1from nameparser.config._invariants import assert_normalized
2
3GIVEN_NAME_TITLES = frozenset({
4 'aunt',
5 'auntie',
6 # #346: the renunciate class -- 'baba' here, and 'guru', 'lama',
7 # 'swami' in their own alphabetical places below. All four were in
8 # the TITLES-only block until 2026-09-06. Two separate criteria
9 # both say yes (rules.md#H Background): the title addresses by the
10 # GIVEN name, which is what membership here means, and the
11 # traditions renounce the surname, which is what makes the empty
12 # family the right output for "Swami Vivekananda". 'rabbi' and
13 # 'imam' address by TITLE rather than by given name ('Rabbi
14 # Cohen'), so they fail the first criterion and stay out, and the
15 # second agrees, those traditions keeping surnames;
16 # 'venerable' stays in TITLES only, because the traditions using it
17 # split on surname retention (Buddhist monastics drop the family
18 # name, Anglican archdeacons keep it) and this set has no way to
19 # say "sometimes".
20 'baba',
21 'brother',
22 'dame',
23 'father',
24 'guru',
25 'king',
26 'lama',
27 'maid',
28 'master',
29 'mother',
30 'pope',
31 # #519: prince and princess address by the GIVEN name ("Prince
32 # Harry", "Princess Anne"), which is what membership here means
33 # (rules.md#H Background); both were in the TITLES-only block
34 # until 2026-09-10. 'lord' and 'lady' stay there, decided rather
35 # than deferred: both split by the bearer's rank, which the text
36 # does not carry -- the given-name form is a courtesy style for
37 # children of the senior ranks alone ("Lord Peter", "Lady Diana"),
38 # and every peer and every wife takes the title or surname ("Lord
39 # Byron", "Lady Thatcher") -- and this set has no way to say
40 # "sometimes" (the 'venerable' reasoning above). Membership decides only which field the one word
41 # behind the title takes: "Prince Fielder" is #348's collision
42 # either way.
43 'prince',
44 'princess',
45 'queen',
46 'sir',
47 'sister',
48 'swami',
49 'uncle',
50 'sheikh',
51 'sheik',
52 'shaik',
53 'shayk',
54 'shaykh',
55 'shaikh',
56 'cheikh',
57 'shekh',
58 # #269: Arabic -- "الشيخ" ("the sheikh") is the native-script form of
59 # the transliterated sheikh/sheik/... cluster above; same
60 # single-first-name-follows convention ("Sheikh Mohammed").
61 'الشيخ',
62 # #269 follow-up: Arabic honorifics precede the GIVEN name, so all
63 # belong here rather than in plain TITLES. Article forms are never
64 # given names; the bare doctor/professor/engineer forms are not
65 # used as given names either. Deferred under the collision rule
66 # (like мл/ст in suffixes.py): bare سيد (Sayyid is a common given
67 # name), bare شيخ (Shaikha is a common female given name), أمير
68 # and سلطان (Amir/Sultan, common given names), and the 'د.'
69 # abbreviation -- edge-period normalization would leave bare 'د',
70 # which swallows single-letter initials (the bare-κ trap above).
71 'الدكتور', # "the doctor" (m)
72 'الدكتورة', # "the doctor" (f)
73 'دكتور', # doctor (m), article-less
74 'دكتورة', # doctor (f), article-less
75 'الأستاذ', # "the professor"/Mr. honorific (m)
76 'الأستاذة', # professor/Mrs. honorific (f)
77 'أستاذ', # professor (m), article-less
78 'أستاذة', # professor (f), article-less
79 'الحاج', # hajj honorific (m)
80 'الحاجة', # hajj honorific (f)
81 'الشيخة', # female counterpart of الشيخ
82 'مهندس', # engineer (a genuine title in Egyptian usage)
83
84 # #344: Devanagari renunciate titles, the native-script twins of
85 # baba/guru/swami above. NO Latin twins for संत on purpose. No NEW
86 # Latin transliterations here: Sri and Sant collide with real
87 # given names (and Pandit, in the civil block below, with a
88 # surname) where the native script cannot (the sri/shri
89 # precedent in the TITLES block below); baba/guru/swami/lama are
90 # the pre-existing Latin entries above. Being in this literal puts
91 # them in TITLES too, TITLES being GIVEN_NAME_TITLES | {...}, which
92 # is what makes them titles at all -- Lexicon does not validate one
93 # set against the other.
94 'स्वामी', # Swami
95 'गुरु', # Guru
96 'बाबा', # Baba
97 'संत', # Sant
98
99 # #343: Bengali renunciate titles. Same two criteria as the Latin
100 # and Devanagari sets (rules.md#H Background), and no NEW Latin
101 # transliterations -- srila has none; baba/guru/swami already ship
102 # above. শ্রীল is the Vaishnava honorific (শ্রীল প্রভুপাদ);
103 # unprefixed শ্রী is civil and sits in TITLES below.
104 'স্বামী', # Swami
105 'শ্রীল', # Srila
106 'গুরু', # Guru
107 'বাবা', # Baba
108})
109"""
110When these titles appear with a single other name, that name is a given name, e.g.
111"Sir John", "Sister Mary", "Queen Elizabeth".
112"""
113
114# Maintainer note, deliberately a plain comment ABOVE the `#:` run and
115# not inside it (a plain comment within a `#:` run splits it, and
116# autodoc then drops everything above the split -- see particles.py).
117# `#:` would publish this into the API reference, where it is advice to
118# nobody. Frozen by
119# construction (#293) -- `frozenset | set` returns a frozenset, the LEFT
120# operand's type wins, so keep the frozenset first. Flipped, this
121# silently yields a plain set again and unfreezes the constant.
122#: **Cannot include things that could also be given names**, e.g. "dean".
123#: Many of these from wikipedia: https://en.wikipedia.org/wiki/Title.
124#: The parser recognizes chains of these including conjunctions allowing
125#: recognition titles like "Deputy Secretary of State".
126TITLES = GIVEN_NAME_TITLES | {
127 "attaché",
128 "chargé",
129 "d'affaires",
130 "king's",
131 "marchioness",
132 "marquess",
133 "marquis",
134 "marquise",
135 "queen's",
136 '10th',
137 '1lt',
138 '1sgt',
139 '1st',
140 '1stlt',
141 '1stsgt',
142 '2lt',
143 '2nd',
144 '2ndlt',
145 '3rd',
146 '4th',
147 '5th',
148 '6th',
149 '7th',
150 '8th',
151 '9th',
152 'a1c',
153 'ab',
154 'abbess',
155 'abbot',
156 'abolitionist',
157 'academic',
158 'acolyte',
159 'activist',
160 'actor',
161 'actress',
162 'adept',
163 'adjutant',
164 'adm',
165 'admiral',
166 'advertising',
167 'adviser',
168 'advocate',
169 'air',
170 'akhoond',
171 'alderman',
172 'almoner',
173 'ambassador',
174 'amn',
175 'analytics',
176 'anarchist',
177 'animator',
178 'anthropologist',
179 'appellate',
180 'apprentice',
181 'arbitrator',
182 'archbishop',
183 'archdeacon',
184 'archdruid',
185 'archduchess',
186 'archduke',
187 'archeologist',
188 'architect',
189 'arhat',
190 'army',
191 'arranger',
192 'assistant',
193 'assoc',
194 'associate',
195 'asst',
196 'astronomer',
197 'attache',
198 'attorney',
199 'author',
200 'award-winning',
201 'ayatollah',
202 'bailiff',
203 'ballet',
204 'bandleader',
205 'banker',
206 'banner',
207 'bard',
208 'baron',
209 'baroness',
210 'barrister',
211 'baseball',
212 'bearer',
213 'behavioral',
214 'bench',
215 'bg',
216 'bgen',
217 'biblical',
218 'bibliographer',
219 'biochemist',
220 'biographer',
221 'biologist',
222 'bishop',
223 'blessed',
224 'blogger',
225 'blues',
226 'bodhisattva',
227 'bookseller',
228 'botanist',
229 'bp',
230 'brigadier',
231 'briggen',
232 'british',
233 'broadcaster',
234 'buddha',
235 'burgess',
236 'burlesque',
237 'business',
238 'businessman',
239 'businesswoman',
240 'bwana',
241 'canon',
242 'capt',
243 'captain',
244 'cardinal',
245 'cartographer',
246 'cartoonist',
247 'catholicos',
248 'ccmsgt',
249 'cdr',
250 'celebrity',
251 'ceo',
252 'cfo',
253 'chair',
254 'chairs',
255 'chancellor',
256 'chaplain',
257 'charge', # unaccented 'chargé', like attaché/'attache'
258 'chef',
259 'chemist',
260 'chief',
261 'chieftain',
262 'choreographer',
263 'civil',
264 'classical',
265 'clergyman',
266 'clerk',
267 'cmsaf',
268 'cmsgt',
269 'co-chair',
270 'co-chairs',
271 'co-founder',
272 'coach',
273 'col',
274 'collector',
275 'colonel',
276 'comedian',
277 'comedienne',
278 'comic',
279 'commander',
280 'commander-in-chief',
281 'commodore',
282 'composer',
283 'compositeur',
284 'comptroller',
285 'computer',
286 'comtesse',
287 'conductor',
288 'consultant',
289 'controller',
290 'corporal',
291 'corporate',
292 'correspondent',
293 'councillor',
294 'counselor',
295 'count',
296 'countess',
297 'courtier',
298 'cpl',
299 'cpo',
300 'cpt',
301 'credit',
302 'criminal',
303 'criminologist',
304 'critic',
305 'csm',
306 'curator',
307 'customs',
308 'cwo-2',
309 'cwo-3',
310 'cwo-4',
311 'cwo-5',
312 'cwo2',
313 'cwo3',
314 'cwo4',
315 'cwo5',
316 'cyclist',
317 'dancer',
318 'dcn',
319 'deacon',
320 'delegate',
321 'deputy',
322 'designated',
323 'designer',
324 'detective',
325 'developer',
326 'dhr',
327 'dipl.-ing',
328 'diplomat',
329 'dir',
330 'director',
331 'discovery',
332 'dissident',
333 'district',
334 'division',
335 'docent',
336 'docket',
337 'doctor',
338 'doyen',
339 'dpty',
340 'dr',
341 'dra',
342 'dramatist',
343 'druid',
344 'drummer',
345 'duchesse',
346 # 'duke', # a common first name
347 'dutchess',
348 'ecologist',
349 'economist',
350 'editor',
351 'edler',
352 'edmi',
353 'edohen',
354 'educator',
355 'effendi',
356 'ekegbian',
357 'elerunwon',
358 'eminence',
359 'emperor',
360 'empress',
361 'engineer',
362 'english',
363 'ens',
364 'entertainer',
365 'entrepreneur',
366 'envoy',
367 'erzbischof',
368 'essayist',
369 'evangelist',
370 'excellency',
371 'excellent',
372 'exec',
373 'executive',
374 'expert',
375 'fadm',
376 'family',
377 'federal',
378 'fh-prof',
379 'field',
380 'film',
381 'financial',
382 'first',
383 'flag',
384 'flying',
385 'foreign',
386 'forester',
387 'founder',
388 'fr',
389 'frau',
390 'fräulein',
391 'freifrau',
392 'freiherr',
393 'friar',
394 'frk',
395 'frøken',
396 'fru',
397 'fürst',
398 'fürsterzbischof',
399 'gaf',
400 'gen',
401 'general',
402 'generalissimo',
403 'gentiluomo',
404 'giani',
405 'goodman',
406 'goodwife',
407 'governor',
408 'graf',
409 'gräfin',
410 'grand',
411 'großfürst',
412 'group',
413 'guitarist',
414 'gyani',
415 'gysgt',
416 'hajji',
417 'headman',
418 'heir',
419 'heiress',
420 'her',
421 'hereditary',
422 'heren',
423 'herr',
424 'herzog',
425 'herren',
426 'herrn',
427 'high',
428 'highness',
429 'his',
430 'historian',
431 'historicus',
432 'historien',
433 'holiness',
434 'hon', # sorry Hon Solo, but judges seem more common.
435 'honorable',
436 'honourable',
437 'host',
438 'hr',
439 'illustrator',
440 'imam',
441 'industrialist',
442 'information',
443 'instructor',
444 'intelligence',
445 'intendant',
446 'inventor',
447 'investigator',
448 'investor',
449 'journalist',
450 'journeyman',
451 'judge',
452 'judicial',
453 'jurist',
454 'keyboardist',
455 'kingdom',
456 'knowledge',
457 'lady',
458 'lamido',
459 'law',
460 'lawyer',
461 'lcdr',
462 'lcpl',
463 'leader',
464 'lecturer',
465 'legal',
466 'librarian',
467 'lieutenant',
468 'linguist',
469 'literary',
470 'lord',
471 'lt',
472 'ltc',
473 'ltcol',
474 'ltg',
475 'ltgen',
476 'ltjg',
477 'lyricist',
478 'madam',
479 'madame',
480 'mademoiselle',
481 'mag',
482 'mag-judge',
483 'mag/judge',
484 'magistrate',
485 'magistrate-judge',
486 'magnate',
487 'maharajah',
488 'maharani',
489 'mahdi',
490 'maj',
491 'majesty',
492 'majgen',
493 'manager',
494 'marcher',
495 'marchess',
496 'marketing',
497 'marquis',
498 'mathematician',
499 'mathematics',
500 'matriarch',
501 'mayor',
502 'mcpo',
503 'mcpoc',
504 'mcpon',
505 'md',
506 'me',
507 'member',
508 'memoirist',
509 'merchant',
510 'met',
511 'metropolitan',
512 'mevr',
513 'mevrouw',
514 'mevrouwe',
515 'mg',
516 'mgr',
517 'mgysgt',
518 'military',
519 'minister',
520 'miss',
521 'misses',
522 'missionary',
523 'mister',
524 'mlle',
525 'mme',
526 'mobster',
527 'model',
528 'monk',
529 'monseigneur',
530 'monsieur',
531 'monsignor',
532 'most',
533 'mountaineer',
534 'mpco-cg',
535 'mr',
536 'mrs',
537 'ms',
538 'msg',
539 'msgt',
540 'mufti',
541 'mullah',
542 'municipal',
543 'murshid',
544 'musician',
545 'musicologist',
546 'mx',
547 'mystery',
548 'nanny',
549 'narrator',
550 'national',
551 'naturalist',
552 'navy',
553 'neuroscientist',
554 'novelist',
555 'nurse',
556 'obstetritian',
557 'officer',
558 'opera',
559 'operating',
560 'ornithologist',
561 'painter',
562 'paleontologist',
563 'pastor',
564 'patriarch',
565 'pd',
566 'pediatrician',
567 'personality',
568 'petty',
569 'pfc',
570 'pharaoh',
571 'philantropist',
572 'philosopher',
573 'photographer',
574 'physician',
575 'physicist',
576 'pianist',
577 'pilot',
578 'pioneer',
579 'pir',
580 'player',
581 'playwright',
582 'po1',
583 'po2',
584 'po3',
585 'poet',
586 'police',
587 'political',
588 'politician',
589 'prefect',
590 'prelate',
591 'premier',
592 'pres',
593 'presbyter',
594 'president',
595 'presiding',
596 'priest',
597 'priestess',
598 'primate',
599 'prime',
600 'prin',
601 'principal',
602 'printer',
603 'printmaker',
604 'prinz',
605 'priv.-doz',
606 'prior',
607 'private',
608 'pro',
609 'producer',
610 'prof',
611 'professor',
612 'provost',
613 'pslc',
614 'psychiatrist',
615 'psychologist',
616 'publisher',
617 'pursuivant',
618 'pv2',
619 'pvt',
620 'ra',
621 'rabbi',
622 'radio',
623 'radm',
624 'rangatira',
625 'ranger',
626 'rdml',
627 'rear',
628 'rebbe',
629 'reichsgraf',
630 'registrar',
631 'rep',
632 'representative',
633 'researcher',
634 'resident',
635 'rev',
636 'revenue',
637 'reverend',
638 'right',
639 'risk',
640 'ritter',
641 'rock',
642 'royal',
643 'rt',
644 'sa',
645 'sailor',
646 'saint',
647 'sainte',
648 'saoshyant',
649 'satirist',
650 'scholar',
651 'schoolmaster',
652 'scientist',
653 'scpo',
654 'screenwriter',
655 'secretary',
656 'security',
657 'seigneur',
658 'senator',
659 'senhor',
660 'senhora',
661 'senhorita',
662 'senior',
663 'señor',
664 'señora',
665 'señores',
666 'señorita',
667 'señoritas',
668 'senior-judge',
669 'sergeant',
670 'servant',
671 'sfc',
672 'sgm',
673 'sgt',
674 'sgtmaj',
675 'sgtmajmc',
676 'shehu',
677 'sheikh',
678 'sheriff',
679 'siddha',
680 'signor',
681 'signora',
682 'signore',
683 'signorina',
684 'singer',
685 'singer-songwriter',
686 'sma',
687 'smsgt',
688 'sn',
689 'soccer',
690 'social',
691 'sociologist',
692 'software',
693 'soldier',
694 'solicitor',
695 'soprano',
696 'spc',
697 'speaker',
698 'special',
699 'sr',
700 'sra',
701 'srta',
702 'srtas',
703 'sres',
704 'ssg',
705 'ssgt',
706 'st',
707 'staff',
708 'state',
709 'states',
710 'strategy',
711 'subaltern',
712 'subedar',
713 'suffragist',
714 'sultan',
715 'sultana',
716 'superior',
717 'supreme',
718 'surgeon',
719 'swordbearer',
720 'sysselmann',
721 'tax',
722 'teacher',
723 'technical',
724 'technologist',
725 'television',
726 'tenor',
727 'theater',
728 'theatre',
729 'theologian',
730 'theorist',
731 'timi',
732 'tirthankar',
733 'translator',
734 'travel',
735 'treasurer',
736 'tsar',
737 'tsarina',
738 'tsgt',
739 'uk',
740 'united',
741 'univ.prof',
742 'us',
743 'vadm',
744 'vardapet',
745 'vc',
746 'venerable',
747 'verderer',
748 'vicar',
749 'vice',
750 'viscount',
751 'vizier',
752 'vocalist',
753 'voice',
754 'vrouwe',
755 'warden',
756 'warrant',
757 'wing',
758 'wm',
759 'wp',
760 'wo-1',
761 'wo1',
762 'wo2',
763 'wo3',
764 'wo4',
765 'wo5',
766 'woodman',
767 'writer',
768 'zoologist',
769
770 # #269: Cyrillic (ru/uk) -- mr/mrs/dr/prof/academician/pan(i)
771 # honorifics, same title-then-family convention as 'mr'/'dr'/'prof'
772 # above (not GIVEN_NAME_TITLES: "г-н Петров" families the surname
773 # just like "Mr. Smith" does).
774 'г-н',
775 'г-жа',
776 'д-р',
777 'проф',
778 'акад',
779 'пан',
780 'пані',
781
782 # #269: Greek -- kyria/kyrios(abbr)/doctor/professor abbreviations;
783 # same plain-title convention as above.
784 # #269: bare κ deferred -- collides with the initial+surname shape
785 # ('Κ. Παπαδόπουλος' would parse as title 'Κ.' with an empty given;
786 # _normalize strips the edge period, so the entry matches the
787 # initial). Latin TITLES deliberately has no bare single-letter
788 # entries for the same reason.
789 'κα',
790 'κος',
791 'δρ',
792 'καθ',
793
794 # #269: Hebrew -- "מר" ("Mr."), plain title like its Latin analog.
795 # Geresh/gershayim forms of "doctor"/"Mrs." -- both the ASCII-quote
796 # spelling ('ד"ר', "גב'") and the typographic Unicode spelling
797 # ('ד״ר' U+05F4 gershayim, 'גב׳' U+05F3 geresh) ship: probed live
798 # against extract_delimited's _open_ok/_close_ok boundary rules
799 # (2026-07-17) -- the quote chars sit mid-word (no preceding
800 # whitespace before the internal quote and, for the closing "'" one,
801 # no following boundary), so both fail the open/close boundary test
802 # and are left untouched as literal text. Extraction is provably
803 # inert on these two ASCII spellings; no delimiter-interaction risk.
804 'מר',
805 'ד"ר',
806 "גב'",
807 'ד״ר',
808 'גב׳',
809 # #269 follow-up: the rest of the common Israeli honorifics, same
810 # plain-title bucket (family follows) and the same dual geresh/
811 # gershayim spelling rule as above. Deferred under the collision
812 # rule: bare 'רב' (also the ordinary word "many"). The 'בר'
813 # particle deferral is recorded in prefixes.py with the other
814 # particle decisions.
815 'גברת', # Mrs./Ms., full form
816 "פרופ'", # professor abbreviation, ASCII apostrophe
817 'פרופ׳', # professor abbreviation, U+05F3 geresh
818 'פרופסור', # professor, full form
819 'עו"ד', # advocate/lawyer, ASCII quote
820 'עו״ד', # advocate/lawyer, U+05F4 gershayim
821 'הרב', # "the rabbi" (article form; bare רב deferred)
822
823 # #269 follow-up: Devanagari (hi/mr). NO Latin twins on purpose:
824 # transliterated sri/shri collide with real given names (Sri
825 # Mulyani); the native-script forms cannot. "डॉ." matches via the
826 # edge-period normalization, like Latin "Dr.".
827 'श्री', # Shri (Mr.)
828 'श्रीमती', # Shrimati (Mrs.)
829 'डॉ', # Dr. abbreviation
830 # #344: the civil set, same no-NEW-Latin-transliterations rule as
831 # the three above.
832 # Excluded under the collision rule and recorded here so a sweep
833 # does not ship them -- ठाकुर (Tagore, the surname), कुमारी, बेगम,
834 # शेख, आचार्य, राजा/रानी are all borne as ordinary names. Full
835 # argument: decisions.md Excluded (TITLES).
836 'डॉक्टर', # Doctor, full form
837 'डा', # Dr. -- the डा. abbreviation (Nepali and older Hindi),
838 # edge-period normalized
839 'प्रो', # Prof. abbreviation
840 'प्रोफेसर', # Professor, full form
841 'प्राध्यापक', # Professor (the Sanskritic form)
842 'प्रा', # Prof. abbreviation, Marathi
843 'पंडित', # Pandit
844 'पं', # Pandit abbreviation
845 'सरदार', # Sardar
846 'सुश्री', # Ms.
847 'श्रीयुत', # Shriyut (Mr.)
848 'श्रीमान', # Shriman (Mr.)
849 'सौ', # Marathi Sau. (Mrs.)
850 'बाबू', # Babu -- LEADING in Hindi; Bengali বাবু is trailing
851 # and lives in suffixes.py. Different codepoints.
852 'महात्मा', # Mahatma -- civil, not renunciate: it addresses by
853 # surname ("महात्मा गांधी"), so TITLES only
854 'न्यायमूर्ति', # Justice
855 'मौलाना', # Maulana
856 'जनाब', # Janab (Mr.)
857 'महाराजा', # Maharaja, LEADING (trailing महाराज is a suffix word)
858
859 # #343: Bengali (bn). NO Latin twins, for the reason the
860 # Devanagari block above gives -- transliterated Sri/Md/Mst
861 # collide with real given names where the native script cannot.
862 # No NEW Latin transliterations here (sri, mst); Latin md already
863 # ships, and for the medical degree
864 # (decisions.md#indic-honorifics). Doctor abbreviations
865 # split by profession: ড./ডঃ is the PhD's, ডাঃ/ডা. the Bangladeshi
866 # physician's. Abbreviation marks are spelled as written -- the
867 # visarga ঃ (U+0983) is a spacing combining mark, and the lookup
868 # fold strips only edge periods and whitespace, so it reaches the
869 # lexicon intact -- while period spellings (মো., ডা.) match the
870 # bare stem through the edge-period normalization, which is why
871 # each stem is listed once and the dotted form is not listed at
872 # all.
873 # Excluded under the collision rule and recorded here so a sweep
874 # does not ship them -- ঠাকুর (Tagore, the surname), কুমারী, বেগম
875 # and শেখ are all borne as ordinary names. Full argument:
876 # decisions.md Excluded (TITLES).
877 'ড', # Dr. abbreviation (PhD)
878 'ডঃ', # Dr. abbreviation, visarga spelling
879 'ডক্টর', # Doctor, full form
880 'ডাঃ', # Dr. abbreviation (physician), visarga spelling
881 'ডা', # Dr. abbreviation (physician)
882 'ডাক্তার', # Doctor, full form (physician)
883 'শ্রী', # Shri (Mr.)
884 'শ্রীমতী', # Shrimati (Mrs.)
885 'জনাব', # Janab (Mr.)
886 'অধ্যাপক', # Professor
887 'প্রফেসর', # Professor, borrowed form
888 'বিচারপতি', # Justice
889 'মাওলানা', # Maulana
890 'মুফতি', # Mufti (Latin mufti ships too)
891 'আলহাজ্ব', # Alhaj
892 'আলহাজ', # Alhaj, the spelling without the ব-phala
893 'মিঃ', # Mr., borrowed
894 'মি', # the same, period spelling মি.
895 'মিসেস', # Mrs., borrowed
896 'মোঃ', # Md. (Mohammad) -- a name PREFIX, not a title
897 # semantically; TITLES is the functional home
898 # because `given` must stay the name the person is
899 # addressed by (decisions.md#indic-honorifics)
900 'মো', # the same, period spelling মো.
901 'মোসাঃ', # Mst. (Mosammat), the women's counterpart
902 'মোসা', # the same, period spelling মোসা.
903 'মোছাঃ', # the same, ছ spelling
904 'মোছা', # the same, period spelling মোছা.
905}
906
907
908# Guard the invariants at import time, so a bad edit fails here instead of
909# drifting silently until a test happens to catch it (see particles.py).
910# The subset rule holds by construction today -- TITLES is defined as
911# GIVEN_NAME_TITLES | {...} -- so this pins it against a future edit that
912# makes TITLES a standalone set. Note `assert` is stripped under
913# `python -O`, and unlike suffixes.py's relations this one has no
914# runtime backstop: Lexicon deliberately does NOT validate
915# given_name_titles against titles (its "NOT validated" comment gives
916# the reasoning), so a caller's
917# Lexicon(titles=frozenset({"sir"}), given_name_titles=frozenset({"dame"}))
918# is accepted. Under -O nothing checks this relation at all.
919assert GIVEN_NAME_TITLES <= TITLES, \
920 "GIVEN_NAME_TITLES must stay a subset of TITLES"
921# TITLES covers GIVEN_NAME_TITLES, by the subset assert above.
922assert_normalized("TITLES", TITLES)
923
924
925# 1.x name, deprecated in 2.2 and removed in 3.0 (#293). Unlike the
926# module moves in #293, the constant did not change module, so this
927# aliases a name to one of this module's own globals: a module
928# __getattr__ runs only once the body has finished and the module is in
929# sys.modules, so the lookup resolves rather than recursing.
930from typing import TYPE_CHECKING # noqa: E402
931
932from nameparser.config._deprecated import alias_getattr # noqa: E402
933
934# Declared for the type checker, served by __getattr__ at runtime. The
935# split is what keeps mypy checking this module's LIVE names: an
936# assigned module __getattr__ answers every missing attribute, so a
937# plain assignment here made `from ... import TITLE` type-check clean.
938# See alias_getattr's docstring. Both branches go in 3.0.
939if TYPE_CHECKING:
940 FIRST_NAME_TITLES: frozenset[str]
941else:
942 __getattr__, __dir__ = alias_getattr(__name__, {
943 "FIRST_NAME_TITLES": (
944 "nameparser.config.titles", "GIVEN_NAME_TITLES"),
945 })
946
947# Star imports read __all__ and never the module __getattr__ -- see the
948# note in prefixes.py. This module keeps its live constants, so they are
949# listed too: without __all__ a star import bound them and dropped the
950# retired name silently; with a PARTIAL __all__ it would bind the
951# retired name and drop the live ones instead.
952# Source order, not alphabetical -- see the note in suffixes.py.
953__all__ = ["GIVEN_NAME_TITLES", "TITLES", "FIRST_NAME_TITLES"]