rigour 2.6.0__tar.gz → 2.6.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. {rigour-2.6.0 → rigour-2.6.2}/PKG-INFO +2 -2
  2. {rigour-2.6.0 → rigour-2.6.2}/pyproject.toml +26 -2
  3. {rigour-2.6.0 → rigour-2.6.2}/rigour/_core.pyi +0 -4
  4. {rigour-2.6.0 → rigour-2.6.2}/rigour/ids/__init__.py +15 -1
  5. {rigour-2.6.0 → rigour-2.6.2}/rigour/ids/stdnum_.py +28 -2
  6. {rigour-2.6.0 → rigour-2.6.2}/rigour/text/__init__.py +2 -0
  7. {rigour-2.6.0 → rigour-2.6.2}/rigour/text/distance.py +39 -2
  8. {rigour-2.6.0 → rigour-2.6.2}/rust/Cargo.lock +3 -3
  9. {rigour-2.6.0 → rigour-2.6.2}/rust/Cargo.toml +2 -2
  10. {rigour-2.6.0 → rigour-2.6.2}/rust/data/names/stopwords.json +7 -0
  11. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/part.rs +0 -25
  12. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/prefix.rs +11 -0
  13. {rigour-2.6.0 → rigour-2.6.2}/LICENSE +0 -0
  14. {rigour-2.6.0 → rigour-2.6.2}/README.md +0 -0
  15. {rigour-2.6.0 → rigour-2.6.2}/rigour/__init__.py +0 -0
  16. {rigour-2.6.0 → rigour-2.6.2}/rigour/addresses/__init__.py +0 -0
  17. {rigour-2.6.0 → rigour-2.6.2}/rigour/addresses/cleaning.py +0 -0
  18. {rigour-2.6.0 → rigour-2.6.2}/rigour/addresses/compare.py +0 -0
  19. {rigour-2.6.0 → rigour-2.6.2}/rigour/addresses/format.py +0 -0
  20. {rigour-2.6.0 → rigour-2.6.2}/rigour/addresses/normalize.py +0 -0
  21. {rigour-2.6.0 → rigour-2.6.2}/rigour/boolean.py +0 -0
  22. {rigour-2.6.0 → rigour-2.6.2}/rigour/data/__init__.py +0 -0
  23. {rigour-2.6.0 → rigour-2.6.2}/rigour/data/addresses/__init__.py +0 -0
  24. {rigour-2.6.0 → rigour-2.6.2}/rigour/data/addresses/data.py +0 -0
  25. {rigour-2.6.0 → rigour-2.6.2}/rigour/data/addresses/formats.yml +0 -0
  26. {rigour-2.6.0 → rigour-2.6.2}/rigour/data/langs/__init__.py +0 -0
  27. {rigour-2.6.0 → rigour-2.6.2}/rigour/data/langs/iso639.py +0 -0
  28. {rigour-2.6.0 → rigour-2.6.2}/rigour/dates.py +0 -0
  29. {rigour-2.6.0 → rigour-2.6.2}/rigour/env.py +0 -0
  30. {rigour-2.6.0 → rigour-2.6.2}/rigour/ids/common.py +0 -0
  31. {rigour-2.6.0 → rigour-2.6.2}/rigour/ids/imo.py +0 -0
  32. {rigour-2.6.0 → rigour-2.6.2}/rigour/ids/npi.py +0 -0
  33. {rigour-2.6.0 → rigour-2.6.2}/rigour/ids/ogrn.py +0 -0
  34. {rigour-2.6.0 → rigour-2.6.2}/rigour/ids/strict.py +0 -0
  35. {rigour-2.6.0 → rigour-2.6.2}/rigour/ids/uei.py +0 -0
  36. {rigour-2.6.0 → rigour-2.6.2}/rigour/ids/wikidata.py +0 -0
  37. {rigour-2.6.0 → rigour-2.6.2}/rigour/langs/__init__.py +0 -0
  38. {rigour-2.6.0 → rigour-2.6.2}/rigour/langs/synonyms.py +0 -0
  39. {rigour-2.6.0 → rigour-2.6.2}/rigour/langs/text.py +0 -0
  40. {rigour-2.6.0 → rigour-2.6.2}/rigour/langs/util.py +0 -0
  41. {rigour-2.6.0 → rigour-2.6.2}/rigour/mime/__init__.py +0 -0
  42. {rigour-2.6.0 → rigour-2.6.2}/rigour/mime/filename.py +0 -0
  43. {rigour-2.6.0 → rigour-2.6.2}/rigour/mime/mappings.py +0 -0
  44. {rigour-2.6.0 → rigour-2.6.2}/rigour/mime/mime.py +0 -0
  45. {rigour-2.6.0 → rigour-2.6.2}/rigour/mime/parse.py +0 -0
  46. {rigour-2.6.0 → rigour-2.6.2}/rigour/mime/types.py +0 -0
  47. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/__init__.py +0 -0
  48. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/analyze.py +0 -0
  49. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/check.py +0 -0
  50. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/compare.py +0 -0
  51. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/name.py +0 -0
  52. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/ordering.py +0 -0
  53. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/org_types.py +0 -0
  54. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/part.py +0 -0
  55. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/pick.py +0 -0
  56. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/prefix.py +0 -0
  57. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/split_phrases.py +0 -0
  58. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/symbol.py +0 -0
  59. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/tag.py +0 -0
  60. {rigour-2.6.0 → rigour-2.6.2}/rigour/names/tokenize.py +0 -0
  61. {rigour-2.6.0 → rigour-2.6.2}/rigour/py.typed +0 -0
  62. {rigour-2.6.0 → rigour-2.6.2}/rigour/reset.py +0 -0
  63. {rigour-2.6.0 → rigour-2.6.2}/rigour/territories/__init__.py +0 -0
  64. {rigour-2.6.0 → rigour-2.6.2}/rigour/territories/lookup.py +0 -0
  65. {rigour-2.6.0 → rigour-2.6.2}/rigour/territories/match.py +0 -0
  66. {rigour-2.6.0 → rigour-2.6.2}/rigour/territories/territory.py +0 -0
  67. {rigour-2.6.0 → rigour-2.6.2}/rigour/territories/util.py +0 -0
  68. {rigour-2.6.0 → rigour-2.6.2}/rigour/text/checksum.py +0 -0
  69. {rigour-2.6.0 → rigour-2.6.2}/rigour/text/cleaning.py +0 -0
  70. {rigour-2.6.0 → rigour-2.6.2}/rigour/text/normalize.py +0 -0
  71. {rigour-2.6.0 → rigour-2.6.2}/rigour/text/phonetics.py +0 -0
  72. {rigour-2.6.0 → rigour-2.6.2}/rigour/text/scripts.py +0 -0
  73. {rigour-2.6.0 → rigour-2.6.2}/rigour/text/stopwords.py +0 -0
  74. {rigour-2.6.0 → rigour-2.6.2}/rigour/text/translit.py +0 -0
  75. {rigour-2.6.0 → rigour-2.6.2}/rigour/time.py +0 -0
  76. {rigour-2.6.0 → rigour-2.6.2}/rigour/units.py +0 -0
  77. {rigour-2.6.0 → rigour-2.6.2}/rigour/urls/__init__.py +0 -0
  78. {rigour-2.6.0 → rigour-2.6.2}/rigour/urls/cleaning.py +0 -0
  79. {rigour-2.6.0 → rigour-2.6.2}/rigour/urls/compare.py +0 -0
  80. {rigour-2.6.0 → rigour-2.6.2}/rigour/urls/util.py +0 -0
  81. {rigour-2.6.0 → rigour-2.6.2}/rigour/util.py +0 -0
  82. {rigour-2.6.0 → rigour-2.6.2}/rust/build.rs +0 -0
  83. {rigour-2.6.0 → rigour-2.6.2}/rust/data/addresses/forms.json +0 -0
  84. {rigour-2.6.0 → rigour-2.6.2}/rust/data/names/compare.json +0 -0
  85. {rigour-2.6.0 → rigour-2.6.2}/rust/data/names/org_types.json +0 -0
  86. {rigour-2.6.0 → rigour-2.6.2}/rust/data/names/person_names.txt +0 -0
  87. {rigour-2.6.0 → rigour-2.6.2}/rust/data/names/symbols.json +0 -0
  88. {rigour-2.6.0 → rigour-2.6.2}/rust/data/territories/data.jsonl +0 -0
  89. {rigour-2.6.0 → rigour-2.6.2}/rust/data/text/ordinals.json +0 -0
  90. {rigour-2.6.0 → rigour-2.6.2}/rust/data/text/stopwords.json +0 -0
  91. {rigour-2.6.0 → rigour-2.6.2}/rust/src/addresses/analyze.rs +0 -0
  92. {rigour-2.6.0 → rigour-2.6.2}/rust/src/addresses/compare.rs +0 -0
  93. {rigour-2.6.0 → rigour-2.6.2}/rust/src/addresses/fingerprint.rs +0 -0
  94. {rigour-2.6.0 → rigour-2.6.2}/rust/src/addresses/mod.rs +0 -0
  95. {rigour-2.6.0 → rigour-2.6.2}/rust/src/addresses/tagger.rs +0 -0
  96. {rigour-2.6.0 → rigour-2.6.2}/rust/src/addresses/token.rs +0 -0
  97. {rigour-2.6.0 → rigour-2.6.2}/rust/src/constants.rs +0 -0
  98. {rigour-2.6.0 → rigour-2.6.2}/rust/src/generated/.gitkeep +0 -0
  99. {rigour-2.6.0 → rigour-2.6.2}/rust/src/lib.rs +0 -0
  100. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/alignment.rs +0 -0
  101. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/analyze.rs +0 -0
  102. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/compare.rs +0 -0
  103. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/constants.rs +0 -0
  104. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/mod.rs +0 -0
  105. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/name.rs +0 -0
  106. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/ordering.rs +0 -0
  107. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/org_types.rs +0 -0
  108. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/pairing.rs +0 -0
  109. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/person_names.rs +0 -0
  110. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/pick.rs +0 -0
  111. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/stopwords.rs +0 -0
  112. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/symbol.rs +0 -0
  113. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/symbols.rs +0 -0
  114. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/tag.rs +0 -0
  115. {rigour-2.6.0 → rigour-2.6.2}/rust/src/names/tagger.rs +0 -0
  116. {rigour-2.6.0 → rigour-2.6.2}/rust/src/territories.rs +0 -0
  117. {rigour-2.6.0 → rigour-2.6.2}/rust/src/text/distance.rs +0 -0
  118. {rigour-2.6.0 → rigour-2.6.2}/rust/src/text/matcher.rs +0 -0
  119. {rigour-2.6.0 → rigour-2.6.2}/rust/src/text/mod.rs +0 -0
  120. {rigour-2.6.0 → rigour-2.6.2}/rust/src/text/normalize.rs +0 -0
  121. {rigour-2.6.0 → rigour-2.6.2}/rust/src/text/numbers.rs +0 -0
  122. {rigour-2.6.0 → rigour-2.6.2}/rust/src/text/ordinals.rs +0 -0
  123. {rigour-2.6.0 → rigour-2.6.2}/rust/src/text/phonetics.rs +0 -0
  124. {rigour-2.6.0 → rigour-2.6.2}/rust/src/text/scripts.rs +0 -0
  125. {rigour-2.6.0 → rigour-2.6.2}/rust/src/text/stopwords.rs +0 -0
  126. {rigour-2.6.0 → rigour-2.6.2}/rust/src/text/tokenize.rs +0 -0
  127. {rigour-2.6.0 → rigour-2.6.2}/rust/src/text/translit.rs +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rigour
3
- Version: 2.6.0
3
+ Version: 2.6.2
4
4
  Classifier: Intended Audience :: Developers
5
5
  Classifier: Operating System :: OS Independent
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -17,7 +17,7 @@ Requires-Dist: orjson>=3.0.0,<4.0.0
17
17
  Requires-Dist: python-stdnum>=2.0,<3.0.0
18
18
  Requires-Dist: jinja2>=3.1.0,<4.0.0
19
19
  Requires-Dist: pip>=10.0.0 ; extra == 'dev'
20
- Requires-Dist: bump2version ; extra == 'dev'
20
+ Requires-Dist: bump-my-version ; extra == 'dev'
21
21
  Requires-Dist: wheel>=0.29.0 ; extra == 'dev'
22
22
  Requires-Dist: ruamel-yaml ; extra == 'dev'
23
23
  Requires-Dist: ruff>=0.16.0,<0.18.0 ; extra == 'dev'
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "rigour"
7
- version = "2.6.0"
7
+ version = "2.6.2"
8
8
  description = "Financial crime domain data validation and normalization library."
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -38,7 +38,7 @@ Issues = "https://github.com/opensanctions/rigour/issues"
38
38
  [project.optional-dependencies]
39
39
  dev = [
40
40
  "pip>=10.0.0",
41
- "bump2version",
41
+ "bump-my-version",
42
42
  "wheel>=0.29.0",
43
43
  "ruamel.yaml",
44
44
  # Bounded on purpose: ruff's default rule selection moves between minor
@@ -63,6 +63,30 @@ docs = [
63
63
  "mkdocs-material",
64
64
  ]
65
65
 
66
+ [tool.bumpversion]
67
+ current_version = "2.6.2"
68
+ commit = true
69
+ tag = true
70
+
71
+ [[tool.bumpversion.files]]
72
+ filename = "pyproject.toml"
73
+ search = 'version = "{current_version}"'
74
+ replace = 'version = "{new_version}"'
75
+
76
+ [[tool.bumpversion.files]]
77
+ filename = "rust/Cargo.toml"
78
+ search = 'version = "{current_version}"'
79
+ replace = 'version = "{new_version}"'
80
+
81
+ [[tool.bumpversion.files]]
82
+ filename = "rust/Cargo.lock"
83
+ search = '''
84
+ name = "rigour-core"
85
+ version = "{current_version}"'''
86
+ replace = '''
87
+ name = "rigour-core"
88
+ version = "{new_version}"'''
89
+
66
90
  [tool.maturin]
67
91
  # pyo3/generate-import-lib lets the Windows wheel job link without a
68
92
  # real Python install (PyO3 generates a stub import library).
@@ -164,8 +164,6 @@ class NamePart:
164
164
  phonetics: bool = True,
165
165
  ) -> None: ...
166
166
 
167
- def __len__(self) -> int: ...
168
-
169
167
  @classmethod
170
168
  def tag_sort(cls, parts: list[NamePart]) -> list[NamePart]: ...
171
169
 
@@ -179,8 +177,6 @@ class Span:
179
177
 
180
178
  def __init__(self, parts: list[NamePart], symbol: Symbol) -> None: ...
181
179
 
182
- def __len__(self) -> int: ...
183
-
184
180
 
185
181
  class Name:
186
182
  """A name — top of the rigour.names object graph."""
@@ -16,7 +16,19 @@ from rigour.ids.common import IdentifierFormat
16
16
  from rigour.ids.imo import IMO
17
17
  from rigour.ids.npi import NPI
18
18
  from rigour.ids.ogrn import OGRN
19
- from rigour.ids.stdnum_ import BIC, CNPJ, CPF, FIGI, IBAN, INN, ISIN, LEI, SSN, USCC
19
+ from rigour.ids.stdnum_ import (
20
+ BIC,
21
+ CNPJ,
22
+ CPF,
23
+ EIN,
24
+ FIGI,
25
+ IBAN,
26
+ INN,
27
+ ISIN,
28
+ LEI,
29
+ SSN,
30
+ USCC,
31
+ )
20
32
  from rigour.ids.strict import StrictFormat
21
33
  from rigour.ids.uei import UEI
22
34
  from rigour.ids.wikidata import WikidataQID
@@ -36,6 +48,7 @@ _FORMATS: tuple[FormatType, ...] = (
36
48
  LEI,
37
49
  UEI,
38
50
  SSN,
51
+ EIN,
39
52
  CPF,
40
53
  CNPJ,
41
54
  USCC,
@@ -100,6 +113,7 @@ __all__ = [
100
113
  "BIC",
101
114
  "CNPJ",
102
115
  "CPF",
116
+ "EIN",
103
117
  "FIGI",
104
118
  "IBAN",
105
119
  "IMO",
@@ -1,10 +1,9 @@
1
-
2
1
  from stdnum import bic, figi, iban, isin, lei
3
2
  from stdnum.br import cnpj, cpf
4
3
  from stdnum.cn import uscc
5
4
  from stdnum.exceptions import ValidationError
6
5
  from stdnum.ru import inn
7
- from stdnum.us import ssn
6
+ from stdnum.us import ein, ssn
8
7
 
9
8
  from rigour.ids.common import IdentifierFormat
10
9
 
@@ -160,6 +159,33 @@ class SSN(IdentifierFormat):
160
159
  return ssn.format(value)
161
160
 
162
161
 
162
+ class EIN(IdentifierFormat):
163
+ """US Employer Identification Number, the IRS tax ID of businesses and other entities"""
164
+
165
+ NAME = "ein"
166
+ TITLE = "EIN"
167
+ STRONG = False
168
+
169
+ @classmethod
170
+ def is_valid(cls, value: str) -> bool:
171
+ return cls.normalize(value) is not None
172
+
173
+ @classmethod
174
+ def normalize(cls, value: str) -> str | None:
175
+ try:
176
+ number = ein.compact(ein.validate(value))
177
+ except ValidationError:
178
+ return None
179
+ # Placeholders such as 999999999 or 111111111 carry issued prefixes.
180
+ if len(set(number)) == 1:
181
+ return None
182
+ return number
183
+
184
+ @classmethod
185
+ def format(cls, value: str) -> str:
186
+ return ein.format(value)
187
+
188
+
163
189
  class CPF(IdentifierFormat):
164
190
  """Cadastro de Pessoas Físicas, Brazilian national identifier"""
165
191
 
@@ -2,6 +2,7 @@ from rigour.text.checksum import text_hash
2
2
  from rigour.text.cleaning import remove_bracketed_text, remove_emoji
3
3
  from rigour.text.distance import (
4
4
  is_levenshtein_plausible,
5
+ jaro,
5
6
  jaro_winkler,
6
7
  levenshtein,
7
8
  levenshtein_similarity,
@@ -16,6 +17,7 @@ __all__ = [
16
17
  "is_nullplace",
17
18
  "is_nullword",
18
19
  "is_stopword",
20
+ "jaro",
19
21
  "jaro_winkler",
20
22
  "levenshtein",
21
23
  "levenshtein_similarity",
@@ -3,6 +3,7 @@ from functools import lru_cache
3
3
 
4
4
  from rigour import env
5
5
  from rigour._core import (
6
+ raw_jaro,
6
7
  raw_jaro_winkler,
7
8
  raw_levenshtein,
8
9
  raw_levenshtein_cutoff,
@@ -101,15 +102,51 @@ def is_levenshtein_plausible(
101
102
 
102
103
 
103
104
  @lru_cache(maxsize=MEMO_SMALL)
104
- def jaro_winkler(left: str, right: str, max_length: int = env.MAX_NAME_LENGTH) -> float:
105
+ def jaro(
106
+ left: str,
107
+ right: str,
108
+ max_length: int = env.MAX_NAME_LENGTH,
109
+ cutoff: float = 0.6,
110
+ ) -> float:
111
+ """Compute the Jaro similarity of two strings.
112
+
113
+ Use this over [jaro_winkler][rigour.text.distance.jaro_winkler] when
114
+ the caller applies its own prefix weighting, or none at all.
115
+
116
+ Args:
117
+ left: A string.
118
+ right: A string.
119
+ max_length: Truncate both strings to this many characters before
120
+ comparing.
121
+ cutoff: Scores at or below this value are returned as 0.0. Pass
122
+ 0.0 to get the unaltered score.
123
+
124
+ Returns:
125
+ A float between 0.0 and 1.0.
126
+ """
127
+ score = raw_jaro(left[:max_length], right[:max_length])
128
+ return score if score > cutoff else 0.0
129
+
130
+
131
+ @lru_cache(maxsize=MEMO_SMALL)
132
+ def jaro_winkler(
133
+ left: str,
134
+ right: str,
135
+ max_length: int = env.MAX_NAME_LENGTH,
136
+ cutoff: float = 0.6,
137
+ ) -> float:
105
138
  """Compute the Jaro-Winkler similarity of two strings.
106
139
 
107
140
  Args:
108
141
  left: A string.
109
142
  right: A string.
143
+ max_length: Truncate both strings to this many characters before
144
+ comparing.
145
+ cutoff: Scores at or below this value are returned as 0.0. Pass
146
+ 0.0 to get the unaltered score.
110
147
 
111
148
  Returns:
112
149
  A float between 0.0 and 1.0.
113
150
  """
114
151
  score = raw_jaro_winkler(left[:max_length], right[:max_length])
115
- return score if score > 0.6 else 0.0
152
+ return score if score > cutoff else 0.0
@@ -603,9 +603,9 @@ checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092"
603
603
 
604
604
  [[package]]
605
605
  name = "lru"
606
- version = "0.18.5"
606
+ version = "0.19.0"
607
607
  source = "registry+https://github.com/rust-lang/crates.io-index"
608
- checksum = "ef9ac18847474e638e3702b76c65d4eb93428471a74778ef0f1be711717f89b5"
608
+ checksum = "4a9f71e3591c7ec44d3e563e87bf14ddc2bada8519dca046e5b0e560cd004e2d"
609
609
  dependencies = [
610
610
  "hashbrown",
611
611
  ]
@@ -811,7 +811,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
811
811
 
812
812
  [[package]]
813
813
  name = "rigour-core"
814
- version = "2.6.0"
814
+ version = "2.6.2"
815
815
  dependencies = [
816
816
  "aho-corasick",
817
817
  "bitflags",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "rigour-core"
3
- version = "2.6.0"
3
+ version = "2.6.2"
4
4
  edition = "2024"
5
5
  rust-version = "1.86"
6
6
  license = "MIT"
@@ -47,7 +47,7 @@ rapidfuzz = "0.5"
47
47
 
48
48
  # LRU caches. Currently used for `maybe_ascii`'s process-wide result
49
49
  # cache. Tiny crate (~500 LoC, no deps), O(1) get/put.
50
- lru = "0.18"
50
+ lru = "0.19"
51
51
 
52
52
  # Aho-Corasick automaton for the multi-needle string search used by
53
53
  # `names::matcher::Needles`, which backs org_types replacement, the
@@ -51,8 +51,15 @@
51
51
  "trading as"
52
52
  ],
53
53
  "obj_name_prefixes": [
54
+ "M T",
55
+ "M V",
56
+ "M.T",
57
+ "M.V",
58
+ "M/T",
54
59
  "M/V",
60
+ "MT",
55
61
  "MV",
62
+ "SS",
56
63
  "The"
57
64
  ],
58
65
  "org_name_prefixes": [
@@ -222,10 +222,6 @@ impl NamePart {
222
222
  self.hash
223
223
  }
224
224
 
225
- fn __len__(&self) -> usize {
226
- self.form_str.chars().count()
227
- }
228
-
229
225
  fn __repr__(&self) -> String {
230
226
  format!(
231
227
  "<NamePart('{}', {}, '{}')>",
@@ -359,27 +355,6 @@ impl Span {
359
355
  })
360
356
  }
361
357
 
362
- /// Total character length of the covered parts' surface forms.
363
- ///
364
- /// Computed on demand by walking `parts` rather than cached at
365
- /// construction, so building a `Span` nobody measures costs
366
- /// nothing. Sums `form` char counts (join spaces excluded), matching
367
- /// the pre-cache semantics.
368
- fn __len__(&self, py: Python<'_>) -> usize {
369
- self.parts
370
- .bind(py)
371
- .iter()
372
- .map(|part| {
373
- part.cast::<NamePart>()
374
- .expect("Span.parts holds NamePart")
375
- .borrow()
376
- .form_str
377
- .chars()
378
- .count()
379
- })
380
- .sum()
381
- }
382
-
383
358
  fn __hash__(&self) -> isize {
384
359
  self.hash
385
360
  }
@@ -87,5 +87,16 @@ mod tests {
87
87
  #[test]
88
88
  fn obj_prefix_dropped() {
89
89
  assert_eq!(remove_obj_prefixes("M/V Oceanic"), "Oceanic");
90
+ assert_eq!(remove_obj_prefixes("M.V. Oceanic"), "Oceanic");
91
+ assert_eq!(remove_obj_prefixes("m v oceanic"), "oceanic");
92
+ assert_eq!(remove_obj_prefixes("M/T Oceanic"), "Oceanic");
93
+ assert_eq!(remove_obj_prefixes("mt oceanic"), "oceanic");
94
+ assert_eq!(remove_obj_prefixes("SS Oceanic"), "Oceanic");
95
+ }
96
+
97
+ #[test]
98
+ fn obj_prefix_needs_word_boundary() {
99
+ assert_eq!(remove_obj_prefixes("Mtwara Dawn"), "Mtwara Dawn");
100
+ assert_eq!(remove_obj_prefixes("Ssangyong Star"), "Ssangyong Star");
90
101
  }
91
102
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes