samename 0.1.3__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.
- samename-0.1.3/LICENSE +21 -0
- samename-0.1.3/PKG-INFO +381 -0
- samename-0.1.3/README.md +361 -0
- samename-0.1.3/pyproject.toml +35 -0
- samename-0.1.3/setup.cfg +4 -0
- samename-0.1.3/src/samename/__init__.py +18 -0
- samename-0.1.3/src/samename/__main__.py +3 -0
- samename-0.1.3/src/samename/cli.py +186 -0
- samename-0.1.3/src/samename/distance.py +242 -0
- samename-0.1.3/src/samename/index.py +150 -0
- samename-0.1.3/src/samename/lexicon.py +637 -0
- samename-0.1.3/src/samename/match.py +423 -0
- samename-0.1.3/src/samename/parse.py +193 -0
- samename-0.1.3/src/samename/phonemes.py +302 -0
- samename-0.1.3/src/samename.egg-info/PKG-INFO +381 -0
- samename-0.1.3/src/samename.egg-info/SOURCES.txt +18 -0
- samename-0.1.3/src/samename.egg-info/dependency_links.txt +1 -0
- samename-0.1.3/src/samename.egg-info/entry_points.txt +2 -0
- samename-0.1.3/src/samename.egg-info/top_level.txt +1 -0
- samename-0.1.3/tests/test_samename.py +521 -0
samename-0.1.3/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 samename contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
samename-0.1.3/PKG-INFO
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: samename
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Match East Slavic personal names (Ukrainian, Russian, Belarusian) across Cyrillic, Latin romanizations and languages. Zero dependencies.
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/RealAoss/samename
|
|
7
|
+
Keywords: names,name-matching,fuzzy-matching,transliteration,romanization,record-linkage,deduplication,entity-resolution,phonetic,ukrainian,russian,belarusian,cyrillic
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Natural Language :: Ukrainian
|
|
13
|
+
Classifier: Natural Language :: Russian
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# samename
|
|
22
|
+
|
|
23
|
+
**Match East Slavic personal names across scripts, romanizations and languages.**
|
|
24
|
+
`Володимир Зеленський` = `Vladimir Zelensky` = `Wolodymyr Selenskyj` = `Уладзімір Зяленскі`,
|
|
25
|
+
but `Oleksandr` ≠ `Oleksii` and `Ivanov` ≠ `Ivanova`.
|
|
26
|
+
|
|
27
|
+
Ukrainian, Russian and Belarusian names, written in Cyrillic or in any of the
|
|
28
|
+
common Latin romanizations. Pure Python, zero dependencies, works offline.
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
>>> import samename
|
|
32
|
+
>>> samename.is_match("Володимир Олександрович Зеленський", "Dr. Vladimir Zelensky")
|
|
33
|
+
True
|
|
34
|
+
>>> samename.is_match("Oleksandr Kovalenko", "Oleksii Kovalenko")
|
|
35
|
+
False
|
|
36
|
+
>>> print(samename.compare("SHEVCHENKO, Taras H.", "Тарас Григорович Шевченко").explain())
|
|
37
|
+
score 0.98 (strong)
|
|
38
|
+
Taras ~ Тарас 1.00
|
|
39
|
+
H ~ Григорович 0.90
|
|
40
|
+
SHEVCHENKO ~ Шевченко 1.00
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Why this exists
|
|
44
|
+
|
|
45
|
+
One East Slavic name has many legitimate spellings. The same person is
|
|
46
|
+
`Сергій` in a Ukrainian passport, `Сергей` in an older Russian-language
|
|
47
|
+
document and `Сяргей` in a Belarusian one; in Latin script he is Serhii,
|
|
48
|
+
Serhiy, Sergey, Sergei, Sergej, Sergueï or Siarhei, depending on the country,
|
|
49
|
+
the decade and the romanization standard the clerk happened to use. German,
|
|
50
|
+
French and Polish conventions add Schewtschenko, Chevtchenko and Szewczenko
|
|
51
|
+
for one and the same `Шевченко`.
|
|
52
|
+
|
|
53
|
+
Software that compares names as plain strings gets this wrong in both
|
|
54
|
+
directions:
|
|
55
|
+
|
|
56
|
+
- **Refugee registration, family tracing and humanitarian aid** fail to link
|
|
57
|
+
records of one person taken by different agencies in different scripts.
|
|
58
|
+
- **Hospitals, universities and HR systems** create duplicate records, or
|
|
59
|
+
cannot join a Cyrillic record to its passport-spelling twin.
|
|
60
|
+
- **Banks and sanctions screening** flag innocent people whose name merely
|
|
61
|
+
resembles a listed one, because generic fuzzy matching cannot tell
|
|
62
|
+
*Oleksandr* from *Oleksii* or *Ivanov* from *Ivanova*.
|
|
63
|
+
- **Archives, genealogy and libraries** hold the same author under five
|
|
64
|
+
romanizations.
|
|
65
|
+
|
|
66
|
+
`samename` is a small library you can read in an afternoon and drop into any
|
|
67
|
+
pipeline. It is a sibling of [ismatch](https://github.com/RealAoss/ismatch),
|
|
68
|
+
which does the same job for Arabic names.
|
|
69
|
+
|
|
70
|
+
## What it understands
|
|
71
|
+
|
|
72
|
+
| Phenomenon | Example |
|
|
73
|
+
|---|---|
|
|
74
|
+
| Romanization systems (English, German, French, Polish, scientific) | `Шевченко` ↔ Shevchenko / Ševčenko / Szewczenko / Schewtschenko / Chevtchenko |
|
|
75
|
+
| The letters щ, ж, х, ц, ч in every convention | `Хрущёв` ↔ Khrushchev / Chruschtschow / Khrouchtchev / Hruščëv |
|
|
76
|
+
| г as *h* or *g* | `Григорій` ↔ Hryhorii / Grigory · `Згурський` ↔ Zghurskyi |
|
|
77
|
+
| One given name in three languages | `Володимир` ↔ `Владимир` ↔ `Уладзімір` · `Микола` ↔ Nikolai |
|
|
78
|
+
| Western forms listed in the lexicon | `Олександр` ↔ Alexander · `Євген` ↔ Eugene · `Андрій` ↔ Andrew |
|
|
79
|
+
| Belarusian spelling (akanye, ў, дз, ц) | `Іваноў` ↔ Ivanou · `Яўген` ↔ Yauhen · `Ціханоўская` ↔ Tikhanovskaya |
|
|
80
|
+
| Surname endings | `Зеленський` ↔ Zelensky / Zelenskyy / Zelenskij · `Ковальська` ↔ Kovalskaya |
|
|
81
|
+
| ё written as е, soft signs, apostrophes, stress marks | `Хрущёв` ↔ `Хрущев` · `Мар'яна` ↔ `Мар’яна` |
|
|
82
|
+
| Patronymics across languages | `Миколайович` ↔ Nikolaevich · `Іванівна` ↔ Ivanovna · `Іван Якович Франко` ↔ `Иван Яковлевич Франко` |
|
|
83
|
+
| Name order, omitted patronymic | "SHEVCHENKO, Taras" ↔ `Тарас Григорович Шевченко` |
|
|
84
|
+
| Initials, spaced or glued | `Шевченко Т. Г.` ↔ Taras Shevchenko · "Yu. Andrukhovych" ↔ `Юрій Андрухович` |
|
|
85
|
+
| Titles | `пані Олена Петренко` ↔ Dr. Olena Petrenko |
|
|
86
|
+
| Hyphenated and joined parts | `Нечуй-Левицький` ↔ Nechui-Levytskyi · `Анна-Марія` ↔ Annamaria |
|
|
87
|
+
| Look-alike letters of the other script typed into a word | `Iвaн` (Latin I, a) ↔ `Іван` · `Ivаn` (Cyrillic а) ↔ Ivan |
|
|
88
|
+
| Diminutives *(opt-in)* | Sasha ↔ `Олександр` with `diminutives=True` |
|
|
89
|
+
|
|
90
|
+
And, just as important, what it refuses to merge:
|
|
91
|
+
|
|
92
|
+
| Different names | Why they are hard |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `Олександр` Oleksandr ≠ `Олексій` Oleksii | shared first half |
|
|
95
|
+
| `Марія` Mariia ≠ `Марина` Maryna | one consonant apart |
|
|
96
|
+
| `Ігор` Ihor ≠ `Єгор` Yehor | one letter apart |
|
|
97
|
+
| `Олександр` ≠ `Олександра` · Ivan ≠ Ivanna | masculine / feminine given name |
|
|
98
|
+
| Ivanov ≠ Ivanova · `Ковальський` ≠ `Ковальська` | masculine / feminine surname: two people (opt out with `gender_insensitive_surnames=True`) |
|
|
99
|
+
| Shevchenko ≠ Shevchuk · Koval ≠ Kovalenko | same root, different surname |
|
|
100
|
+
| `Петрович` ≠ `Павлович` · `Іванович` ≠ `Іванівна` | different father; brother and sister |
|
|
101
|
+
| Petro Ivanov ≠ Ivan Petrov | same roots, swapped roles |
|
|
102
|
+
| Ivan **Petrovych** Shevchenko ≠ Ivan **Mykolaiovych** Shevchenko | one different part = another person |
|
|
103
|
+
|
|
104
|
+
## How it works
|
|
105
|
+
|
|
106
|
+
1. **Parse** the name: strip titles and stress marks, unify apostrophes, move
|
|
107
|
+
a "SURNAME, Given" head to the end, recognise initials and patronymics.
|
|
108
|
+
2. **Phonemise** every part into a small script-independent alphabet. Cyrillic
|
|
109
|
+
letters and Latin digraphs (`shch`, `sch`, `tsch`, `cz`, `kh`, `zh` ...)
|
|
110
|
+
map onto the same consonants and vowels; an ambiguous Latin spelling such
|
|
111
|
+
as `ch` keeps its alternative readings.
|
|
112
|
+
3. **Align** two parts with a weighted edit distance whose costs model how
|
|
113
|
+
these names really vary: `i`/`y` is nearly free, `g`/`h` and `v`/`w` are
|
|
114
|
+
cheap, a dropped glide is cheap where romanizations drop it, and a missing
|
|
115
|
+
final `a` is expensive because it marks a feminine form.
|
|
116
|
+
4. **Consult a lexicon** of about 370 given names (plus about 100
|
|
117
|
+
diminutives). It links the Ukrainian, Russian and Belarusian forms of one
|
|
118
|
+
name, and knows that some similar spellings are different names.
|
|
119
|
+
5. **Assign** the parts of one full name to the parts of the other, tolerate
|
|
120
|
+
reordering and an omitted patronymic, and punish a clearly different part.
|
|
121
|
+
|
|
122
|
+
No machine learning, no model download: the result is deterministic and every
|
|
123
|
+
score can be explained (`Match.explain()`).
|
|
124
|
+
|
|
125
|
+
## Accuracy
|
|
126
|
+
|
|
127
|
+
`python bench/run.py` compares `samename` with the approaches people usually
|
|
128
|
+
reach for. Each baseline gets the **best possible threshold for that data**;
|
|
129
|
+
`samename` uses its fixed default (0.85).
|
|
130
|
+
|
|
131
|
+
| Set | Pairs | Method | Precision | Recall | F1 |
|
|
132
|
+
|---|---|---|---|---|---|
|
|
133
|
+
| **Blind** (run once, never tuned on) | 8,575 | Levenshtein | 0.794 | 0.507 | 0.618 |
|
|
134
|
+
| | | Transliterate + Levenshtein | 0.880 | 0.931 | 0.905 |
|
|
135
|
+
| | | Transliterate + consonant skeleton | 0.969 | 0.382 | 0.548 |
|
|
136
|
+
| | | **samename** | **0.996** | **0.987** | **0.992** |
|
|
137
|
+
| Development (tuned on) | 5,449 | Levenshtein | 0.751 | 0.482 | 0.587 |
|
|
138
|
+
| | | Transliterate + Levenshtein | 0.853 | 0.915 | 0.883 |
|
|
139
|
+
| | | Transliterate + consonant skeleton | 0.943 | 0.495 | 0.649 |
|
|
140
|
+
| | | **samename** | 0.999 | 1.000 | 1.000 |
|
|
141
|
+
|
|
142
|
+
The blind set (`bench/blind.py`, 78 name groups and 143 deliberately
|
|
143
|
+
confusable pairs) was written by someone who had not seen the matcher's code,
|
|
144
|
+
tests or documentation. It was run once and the matcher was not changed
|
|
145
|
+
afterwards, so its 27 misses and 8 false alarms are all still there
|
|
146
|
+
(`python bench/run.py --errors` prints them). Examples: the patronymics
|
|
147
|
+
`Миколаївна` / `Николаевна` and `Володимирович` / `Уладзіміравіч` are missed,
|
|
148
|
+
the Polish form `Kazimierz Malewicz` is not linked to `Казимир Малевич`, and
|
|
149
|
+
`Кличко` / `Клочко`, `Костенко` / `Косенко` and `Zhanna` / `Yana` are wrongly
|
|
150
|
+
merged.
|
|
151
|
+
|
|
152
|
+
Read these numbers with care:
|
|
153
|
+
|
|
154
|
+
- Only the **blind** row is an honest estimate, and even that set was written
|
|
155
|
+
for this project rather than collected from real records.
|
|
156
|
+
|
|
157
|
+
- The development set was **written by the project authors, who also tuned
|
|
158
|
+
the matcher on it**. Its numbers are a regression benchmark, not an
|
|
159
|
+
evaluation, and they are optimistic: expect clearly lower figures on any
|
|
160
|
+
data the matcher has not seen.
|
|
161
|
+
- It is not real-world data. It is full of deliberately confusable pairs, but
|
|
162
|
+
real records are messier (typos, OCR errors, missing parts, mixed scripts).
|
|
163
|
+
- One development pair is still wrong and is left wrong on purpose rather
|
|
164
|
+
than special-cased: Savchenko / Shevchenko scores 0.86.
|
|
165
|
+
- If you have labelled name pairs from a real system and can share them (or
|
|
166
|
+
just the aggregate results), please open an issue. That is the most
|
|
167
|
+
valuable contribution this project can receive.
|
|
168
|
+
|
|
169
|
+
Speed on a laptop, single thread, CPython 3.14 (`python bench/speed.py`,
|
|
170
|
+
synthetic data: 4,000 distinct full names built from the lexicon plus 1,000
|
|
171
|
+
planted Latin-script duplicates): about 0.35 ms per comparison of two unseen
|
|
172
|
+
three-part names (about 0.05 ms once the name parts are cached); building the
|
|
173
|
+
index of 5,000 names takes about 0.1 s; a search in it takes about 2 ms;
|
|
174
|
+
de-duplicating all 5,000 names takes about 4.5 s and groups all 1,000 planted
|
|
175
|
+
duplicates with their original. An exhaustive search (no blocking) takes
|
|
176
|
+
about 0.6 s.
|
|
177
|
+
|
|
178
|
+
## Install
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
pip install git+https://github.com/RealAoss/samename
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
or clone the repository and run `pip install .`. Python 3.10+.
|
|
185
|
+
|
|
186
|
+
## Usage
|
|
187
|
+
|
|
188
|
+
### Compare two names
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
>>> import samename
|
|
192
|
+
>>> m = samename.compare("Сергій Вікторович Жадан", "Zhadan Serhij")
|
|
193
|
+
>>> round(m.score, 2) # 0.0 - 1.0
|
|
194
|
+
0.92
|
|
195
|
+
>>> m.is_match # score >= threshold (default 0.85)
|
|
196
|
+
True
|
|
197
|
+
>>> m.level # 'strong' | 'probable' | 'possible' | 'no'
|
|
198
|
+
'probable'
|
|
199
|
+
>>> m.pairs # (part_a, part_b, similarity)
|
|
200
|
+
[('Жадан', 'Zhadan', 1.0), ('Сергій', 'Serhij', 1.0)]
|
|
201
|
+
>>> m.unmatched_a, m.reordered
|
|
202
|
+
(['Вікторович'], True)
|
|
203
|
+
>>> m.to_dict() # JSON-ready
|
|
204
|
+
{'score': 0.9238, 'is_match': True, 'level': 'probable', 'pairs': [{'a': 'Жадан', 'b': 'Zhadan', 'score': 1.0}, {'a': 'Сергій', 'b': 'Serhij', 'score': 1.0}], 'unmatched_a': ['Вікторович'], 'unmatched_b': [], 'reordered': True, 'notes': []}
|
|
205
|
+
|
|
206
|
+
>>> samename.score("Hanna Kovalska", "Ганна Ковальська") # just the number
|
|
207
|
+
1.0
|
|
208
|
+
>>> samename.is_match("Hanna", "Анна"), samename.is_match("Hanna", "Анна", threshold=0.95)
|
|
209
|
+
(True, False)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Choosing a threshold: `0.85` balances both error types. For anything that
|
|
213
|
+
blocks a person (sanctions, fraud), keep a human in the loop and treat
|
|
214
|
+
`possible` (0.70-0.85) as "needs review", never as a decision.
|
|
215
|
+
|
|
216
|
+
### Options
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
>>> samename.is_match("Sasha Kovalenko", "Олександр Коваленко")
|
|
220
|
+
False
|
|
221
|
+
>>> samename.is_match("Sasha Kovalenko", "Олександр Коваленко", diminutives=True)
|
|
222
|
+
True
|
|
223
|
+
|
|
224
|
+
>>> print(samename.compare("Ivanov", "Ivanova").explain())
|
|
225
|
+
score 0.57 (no)
|
|
226
|
+
Ivanov ~ Ivanova 0.57
|
|
227
|
+
(Ivanov / Ivanova: masculine and feminine form of one surname)
|
|
228
|
+
>>> samename.is_match("Ivanov", "Ivanova", gender_insensitive_surnames=True) # linking a family
|
|
229
|
+
True
|
|
230
|
+
|
|
231
|
+
>>> samename.score("Микола", "Николай") # one name, two languages
|
|
232
|
+
0.92
|
|
233
|
+
>>> round(samename.score("Микола", "Николай", cross_language=False), 2) # spelling only
|
|
234
|
+
0.58
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Search a list
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
>>> idx = samename.NameIndex(["Тарас Шевченко", "Olena Kovalenko", "Сергей Иванов"])
|
|
241
|
+
>>> idx.add("Юрій Андрухович", id="author-0042")
|
|
242
|
+
>>> idx.search("Shevchenko, Taras")
|
|
243
|
+
[('Тарас Шевченко', 1.0)]
|
|
244
|
+
>>> [(name, round(score, 2)) for name, score in idx.search("Serhii Ivanov")]
|
|
245
|
+
[('Сергей Иванов', 0.96)]
|
|
246
|
+
>>> [(id, round(score, 2)) for id, score in idx.search_ids("Yuri Andrukhovych")]
|
|
247
|
+
[('author-0042', 0.99)]
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
`NameIndex` takes the same options as `compare`. Candidates are found through
|
|
251
|
+
blocking keys (two name parts must share a key; a part written as one word in
|
|
252
|
+
one name and as two in the other, such as Annamaria / Anna-Maria, counts as a
|
|
253
|
+
shared part); pass `exhaustive=True` to `search` to score every stored name
|
|
254
|
+
instead.
|
|
255
|
+
|
|
256
|
+
### Find duplicates
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
>>> names = ["Тарас Шевченко", "Olena Kovalenko", "Taras Shevchenko", "Олена Коваленко", "Oleksii Kovalenko"]
|
|
260
|
+
>>> samename.dedupe(names) # indexes into names
|
|
261
|
+
[[0, 2], [1, 3]]
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Grouping is transitive (single linkage): review large groups before merging
|
|
265
|
+
records.
|
|
266
|
+
|
|
267
|
+
### Blocking keys for databases
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
>>> samename.keys("Шевченко")
|
|
271
|
+
('JVJNK',)
|
|
272
|
+
>>> samename.keys("Szewczenko")
|
|
273
|
+
('JVJNK',)
|
|
274
|
+
>>> samename.keys("Shevchenko") # "ch" is ambiguous in Latin script: two keys
|
|
275
|
+
('JVJNK', 'JVKNK')
|
|
276
|
+
>>> samename.keys("Володимир")
|
|
277
|
+
('VLDMR', '=VOLODYMYR')
|
|
278
|
+
>>> samename.keys("Уладзімір")
|
|
279
|
+
('LDMR', '=VOLODYMYR')
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Store the keys in an indexed column to fetch candidates with plain SQL, then
|
|
283
|
+
score the candidates with `compare`. Keys starting with `=` come from the
|
|
284
|
+
lexicon and link the forms of one given name across languages.
|
|
285
|
+
|
|
286
|
+
### Command line
|
|
287
|
+
|
|
288
|
+
```console
|
|
289
|
+
$ samename compare "Володимир Зеленський" "Vladimir Zelensky"
|
|
290
|
+
score 0.95 (strong)
|
|
291
|
+
Володимир ~ Vladimir 0.92
|
|
292
|
+
Зеленський ~ Zelensky 0.99
|
|
293
|
+
$ samename compare "Oleksandr Kovalenko" "Oleksii Kovalenko"
|
|
294
|
+
score 0.56 (no)
|
|
295
|
+
Oleksandr ~ Oleksii 0.52
|
|
296
|
+
Kovalenko ~ Kovalenko 1.00
|
|
297
|
+
$ samename key "Тарас Шевченко"
|
|
298
|
+
TRS =TARAS JVJNK
|
|
299
|
+
$ samename search tests/people.csv "Шевченко Тарас" --column full_name
|
|
300
|
+
0.97 Taras Shevchenko
|
|
301
|
+
0.92 Тарас Григорович Шевченко
|
|
302
|
+
$ samename dedupe tests/people.csv --column full_name
|
|
303
|
+
# group 1
|
|
304
|
+
Тарас Григорович Шевченко
|
|
305
|
+
Taras Shevchenko
|
|
306
|
+
# group 2
|
|
307
|
+
Olena Kovalenko
|
|
308
|
+
Kovalenko, Olena
|
|
309
|
+
# group 3
|
|
310
|
+
Сергей Иванов
|
|
311
|
+
Serhii Ivanov
|
|
312
|
+
3 group(s) of likely duplicates among 8 names
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
`compare` and `search` exit with 0 for a match / at least one hit and 1
|
|
316
|
+
otherwise; usage and file errors exit with 2. Add `--json` to `compare`,
|
|
317
|
+
`search` or `dedupe` for machine-readable output, and `--diminutives`,
|
|
318
|
+
`--gender-insensitive-surnames` or `--no-cross-language` for the options
|
|
319
|
+
above. Input files are UTF-8: a text file with one name per line, or a CSV /
|
|
320
|
+
TSV file with `--column` (a header name, or a 0-based number); a one-column
|
|
321
|
+
CSV / TSV needs no `--column`.
|
|
322
|
+
|
|
323
|
+
Header rule for CSV / TSV files: with `--column` given by header name, the
|
|
324
|
+
first row is always the header. Otherwise (a column number, or no
|
|
325
|
+
`--column`) the first row is skipped only if that cell is a header word such
|
|
326
|
+
as `name`, `names`, `full_name`, `first_name`, `surname`, `ПІБ`, `прізвище`,
|
|
327
|
+
`ФИО` or `фамилия` (case and spaces / hyphens ignored; the full list is
|
|
328
|
+
`HEADER_WORDS` in `src/samename/cli.py`). Pass `--header` to always skip the
|
|
329
|
+
first row or `--no-header` to always read it as a name. Without installing,
|
|
330
|
+
run `python -m samename ...` with `src` on `PYTHONPATH`.
|
|
331
|
+
|
|
332
|
+
## Limitations
|
|
333
|
+
|
|
334
|
+
Be aware of these before relying on a score:
|
|
335
|
+
|
|
336
|
+
- **A name is not an identity.** Two people can share a full name. Combine
|
|
337
|
+
the score with date of birth, place, document number or other evidence.
|
|
338
|
+
- **Only East Slavic names, only Cyrillic and Latin script.** Text in any
|
|
339
|
+
other script (Arabic, Greek, Chinese, Georgian ...) is ignored and scores
|
|
340
|
+
0. Names from other cultures written in Latin or Cyrillic are compared
|
|
341
|
+
phonetically with no special knowledge.
|
|
342
|
+
- **Short and single-part names** carry little information; `Taras` alone
|
|
343
|
+
never "matches" `Taras Shevchenko`. A patronymic standing alone is treated
|
|
344
|
+
like any other word.
|
|
345
|
+
- **Extra parts are forgiven when two parts agree**: `Olena Petrenko`
|
|
346
|
+
matches `Olena Kovalenko-Petrenko` (0.91) and `Ivan Franko` matches
|
|
347
|
+
`Ivan Franko Jr` (0.91). Initials are weak evidence too:
|
|
348
|
+
`T. H. Shevchenko` matches every T. H. Shevchenko, whatever the names
|
|
349
|
+
behind the initials.
|
|
350
|
+
- **Given names outside the lexicon** are matched by spelling alone. Western
|
|
351
|
+
equivalents that are not listed do not match: Leo / `Лев`, Jeanne /
|
|
352
|
+
`Жанна`, Nick / `Микола`. Diminutives (Sasha, Katya) match only with
|
|
353
|
+
`diminutives=True`, and only the listed ones.
|
|
354
|
+
- **Surnames are matched by rules only.** Close surnames can collide:
|
|
355
|
+
Savchenko / Shevchenko scores 0.86 and is wrongly accepted.
|
|
356
|
+
- **Latin digraphs are ambiguous.** `sch` is read as ш / щ (German,
|
|
357
|
+
simplified Ukrainian), so a surname with a real с + ч cluster does not
|
|
358
|
+
match its plain romanization (`Тарасчук` / Taraschuk scores 0.81).
|
|
359
|
+
- **The lexicon takes sides** where usage is disputed: `Ганна` and `Анна`
|
|
360
|
+
are one name, `Марта` and `Марфа` are two, `Ліна` and `Лена` are two.
|
|
361
|
+
- **Typos are not modelled.** The costs describe romanization and language
|
|
362
|
+
differences, not keyboard slips or OCR errors.
|
|
363
|
+
- **Known misses from the blind set** (see Accuracy): cross-language
|
|
364
|
+
patronymics standing alone, Polish cognate forms of given names, and
|
|
365
|
+
surnames that differ by one inner letter (`Кличко` / `Клочко`).
|
|
366
|
+
|
|
367
|
+
## Contributing
|
|
368
|
+
|
|
369
|
+
The easiest high-impact contribution is a line in
|
|
370
|
+
[`src/samename/lexicon.py`](src/samename/lexicon.py): a given name with its
|
|
371
|
+
Ukrainian, Russian and Belarusian forms. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
python -m unittest discover -s tests # tests
|
|
375
|
+
python bench/run.py --errors # benchmark and every wrong pair
|
|
376
|
+
python bench/speed.py # speed on synthetic data
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## License
|
|
380
|
+
|
|
381
|
+
MIT
|