Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoMatch = errors.New("no matching street found")
ErrNoMatch is returned by Normalize when no street reaches the minimum confidence threshold.
Functions ¶
Types ¶
type Config ¶
type Config struct {
DBPath string `koanf:"db_path"`
}
Config controls parser initialization. DBPath optionally points to an external SQLite streets database; when empty, the embedded copy is used.
type Match ¶
type Match struct {
// Name is the canonical street name as stored in the database.
Name string `json:"name"`
// NormalizedName is the lowercased form used for lookups.
NormalizedName string `json:"normalized_name"`
// Confidence is the match score; 1.0 for exact matches.
Confidence float64 `json:"confidence"`
}
Match is a resolved street with a confidence score in [0, 1].
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser matches free-form street names against an in-memory street index. It is safe for concurrent use.
func NewParser ¶
NewParser loads streets into memory and returns a ready-to-use Parser. When cfg.DBPath is empty, the embedded street database is extracted to a temporary directory; call Stop to release it. On failure the temporary directory is removed before returning.
func (*Parser) Normalize ¶
Normalize matches rawInput against the street index and returns the best match. Exact matches have confidence 1.0; otherwise a weighted blend of Levenshtein similarity and LCS is used, requiring at least 0.6 confidence and 0.4 LCS coverage of the stored name. Returns ErrNoMatch when nothing scores high enough, or a context error when ctx is canceled.