Skip to content

v2.6.1

Latest

Choose a tag to compare

@pudo pudo released this 21 Oct 19:59
· 2 commits to main since this release

A patch release: more vessel-name prefixes for remove_obj_prefixes, a standalone jaro() similarity, and a configurable cutoff for Jaro and Jaro-Winkler.

Changes

Vessel-name prefixes

remove_obj_prefixes now recognises dotted and spaced spellings of M/V (M.V, M V) and tanker prefixes (MT, M/T, M.T, M T, SS). Prefixes only match as whole words, so names like Mtwara Dawn or Ssangyong Star stay as they are (#304).

from rigour.names.prefix import remove_obj_prefixes

remove_obj_prefixes("M.V. Oceanic")    # "Oceanic"
remove_obj_prefixes("M/T Oceanic")     # "Oceanic"
remove_obj_prefixes("SS Oceanic")      # "Oceanic"
remove_obj_prefixes("Mtwara Dawn")     # "Mtwara Dawn"

jaro() and a cutoff argument

rigour.text.distance.jaro (also exported from rigour.text) computes plain Jaro similarity, for callers that apply their own prefix weighting or none at all. jaro and jaro_winkler both take a cutoff argument (default 0.6, the previous hard-coded value): scores at or below it are returned as 0.0. Pass cutoff=0.0 to get the unaltered score (#305).

from rigour.text import jaro, jaro_winkler

jaro("MARTHA", "MARHTA")                   # 0.944…
jaro_winkler("MARTHA", "MARHTA")           # 0.961…
jaro_winkler("abc", "xyz", cutoff=0.0)     # unaltered score

Breaking changes

  • NamePart and Span no longer implement __len__, so len(part) and len(span) now raise TypeError. Use len(part.form) for a part's length, or len(span.parts) for the number of parts in a span (#305).