betting_combat.normalizers.names
names.py — fighter names across sources (today’s rules, kept exactly: the history’s ids were resolved by them): Kalshi, UFCStats, Wikipedia, the sportsbook lines and the judge scores spell one fighter differently (‘Su Mudaerji’ / ‘Sumudaerji’, ‘Sergey Spivak’ / ‘Serghei Spivac’, ‘Seok Hyun Ko’ / ‘Seokhyeon Ko’).
The research matched two sources’ bouts by name words: each fighter sharing a word of three
letters or more, on the card date +/- 1 day. That rule is kept as it is (every bout it matched
is matched the same way). When it finds NO bout, :func:pair_fallback is tried:
pinned one of the two names shares a word with exactly one fighter of the window's bouts, and is that fighter (:func:`variant`): the fighter is on one bout of the card, so that bout is the fightsimilar and the other name is that bout's other fighter spelt differently (:func:`similar`: the same letters without spaces, the same words in another order, one name's words inside the other's, or letters >= 80% alike)result or, when a result is given (``winner``), the two sources' winners agree, both fighters named: the opponent under another name ('Valesca Machado' / 'Tina Black', 2026-09-26), accepted only on the agreeing resultThe research’s rule is FALLBACK = False (the parity tests pin it); production matches with
the fallback.
Words are compared after :func:canon_name: letters NFKD drops (ł, the dotless i, ø đ ß æ) are
transliterated first, so ‘Łukasz’ is ‘lukasz’, not ‘ukasz’.
Classes
PairMatch
The fallback’s verdict for one pair: the bout (an index into the window), whether the first name is the bout’s first fighter, and the rule (‘similar’ / ‘result’).
Functions
ascii_name
ascii_name(s: Any) -> strThe name in ASCII: transliterated (TRANSLIT), then accents dropped.
canon_name
canon_name(s: Any) -> strLower-case ASCII words, punctuation and suffixes (jr, sr, ii, iii, iv) removed: ‘Michael Aswell Jr.’ -> ‘michael aswell’; ‘Łukasz Brzeski’ -> ‘lukasz brzeski’.
compact
compact(s: Any) -> strThe canonical name’s letters without spaces: ‘Su Mudaerji’ -> ‘sumudaerji’.
division_of
division_of(weight_class: Any, womens_titles: bool = False) -> tuple[str, bool](‘Lightweight’, women) from a UFCStats weight class string; ‘Other’ if none.
womens_titles (our ids): a women’s title bout is a women’s bout (‘UFC Women’s
Strawweight Title Bout’: 68 bouts the research read as men’s, its rule the default so the
legacy build stays the research’s).
letters_alike
letters_alike(a: Any, b: Any) -> floatHow alike the two names’ letters are (SequenceMatcher ratio of the compact names).
name_tokens
name_tokens(s: Any) -> frozenset[str]The name’s words longer than two letters (hyphens split).
norm_name
norm_name(s: Any) -> strLower-case ASCII letters and single spaces: ‘Łukasz Brzeski’ -> ‘lukasz brzeski’.
pair_fallback
pair_fallback(a: str, b: str, bouts: Sequence[tuple[str, str]], tokens: Any, winner: str | None = None, bout_winners: Sequence[int | None] | None = None) -> PairMatch | NoneThe bout of bouts (the window’s (fighter 1, fighter 2) names) that the pair
a v b is, when the word rule found none (see the module doc); None when no bout
or several qualify.
Args: tokens: the caller’s word rule (a name -> its set of words), so ‘shares a word’ is exactly the research’s test. winner: the pair’s winner, ‘a’ or ‘b’ (None: unknown, no result rule). bout_winners: per bout, its winning slot (1 or 2; None or 0: no winner).
similar
similar(a: Any, b: Any) -> boolOne fighter spelt two ways: the same letters without spaces (in any word order),
the same words in another order, one name’s words all in the other’s (‘Norma Dumont’ /
‘Norma Dumont Viana’), or letters at least SIMILAR alike (‘Sergey Spivak’ /
‘Serghei Spivac’; of the given names when the surname is one: ‘Cy’ / ‘Carl Charlie’
are two people).
strictly_same
strictly_same(a: Any, b: Any) -> boolOne fighter’s two spellings by the strict rules only (the card loader’s on our ids,
taking a name it cannot find exactly; similar’s looser rules are not enough there).
Accents, case, punctuation and suffixes never count (canon_name: ‘José Mauro Delano’
is ‘jose mauro delano’). The rules:
- the same letters in any word order (‘Ko Seok-hyeon’ / ‘Seokhyeon Ko’);
- the same surname, the given names alike (
_given_alike: ‘Phil’ / ‘Philip Rowe’, ‘Joe’ / ‘Joseph Kropschot’), the surname first or last in either (‘Lee Jeong-yeong’ / ‘Jung-Young Lee’); - the same first name and surname with middle names in one only (‘Jose Mauro Delano’ / ‘Jose Delano’, ‘Nina Nikolija Milosevic’ / ‘Nina Milosevic’);
- the same first name with surnames at least
STRICT_SURNAMEalike (‘Daria Zheleznyakova’ / ‘Daria Zhelezniakova’). The loader takes a strict match only when it is ONE fighter, near the bout’s division (services.rounds_upcoming): ‘Bruno Silva’ and ‘Bruno Gustavo da Silva’, both on the roster, each match themselves exactly and a third spelling of either is refused.
variant
variant(a: Any, b: Any) -> boolOne fighter’s two given names: :func:similar, or the same surname with one first
name the start (3 letters or more) of the other (‘Chris’ / ‘Christopher Padilla’,
‘Dan’ / ‘Daniel Hooker’, ‘Montse’ / ‘Montserrat Rendon’).