Documentation ¶
Overview ¶
Package scp provides access to the Super Check Partial (http://www.supercheckpartial.com) database stored in the SCP format. The package also provides functions to download, store and update a MASTER.SCP file. The default remote location for the MASTER.SCP file is http://www.supercheckpartial.com/MASTER.SCP.
File Format Description ¶
1. The file is in plain text format (ASCII). 2. Each line contains one callsign. 3. Lines that begin with # are comments that can be ignored.
Index ¶
- Constants
- Variables
- func Download(remoteURL, localFilename string) error
- func LocalFilename() (string, error)
- func Update(remoteURL, localFilename string) (bool, error)
- type CallHistoryParser
- type Database
- type Entry
- func (e Entry) CompareTo(o Entry) (distance, accuracy)
- func (e Entry) EditTo(o Entry) (distance, accuracy, MatchingAssembly)
- func (e Entry) Get(field FieldName) string
- func (e Entry) GetValues(fields ...FieldName) []string
- func (e Entry) Key() string
- func (e Entry) PopulatedFields() FieldSet
- func (e Entry) String() string
- type EntryParser
- type EntryParserFunc
- type FieldName
- type FieldSet
- type FieldValues
- type Match
- type MatchingAssembly
- type MatchingOperation
- type MatchingPart
Constants ¶
const DefaultLocalFilename = ".config/hamradio/MASTER.SCP"
DefaultLocalFilename is the default name for the file that is used to store the contents of MASTER.SCP locally in the user's home directory.
const DefaultURL = "http://www.supercheckpartial.com/MASTER.SCP"
DefaultURL is the original URL of the MASTER.SCP file: http://www.supercheckpartial.com/MASTER.SCP
Variables ¶
var DefaultFieldSet = NewFieldSet("Call", "Name", "Loc1", "Loc2", "Sect", "State", "CK", "BirthDate", "Exch1", "Misc", "UserText", "LastUpdateNote")
DefaultFieldSet defines the default field set that is used if no !!Order!! directive is present in the call history file.
Functions ¶
func LocalFilename ¶
LocalFilename returns the absolute path of the default local filename in the current user's home directory.
Types ¶
type CallHistoryParser ¶ added in v0.2.0
type CallHistoryParser struct {
// contains filtered or unexported fields
}
CallHistoryParser is used to parse the entries in a call history file to fill the database.
func NewCallHistoryParser ¶ added in v0.2.0
func NewCallHistoryParser() *CallHistoryParser
NewCallHistoryParser creates a new CallHistoryParser that uses the DefaultFieldSet.
func (*CallHistoryParser) ParseEntry ¶ added in v0.2.0
func (p *CallHistoryParser) ParseEntry(line string) (Entry, bool)
ParseEntry parses the given line and returns the corresponding entry. If the line contains other information (for example a comment or a directive), this method returns false in the second return value.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents the SCP database.
func LoadRemote ¶
LoadRemote loads the database file from a remote URL.
func Read ¶
func Read(r io.Reader, parser EntryParser) (*Database, error)
Read the database from a reader unsing the given entry parser.
func ReadCallHistory ¶ added in v0.2.0
ReadCallHistory creates a new Database and fills it from the call history that is read with the given reader.
type Entry ¶ added in v0.2.0
type Entry struct {
// contains filtered or unexported fields
}
Entry represents one entry in a Database.
func (Entry) CompareTo ¶ added in v0.2.0
CompareTo compares this Entry's key with the key of the given Entry. It returns a measure of similarity in form of the editing distance and the matching accuracy.
func (Entry) EditTo ¶ added in v0.2.0
func (e Entry) EditTo(o Entry) (distance, accuracy, MatchingAssembly)
EditTo provides the editing distance, matching accuracy, and the given Entry's key as MatchingAssembly
func (Entry) GetValues ¶ added in v0.2.0
GetValues returns the values of the fields with the given names as slice. The returned slice is of the same size as the number of field names. If a field is not populated, the corresponding slice entry is empty.
func (Entry) PopulatedFields ¶ added in v0.2.0
PopulatedFields returns a FieldSet that contains all populated fields of this Entry.
type EntryParser ¶ added in v0.2.0
EntryParser defines an abstraction for parsing a single entry from a given line in a file.
type EntryParserFunc ¶ added in v0.2.0
EntryParserFunc wraps a matching function into the EntryParser interface
func (EntryParserFunc) ParseEntry ¶ added in v0.2.0
func (f EntryParserFunc) ParseEntry(line string) (Entry, bool)
type FieldName ¶ added in v0.2.0
type FieldName string
FieldName defines the name of a field in an Entry.
type FieldSet ¶ added in v0.2.0
type FieldSet []FieldName
FieldSet defines a set of fields used in a call history file.
func NewFieldSet ¶ added in v0.2.0
NewFieldSet creates a new FieldSet with the given field names.
type FieldValues ¶ added in v0.2.0
FieldValues contains all fields of an Entry and their corresponding values.
type Match ¶ added in v0.2.0
type Match struct { Entry Assembly MatchingAssembly // contains filtered or unexported fields }
type MatchingAssembly ¶ added in v0.2.0
type MatchingAssembly []MatchingPart
MatchingAssembly describes how a certain key matches to another key, using editing operations.
func (MatchingAssembly) ContainsFalseFriend ¶ added in v0.2.1
func (m MatchingAssembly) ContainsFalseFriend() bool
ContainsFalseFriend indicates if this matching assembly contains a false friend.
func (MatchingAssembly) LongestPart ¶ added in v0.2.0
func (m MatchingAssembly) LongestPart() int
LongestPart returns the length of the longest matching part.
func (MatchingAssembly) String ¶ added in v0.2.0
func (m MatchingAssembly) String() string
type MatchingOperation ¶ added in v0.1.1
type MatchingOperation int
MatchingOperation represents an editing operation that is applied to a key to transform it into another key.
const ( // NOP = no edit required, the part matches exactly NOP MatchingOperation = iota // Insert this part Insert // Delete this part Delete // Substitute this part Substitute // FalseFriend is a subsitute that is close in CW to this part FalseFriend )
type MatchingPart ¶ added in v0.2.0
type MatchingPart struct { OP MatchingOperation Value string }
Part represents a part of a key with the corresponding editing operation.