Skip to content

Commit 96e6186

Browse files
committed
test: pin whole-word matching for Turkic marker regex; docs: clarify guard asymmetry
Addresses PR review feedback on #198: - Add a regex-level test confirming is_turkic_patronymic_marker() only matches whole marker words, not substrings (e.g. "ogluu", "Bogluchik"), guarding against a future accidental .match()->.search() swap. - Soften docs/customize.rst's "mirroring the strictness of the East-Slavic guard" claim, which overstated parity: the Turkic guard has no middle-token disambiguation check analogous to East-Slavic's, since marker words are a small closed set unlikely to coincide with an ordinary given name.
1 parent 83615bc commit 96e6186

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

docs/customize.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,17 @@ Natural order (``"Vusal Said oglu Aliyev"``) and comma order
140140
and are left unchanged.
141141

142142
Detection is scoped strictly to the 4-token shape (single-token first/last,
143-
exactly two middle tokens, last token a recognised marker) — mirroring the
144-
strictness of the East-Slavic guard above. Recognised markers cover common
145-
transliterations and native orthographies: Latin ``oglu``, ``oğlu``,
146-
``ogly``, ``ogli``, ``o'g'li`` (and its Uzbek modifier-apostrophe and
147-
right-single-quote variants), ``qizi``, ``qızı``, ``kizi``, ``kyzy``,
148-
``gyzy``, ``uly``, ``uulu``; and Cyrillic ``оглу``, ``оглы``, ``оғлу``,
149-
``ўғли``, ``угли``, ``кызы``, ``гызы``, ``қызы``, ``қизи``, ``улы``,
150-
``ұлы``, ``уулу``. Matching is case-insensitive.
143+
exactly two middle tokens, last token a recognised marker) — matching the
144+
East-Slavic guard's token-count strictness above. Unlike that guard, there's
145+
no additional check on the given-name token, since Turkic markers are a
146+
small, closed set unlikely to coincide with an ordinary given name (whereas
147+
East-Slavic patronymic suffixes can coincide with real Western surnames).
148+
Recognised markers cover common transliterations and native orthographies:
149+
Latin ``oglu``, ``oğlu``, ``ogly``, ``ogli``, ``o'g'li`` (and its Uzbek
150+
modifier-apostrophe and right-single-quote variants), ``qizi``, ``qızı``,
151+
``kizi``, ``kyzy``, ``gyzy``, ``uly``, ``uulu``; and Cyrillic ``оглу``,
152+
``оглы``, ``оғлу``, ``ўғли``, ``угли``, ``кызы``, ``гызы``, ``қызы``,
153+
``қизи``, ``улы``, ``ұлы``, ``уулу``. Matching is case-insensitive.
151154

152155

153156
Suppressing Middle Names

tests/test_turkic_patronymic_order.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
from tests.base import HumanNameTestBase
44

55

6+
def test_marker_is_whole_word_not_substring() -> None:
7+
# is_turkic_patronymic_marker() deliberately uses whole-word .match(),
8+
# not suffix .search() (unlike is_east_slavic_patronymic()) — pin this
9+
# so a future .match()->.search() slip doesn't silently start matching
10+
# surnames/given-names that merely contain a marker as a substring.
11+
C = Constants()
12+
assert not C.regexes.turkic_patronymic_marker.match("ogluu")
13+
assert not C.regexes.turkic_patronymic_marker.match("Bogluchik")
14+
assert not C.regexes.turkic_patronymic_marker_cyrillic.match("оглуш")
15+
assert not C.regexes.turkic_patronymic_marker_cyrillic.match("Оглуев")
16+
17+
618
class TurkicPatronymicNameOrderReorderTests(HumanNameTestBase):
719
"""Names that SHOULD be rotated when the flag is on."""
820

0 commit comments

Comments
 (0)