sinonym 0.6.3__tar.gz → 0.7.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 (181) hide show
  1. {sinonym-0.6.3 → sinonym-0.7.2}/PKG-INFO +1 -1
  2. {sinonym-0.6.3 → sinonym-0.7.2}/docs/unicode_hyphen_policy_review.md +1 -1
  3. {sinonym-0.6.3 → sinonym-0.7.2}/pyproject.toml +7 -1
  4. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/coretypes/config.py +2 -2
  5. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/COMPOUND_SURNAMES.md +48 -20
  6. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/EAST_ASIAN_NAME_LEXICONS.md +2 -0
  7. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/README.md +25 -8
  8. sinonym-0.7.2/sinonym/data/allcaps_given_words.csv.gz +0 -0
  9. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/compound_surnames.csv.gz +0 -0
  10. sinonym-0.7.2/sinonym/data/given_name_words.csv.gz +0 -0
  11. sinonym-0.7.2/sinonym/data/glued_initial_prefixes.csv.gz +0 -0
  12. sinonym-0.7.2/sinonym/data/korean_given_words.csv.gz +0 -0
  13. sinonym-0.7.2/sinonym/data/surname_first_words.csv.gz +0 -0
  14. sinonym-0.7.2/sinonym/data/token_role_prior.csv.gz +0 -0
  15. sinonym-0.7.2/sinonym/data/two_token_order_prior.csv.gz +0 -0
  16. sinonym-0.7.2/sinonym/data/unsplit_given_words.csv.gz +0 -0
  17. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/detector.py +8 -1
  18. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/name_punctuation.py +1 -1
  19. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/batch_analysis.py +11 -5
  20. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/compound_surnames.py +13 -0
  21. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/east_asian_name_order.py +5 -2
  22. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/ethnicity.py +8 -1
  23. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/normalization.py +10 -2
  24. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/person_name_normalization.py +57 -9
  25. sinonym-0.7.2/sinonym/services/source_repairs.py +1112 -0
  26. sinonym-0.7.2/sinonym/services/suffix_display.py +120 -0
  27. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/timo/_resolution.py +272 -22
  28. sinonym-0.7.2/sinonym/timo/interface.py +423 -0
  29. sinonym-0.7.2/sinonym/utils/allcaps_given_words.py +35 -0
  30. sinonym-0.7.2/sinonym/utils/given_name_words.py +53 -0
  31. sinonym-0.7.2/sinonym/utils/korean_given_names.py +106 -0
  32. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/utils/string_manipulation.py +79 -8
  33. sinonym-0.7.2/sinonym/utils/unsplit_given_words.py +145 -0
  34. {sinonym-0.6.3 → sinonym-0.7.2}/tests/data/hangul_name_order_gold.json +1 -1
  35. {sinonym-0.6.3 → sinonym-0.7.2}/tests/data/manufactured_initials_cohorts.json +2 -2
  36. sinonym-0.7.2/tests/data/name_regression_cases.csv +706 -0
  37. sinonym-0.7.2/tests/data/source_repair_cases.csv +146 -0
  38. {sinonym-0.6.3 → sinonym-0.7.2}/tests/data/timo_parity/manifest.json +2 -2
  39. {sinonym-0.6.3 → sinonym-0.7.2}/tests/data/timo_parity/requests.jsonl +2 -2
  40. {sinonym-0.6.3 → sinonym-0.7.2}/tests/data/vietnamese_name_order_gold.json +2 -2
  41. sinonym-0.7.2/tests/test_070_name_fixes.py +400 -0
  42. sinonym-0.7.2/tests/test_072_name_fixes.py +329 -0
  43. sinonym-0.7.2/tests/test_allcaps_given_words.py +75 -0
  44. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_compound_names.py +1 -1
  45. sinonym-0.7.2/tests/test_compound_surname_stability.py +140 -0
  46. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_east_asian_name_order.py +2 -1
  47. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_fixability_proposal_fixes.py +20 -15
  48. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_initial_policy_routing.py +1 -1
  49. sinonym-0.7.2/tests/test_korean_given_names.py +126 -0
  50. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_manufactured_initials.py +1 -1
  51. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_mixed_scripts.py +5 -5
  52. sinonym-0.7.2/tests/test_name_regression_cases.py +215 -0
  53. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_non_chinese_exact_source_fixes.py +6 -7
  54. sinonym-0.7.2/tests/test_order_prior_stability.py +129 -0
  55. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_person_name_normalization.py +4 -6
  56. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_regression_proposals.py +2 -2
  57. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_s2and_review_regressions.py +219 -6
  58. sinonym-0.7.2/tests/test_source_repairs.py +274 -0
  59. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_timo_interface.py +2 -2
  60. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_timo_parity_fixture.py +1 -1
  61. sinonym-0.6.3/sinonym/data/surname_first_words.csv.gz +0 -0
  62. sinonym-0.6.3/sinonym/data/token_role_prior.csv.gz +0 -0
  63. sinonym-0.6.3/sinonym/data/two_token_order_prior.csv.gz +0 -0
  64. sinonym-0.6.3/sinonym/timo/interface.py +0 -213
  65. {sinonym-0.6.3 → sinonym-0.7.2}/.gitignore +0 -0
  66. {sinonym-0.6.3 → sinonym-0.7.2}/LICENSE +0 -0
  67. {sinonym-0.6.3 → sinonym-0.7.2}/README.md +0 -0
  68. {sinonym-0.6.3 → sinonym-0.7.2}/docs/batch_processing.md +0 -0
  69. {sinonym-0.6.3 → sinonym-0.7.2}/docs/canonical_name_evaluation.md +0 -0
  70. {sinonym-0.6.3 → sinonym-0.7.2}/docs/scalar_source_surname_repartition_evaluation.md +0 -0
  71. {sinonym-0.6.3 → sinonym-0.7.2}/docs/timo.md +0 -0
  72. {sinonym-0.6.3 → sinonym-0.7.2}/scripts/README.md +0 -0
  73. {sinonym-0.6.3 → sinonym-0.7.2}/scripts/build_east_asian_name_lexicons.py +0 -0
  74. {sinonym-0.6.3 → sinonym-0.7.2}/scripts/check_test_status.py +0 -0
  75. {sinonym-0.6.3 → sinonym-0.7.2}/scripts/data/reviewed_japanese_possible_surnames.csv +0 -0
  76. {sinonym-0.6.3 → sinonym-0.7.2}/scripts/generate_name_statistics.py +0 -0
  77. {sinonym-0.6.3 → sinonym-0.7.2}/scripts/generate_surname_romanizations.py +0 -0
  78. {sinonym-0.6.3 → sinonym-0.7.2}/scripts/name_order_routing_rules.py +0 -0
  79. {sinonym-0.6.3 → sinonym-0.7.2}/scripts/train_ml_classifier_for_chinese_vs_japanese.py +0 -0
  80. {sinonym-0.6.3 → sinonym-0.7.2}/scripts/verify_multiprocess.py +0 -0
  81. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/__init__.py +0 -0
  82. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/chinese_names_data.py +0 -0
  83. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/coretypes/__init__.py +0 -0
  84. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/coretypes/results.py +0 -0
  85. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/coretypes/routing_resolution.py +0 -0
  86. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/acl_2025_authors.txt +0 -0
  87. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/chinese_japanese_classifier.skops +0 -0
  88. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/east_asian_roman_lexicons.json.gz +0 -0
  89. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/familyname_orcid.csv +0 -0
  90. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/given_position.csv +0 -0
  91. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/givenname_orcid.csv +0 -0
  92. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/japanese_native_lexicons.json.gz +0 -0
  93. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/model_features.json +0 -0
  94. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/name_order_routing/README.md +0 -0
  95. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/name_order_routing/pp_abstain_labels.jsonl +0 -0
  96. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/name_order_routing/pp_vys_abstain_labels.jsonl +0 -0
  97. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/data/surname_romanizations.csv +0 -0
  98. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/ml_fast_scorer.py +0 -0
  99. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/ml_flag_data.py +0 -0
  100. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/ml_model_components.py +0 -0
  101. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/patterns/__init__.py +0 -0
  102. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/patterns/compiled_patterns.py +0 -0
  103. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/patterns/regex_builders.py +0 -0
  104. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/pipeline/__init__.py +0 -0
  105. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/pipeline/name_order_routing.py +0 -0
  106. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/resources.py +0 -0
  107. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/__init__.py +0 -0
  108. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/cache.py +0 -0
  109. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/formatting.py +0 -0
  110. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/initialization.py +0 -0
  111. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/name_lookup.py +0 -0
  112. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/non_person.py +0 -0
  113. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/order_metadata.py +0 -0
  114. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/order_prior.py +0 -0
  115. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/parsing.py +0 -0
  116. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/process_pool.py +0 -0
  117. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/slavic_initials.py +0 -0
  118. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/surname_first_words.py +0 -0
  119. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/services/token_order_prior.py +0 -0
  120. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/text_processing/__init__.py +0 -0
  121. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/text_processing/compound_detector.py +0 -0
  122. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/text_processing/text_normalizer.py +0 -0
  123. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/text_processing/text_preprocessor.py +0 -0
  124. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/timo/__init__.py +0 -0
  125. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/timo/config.yaml +0 -0
  126. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/timo/integration_test.py +0 -0
  127. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/utils/__init__.py +0 -0
  128. {sinonym-0.6.3 → sinonym-0.7.2}/sinonym/utils/thread_cache.py +0 -0
  129. {sinonym-0.6.3 → sinonym-0.7.2}/tests/_case_assertions.py +0 -0
  130. {sinonym-0.6.3 → sinonym-0.7.2}/tests/_korean_atomic_cases.py +0 -0
  131. {sinonym-0.6.3 → sinonym-0.7.2}/tests/conftest.py +0 -0
  132. {sinonym-0.6.3 → sinonym-0.7.2}/tests/data/reviewed_korean_source_assignments.tsv +0 -0
  133. {sinonym-0.6.3 → sinonym-0.7.2}/tests/data/reviewed_source_pattern_assignments.jsonl +0 -0
  134. {sinonym-0.6.3 → sinonym-0.7.2}/tests/data/spaced_cjk_name_order_gold.json +0 -0
  135. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_acl.py +0 -0
  136. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_all_chinese_inputs.py +0 -0
  137. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_basic_chinese_names.py +0 -0
  138. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_batch.py +0 -0
  139. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_batch_crash_guard.py +0 -0
  140. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_batch_scalar_parity.py +0 -0
  141. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_bug_report_fixes.py +0 -0
  142. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_canonical_name_integration.py +0 -0
  143. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_canonical_results.py +0 -0
  144. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_check_test_status.py +0 -0
  145. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_chinese_classification_evidence_gates.py +0 -0
  146. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_chinese_compound_surname_provenance.py +0 -0
  147. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_cjk_component_leaks.py +0 -0
  148. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_compound_surname_formats.py +0 -0
  149. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_config_immutability.py +0 -0
  150. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_detector_initialization_and_validation.py +0 -0
  151. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_east_asian_lexicon_builder.py +0 -0
  152. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_han_surname_readings.py +0 -0
  153. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_hangul_name_order_gold.py +0 -0
  154. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_initial_policy_chinese.py +0 -0
  155. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_initial_policy_non_chinese.py +0 -0
  156. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_middle_names.py +0 -0
  157. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_misc.py +0 -0
  158. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_mixed_production_cases.py +0 -0
  159. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_ml_fast_scorer.py +0 -0
  160. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_ml_japanese_detection.py +0 -0
  161. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_multiprocess_pool.py +0 -0
  162. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_name_formatting.py +0 -0
  163. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_name_order_routing_label_fixtures.py +0 -0
  164. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_name_order_routing_rules.py +0 -0
  165. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_name_statistics_data.py +0 -0
  166. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_non_chinese_rejection.py +0 -0
  167. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_package_metadata.py +0 -0
  168. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_performance.py +0 -0
  169. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_pr29_pr30_paper_context_repairs.py +0 -0
  170. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_reference_scripts.py +0 -0
  171. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_regional_variants.py +0 -0
  172. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_review_finding_regressions.py +0 -0
  173. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_reviewed_non_person_patterns.py +0 -0
  174. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_reviewed_structured_source_repairs.py +0 -0
  175. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_scalar_clean_source_surname_repartition.py +0 -0
  176. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_spaced_cjk_name_order_gold.py +0 -0
  177. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_strict_spaced_japanese_routing.py +0 -0
  178. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_surname_romanizations.py +0 -0
  179. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_timo_contract.py +0 -0
  180. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_timo_performance.py +0 -0
  181. {sinonym-0.6.3 → sinonym-0.7.2}/tests/test_vietnamese_name_order_gold.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: sinonym
3
- Version: 0.6.3
3
+ Version: 0.7.2
4
4
  Summary: Chinese Name Detection and Normalization Module
5
5
  Project-URL: Homepage, https://github.com/allenai/sinonym
6
6
  Project-URL: Repository, https://github.com/allenai/sinonym
@@ -46,7 +46,7 @@ The full scan used the current review corpus, not a sample:
46
46
  - 106,873,287 distinct `nm` rows and 690,997,259 weighted mentions
47
47
  - Parquet size 1,881,981,435 bytes, 533 row groups
48
48
  - SHA-256 `36d6e49e31dfc09b3e98144a6d1bc44c4884abe003a0672bb00ec4c9be991ad1`
49
- - source object: `s3://s2-atalyaa/disambiguation/author-names/sinonym-0-4-x-review/corpus/distinct_author_names.parquet`
49
+ - source object: an internal export of the distinct corpus author names (not published)
50
50
  - matching 106,873,287-row Chinese-label map SHA-256 `4992da8513e23855f51662583e015237edea0071bc907222fdfc38462bd09dd4`
51
51
  - 9,520,175 rows in that aligned map have `chinese=true`
52
52
  - scan revision `b39bdbe35e18104bb77bff21014e1921342e18d2`; DuckDB 1.5.5; elapsed 269.712 seconds
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "sinonym"
7
- version = "0.6.3"
7
+ version = "0.7.2"
8
8
  description = "Chinese Name Detection and Normalization Module"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -96,6 +96,12 @@ ignore = ["S101", "T201"] # Allow assert statements and print statements
96
96
  "sinonym/services/ethnicity.py" = ["C901", "PLR0911", "PLR0912", "PLR0915", "PLR2004", "ARG002", "SLF001"]
97
97
  "scripts/generate_acl_data.py" = ["B007", "BLE001", "C901", "F841", "PLC0415", "PLR0912", "PLR0915", "PLR2004", "PLW2901", "PTH123", "SIM102", "SIM108", "SLF001"]
98
98
  "scripts/generate_chinese_name_corpus_data.py" = ["ARG001", "BLE001", "C901", "ERA001", "N806", "PLC0415", "PLR0912", "PLR2004", "PTH123", "SLF001", "TRY300"]
99
+ "scripts/build_unsplit_given_words.py" = ["S608"]
100
+ "scripts/build_allcaps_given_words.py" = ["S608"]
101
+ "scripts/build_given_name_words.py" = ["S608"]
102
+ "sinonym/services/source_repairs.py" = ["RUF001", "RUF002", "RUF003"]
103
+ "tests/test_070_name_fixes.py" = ["RUF001", "PLC0415"]
104
+ "scripts/build_korean_given_words.py" = ["S608"]
99
105
  "scripts/change_class_tally.py" = ["INP001", "PLR2004", "S608"]
100
106
  "scripts/check_test_status.py" = ["E501", "RUF001"]
101
107
  "scripts/profile_multiprocess.py" = ["EM101", "PLR0913", "TRY003"]
@@ -132,8 +132,8 @@ class ChineseNameConfig:
132
132
  han_roman_splitter=HAN_ROMAN_SPLITTER,
133
133
  ascii_alpha_pattern=re.compile(r"[A-Za-z]"),
134
134
  clean_roman_pattern=re.compile(
135
- r"[^A-Za-z\u00C0-\u00FF\u0100-\u024F-''']",
136
- ), # PRESERVE ASCII letters, Latin-1 Supplement (À-ÿ), Latin Extended-A (Ā-ſ), Latin Extended-B (ǀ-ɏ), hyphens and apostrophes for romanization systems
135
+ r"[^A-Za-z\u00C0-\u00FF\u0100-\u024F\u1E00-\u1EFF-''']",
136
+ ), # PRESERVE ASCII letters, Latin-1 Supplement (À-ÿ), Latin Extended-A (Ā-ſ), Latin Extended-B (ǀ-ɏ), Latin Extended Additional (Ḁ-ỿ, Vietnamese ậ/ễ/ự), hyphens and apostrophes for romanization systems
137
137
  camel_case_finder=re.compile(r"[A-Z][a-z]+"),
138
138
  clean_pattern=CLEAN_PATTERN,
139
139
  forbidden_patterns_regex=FORBIDDEN_PATTERNS_REGEX,
@@ -45,7 +45,7 @@ Tiers, column `tier`:
45
45
  left out (surname-first sources put hyphenated given names such as `Zhong-Hua` in `last_name`). For this tier
46
46
  `mentions` counts the hyphenated mentions, `whole_share` includes them as whole, and `given_names` is the distinct
47
47
  given-name initials. A hyphen is any of `-`, U+2010, U+2011, U+2012, U+2013 (en dash) and U+2212 (minus sign).
48
- 2026-10-31 build from the October name counts (`name_counts_20261021_v2`, with the `oct2` partition and token
48
+ 2026-10-31 build from the October 2026 name counts (with token
49
49
  priors): 112,671 surfaces not already in another tier. Rows whose `first_name` is an East Asian surname (two or
50
50
  more letters) are not evidence: a surname-first source puts the hyphenated given name in `last_name`
51
51
  (`Wang / Cai-hon`, `Sakamoto / Shin-ichi`).
@@ -63,16 +63,15 @@ no identifiers.
63
63
 
64
64
  ## How it was built (2026-10-22, October snapshot) and how to rebuild from a later dump
65
65
 
66
- All steps are read-only and local except the first dump. Scripts live in
67
- `/Users/atalyaa/Documents/repos/author-names/pp_vys_orcid_conc/scripts/` unless noted; the final step is in this repo.
66
+ All steps are read-only and local except the first dump. Steps 1–5 and 7 use analysis scripts kept outside this
67
+ repo; step 6 is in this repo.
68
68
 
69
- 1. **Source-name counts.** One Athena pass over a post-backfill `paper_authors` snapshot
70
- (`author-names/NAME_COUNTS.md`, `pp_vys_orcid_conc/scripts/v4/athena_name_counts.sh`): one row per distinct
69
+ 1. **Source-name counts.** One pass over a post-backfill `paper_authors` snapshot: one row per distinct
71
70
  source triple, where the source name is **all** `original_*` fields when `original_last IS NOT NULL`, else the
72
71
  stored fields (never a per-field coalesce — it leaks sinonym's own middle into rewritten rows). Counts: mentions,
73
72
  distinct papers, distinct ORCIDs; no production `author_id`. 113.6M triples, 702.9M mentions (Oct 2026).
74
- 2. (The May 2026 build used a pre-sinonym dump, `pre_name_counts.py`; same schema.)
75
- 3. **Partition statistics.** `partition_prior.py "<out_dir>/*.parquet" partition_prior.parquet` → for each 2–4-word
73
+ 2. (The May 2026 build used a pre-sinonym dump with the same schema.)
74
+ 3. **Partition statistics.** `partition_prior.parquet`: for each 2–4-word
76
75
  surname tail (`middle` words + `last` words), how often the corpus puts k words in `middle`; `share_whole`
77
76
  = k = 0. Also writes `partition_prior_tokens.parquet`: per word, mentions as a given name vs as the surname word.
78
77
  4. **Candidate universe.** Mention-count thresholds (in `build_compound_surnames.py`): 2–3 words, ≥ 50 mentions,
@@ -80,14 +79,14 @@ All steps are read-only and local except the first dump. Scripts live in
80
79
  letters, no suffix tail (`junior`, `filho`, …), no East Asian surname head (Vietnamese `Nguyen Van`, Chinese
81
80
  `Liu Yang` are not compounds), no Vietnamese `van X` / `thi X` pair (`Van Le`, `Van Tran`), no Chinese compound
82
81
  head (`Au Yeung`, `Ou Yang` stay with sinonym's curated list).
83
- Kill test before anything ships: `sim_compound_canon.py --asset <csv.gz> --no-shrink --half A|B` applies the
84
- shipped rule to an existing routed arm and scores people united / split under the production block key on
85
- the held-out ORCID half. Without `--no-shrink` the simulation also cuts longer surnames down to the surface
86
- and over-counts (2026-10-21: 446 / 17) — the shipped rule's own numbers are in step 7.
87
- 5. **Person-level gate.** `scripts/v4/compound_orcid_gate_v4.py` over dataset v4 (every ORCID mention with its source
88
- name), excluding the ORCIDs of the 690k evaluation index: per surface, distinct people with the whole form, the
89
- split form, and both. `HALF=A` builds it on one ORCID half (last ORCID character not in 1 3 5 7 9 X) so the other
90
- half can score the asset; `HALF=all` for the shipped build.
82
+ Kill test before anything ships: apply the shipped rule to an existing routed arm and score people united /
83
+ split under the production block key on the held-out ORCID half. The simulation must not also cut longer
84
+ surnames down to the surface, which over-counts (2026-10-21: 446 / 17); the shipped rule's own numbers are in
85
+ step 7.
86
+ 5. **Person-level gate.** `compound_orcid_gate.parquet`, built over every ORCID mention with its source
87
+ name, excluding the ORCIDs of the 690k evaluation index: per surface, distinct people with the whole form, the
88
+ split form, and both. One build uses one ORCID half (last ORCID character not in 1 3 5 7 9 X) so the other
89
+ half can score the asset; the shipped build uses all ORCIDs.
91
90
  6. **Asset.** `uv run python scripts/build_compound_surnames.py --partition partition_prior.parquet --tokens
92
91
  partition_prior_tokens.parquet --orcid-gate compound_orcid_gate.parquet --output sinonym/data/compound_surnames.csv.gz`
93
92
  keeps the `listed` surfaces where both signals agree (≥ 3 people, ≥ 2 of them whole), derives the
@@ -95,11 +94,10 @@ All steps are read-only and local except the first dump. Scripts live in
95
94
  pair of the partition statistics built from them (≥ 5 mentions, same head-word given-name gate), then prints
96
95
  the sha256, and adds the `corpus` tier. 2026-10-23 October build (floor 0.15, construct prefixes): 7,240 listed
97
96
  + 1,719 vocabulary + 167,475 corpus surfaces.
98
- 7. **Acceptance.** Route the 690k index with the new build (`run_690k_*.sh`), score with `conc_arms.py`
99
- (FIXED/BROKE ≥ 5:1 on half B, no shared-block growth), run the detector (`weird_bugs.py`) and a blind judge
100
- sample (`judge_changes.py`), and the test suite at its baseline. Then the corpus-scale run (every ORCID,
101
- `author-names/ORCID_V4.md`): `scripts/v4/broke_v4.py` attributes every united / split person to the rule that
102
- moved it, and `scripts/v4/registry_agreement.py` scores each arm's surnames against the ORCID registry's
97
+ 7. **Acceptance.** Route the 690k index with the new build and score it (FIXED/BROKE ≥ 5:1 on half B, no
98
+ shared-block growth), run an anomaly detector and a blind judge sample, and the test suite at its baseline.
99
+ Then the corpus-scale run over every ORCID mention: attribute every united / split person to the rule that
100
+ moved it, and score each arm's surnames against the ORCID registry's
103
101
  self-declared family names (the name ground truth; the corpus share is a source convention, not a truth).
104
102
 
105
103
  Known limits: sources that drop a compound's head entirely (`Maza` alone) cannot be joined by any rule; the
@@ -113,3 +111,33 @@ surfaces removed from the asset). Across every tier, ORCID people who write such
113
111
  word alone more often than both words (`mohamed` 40% / 32%, `mohammad` 42% / 36%, `bin` 58% / 29%): the head is a
114
112
  given name or a patronymic (`Ahmed / Mohamed / Ali`, `Ahmad / bin / Ismail`). The other construct prefixes register
115
113
  both words (`abdul` 62% / 22%, `mohd` 81% / 9%) and stay.
114
+
115
+ ## Refreshing the table: only clear evidence changes a surface (since 0.7.1)
116
+
117
+ A rebuild from a newer snapshot decides every surface by that day's evidence. Pairs that ORCID registrants write about
118
+ as often whole as split (`rodrigues gomes`, `rodrigues oliveira`, `silva santana`, `srinivasa rao`: 40-60 % of the
119
+ registrants carrying the pair register both words) then cross the majority threshold in either direction. Rebuilding
120
+ every tier from the 2026-11-12 data with unchanged thresholds fixed the family name of 4,489 ORCID people but broke
121
+ 3,108, far below the 5:1 acceptance bar of step 7.
122
+
123
+ `scripts/stabilize_compound_surnames.py` therefore compares the rebuilt table with the shipped one, surface by surface.
124
+ Its evidence is, per surface, the ORCID people whose source-supplied mentions end their `middle + last` words with the
125
+ surface, split by their registered family name in the ORCID public data file: `join` when it is the surface or ends
126
+ with it, `tail` when it is the surface without its first word (the script's docstring gives the exact folding and the
127
+ input schema).
128
+
129
+ - `join + tail >= 20` and `join >= 0.67` of them: listed;
130
+ - `join + tail >= 20` and `tail >= 0.67` of them: not listed;
131
+ - anything else (ambiguous, too few registrants, or no registry evidence): the shipped status.
132
+
133
+ Thresholds were chosen on held-out people: evidence from ORCID half A (last iD character not 1 3 5 7 9 X), scored on
134
+ half B against the 0.7.0 table. Keeping the shipped status for ambiguous pairs at a 0.67 margin and 20 registrants
135
+ changed 3 held-out family names for the better and none for the worse; a 0.6 margin let the churn back in (support 5:
136
+ 300 fixed, 254 broken). The alternative of dropping ambiguous pairs, so that sinonym follows each source's own field
137
+ split (`--ambiguous abstain`), lost at every setting tried (0.67 and 20: 2,702 fixed, 3,642 broken), because sources
138
+ split pairs their authors registered whole about as often as the reverse. A surface that stays listed keeps its
139
+ shipped row.
140
+
141
+ The shipped 0.7.1 table was decided on the half-A evidence as well (unlike the `HALF=all` gate of step 5), so half B
142
+ stays a held-out set for the next refresh. It is the 0.7.0 table without `silva silva` (half A: 10 registrants with
143
+ both words, 25 with `Silva`; half B: 8 and 26).
@@ -59,6 +59,8 @@ suppress an earlier candidate and therefore do not change routing metadata for
59
59
  already-correct context-supported parses. All other reviewed surnames use the
60
60
  general, candidate-aware possible-surname rule.
61
61
 
62
+ `Fuji Ren` is a separate exact entry in `JAPANESE_PRESELECTION_GIVEN_FIRST_EXACT_SURFACES`, not in the reviewed CSV: it is a Chinese given-first name (ORCID family name `Ren`, 827 mentions in the 2026-11-12 name-counts export) whose two words are a Japanese surname and a Japanese given name, so the Japanese family-first inference would otherwise make `Fuji` the surname. The same person written surname-first, `Ren Fuji` (56 mentions in `content_ext.paper_authors` on 2026-11-25, all with his known co-authors), is in `IDENTITY_BACKED_EXACT_ROLES` as surname then given.
63
+
62
64
  ## Popular Names by Country Dataset
63
65
 
64
66
  Source: <https://github.com/sigpwned/popular-names-by-country-dataset>
@@ -47,30 +47,47 @@ Attribution: the 120W corpus is from [wainshine/Chinese-Names-Corpus](https://gi
47
47
  - The scoring hook reads `spelling` and `target_share` and (via initialization) loads each row's `surname_ppm_as_written` into the runtime surname frequency table, so full-share rows carry the target's mass and penalty CANTONESE keys carry the discounted mass. Corpus-derived estimates (e.g. ORCID with affiliation country) can replace the numbers without a schema change.
48
48
  ### Corpus-Derived Name Assets: Coverage, Provenance and Refresh
49
49
 
50
- Four assets are lookup tables built from Semantic Scholar author names:
50
+ Five assets are lookup tables built from Semantic Scholar author names:
51
51
 
52
52
  | asset | built by | snapshot | fires only when |
53
53
  |---|---|---|---|
54
- | `compound_surnames.csv.gz` | `scripts/build_compound_surnames.py`, `scripts/build_hyphen_compound_surnames.py` ([COMPOUND_SURNAMES.md](COMPOUND_SURNAMES.md)) | October 2026 | the multi-word surname is listed |
55
- | `two_token_order_prior.csv.gz` | `scripts/build_order_prior_asset.py` | May 2026 | the pair has >= 100 mentions and a >= 80% majority |
56
- | `token_role_prior.csv.gz` | `scripts/build_token_order_prior.py` | May 2026 | the token has >= 200 mentions and is >= 90% one role |
57
- | `surname_first_words.csv.gz` | `scripts/build_surname_first_words.py` | October 2026 | the word was seen in that shape and is mostly a surname (>= 3 mentions) |
54
+ | `compound_surnames.csv.gz` | `scripts/build_compound_surnames.py`, `scripts/build_hyphen_compound_surnames.py`, then `scripts/stabilize_compound_surnames.py` ([COMPOUND_SURNAMES.md](COMPOUND_SURNAMES.md)) | October 2026 | the multi-word surname is listed |
55
+ | `two_token_order_prior.csv.gz` | `scripts/build_order_prior_asset.py`, then `scripts/stabilize_order_priors.py` | November 2026 | the pair has >= 100 mentions and a >= 80% majority |
56
+ | `token_role_prior.csv.gz` | `scripts/build_token_order_prior.py`, then `scripts/stabilize_order_priors.py` | November 2026 | the token has >= 200 mentions and is >= 90% one role |
57
+ | `surname_first_words.csv.gz` | `scripts/build_surname_first_words.py` | November 2026 | the word was seen in that shape and is mostly a surname (>= 3 mentions) |
58
+ | `glued_initial_prefixes.csv.gz` | `scripts/build_glued_initial_prefixes.py` | November 2026 | the word before a glued capital is a first name >= 100 times and at least as often as a surname, and word + that letter is not itself a common first name |
58
59
 
59
60
  - **Unseen names.** A name a table does not list gets the behavior without that rule, never a guess, so new or rare
60
61
  names are not made worse; they just do not get the gain. Shape-based rules (digraph initials, glued initials, the
61
62
  Japanese given-first veto) apply to any name.
62
63
  - **Provenance.** Build every asset from source names as published, never from sinonym's output: per row, all
63
- `original_*` fields when `original_last` is set, else the stored fields, and never coalesce per field (the export is
64
- described in author-names `NAME_COUNTS.md`). An asset built from normalized names learns sinonym's own decisions.
64
+ `original_*` fields when `original_last` is set, else the stored fields, and never coalesce per field. An asset built from normalized names learns sinonym's own decisions.
65
65
  - **Refresh.** The tables age as new authors and conventions arrive. Rebuild them from a newer snapshot periodically,
66
66
  and in particular after each ORCID backfill (more linked people strengthens the ORCID-gated compound tier), then
67
67
  rerun the ORCID ledger, the registry agreement and the S2AND gold-cluster check before shipping.
68
68
  - **Measuring the gain on new names.** The held-out ORCID half guards against fitting particular people, but the tables
69
69
  were built from a snapshot that contains those names. To measure the gain on unseen names, build the tables from an
70
70
  older snapshot and score only names that first appear after it.
71
+ - **Current build (0.7.1).** Six tables were rebuilt on 2026-11-12 with the 0.7.0 builders and unchanged thresholds:
72
+ source-name counts from the Semantic Scholar `paper_authors` export of 2026-11-12, ORCID evidence only from iDs the
73
+ source supplied (iDs attached later by the ORCID profile backfill, which matches by name, are left out so the tables
74
+ do not learn from name matching), and the ORCID public data file of October 2026 (`korean_given_words.csv.gz`,
75
+ `allcaps_given_words.csv.gz`). Rows: two-token order prior 106,311 -> 107,787; token roles 238,677 -> 243,168 (the two order priors keep every 0.7.0 entry the rebuild dropped and add the rebuild's new ones, `scripts/stabilize_order_priors.py`: a dropped entry had only crossed a gate, and dropping it turned names such as `Petralia / Salvatore` back; entries kept from 0.7.0 keep their 0.7.0 counts, which the runtime does not read);
76
+ surname-first words 40,112 -> 42,178; glued-initial prefixes 112,710 -> 113,345; Korean given words 3,108 -> 3,670;
77
+ three-letter given words 881 -> 824. Two tables keep their 0.7.0 build, `unsplit_given_words.csv.gz` and
78
+ `given_name_words.csv.gz`; `compound_surnames.csv.gz` is the 0.7.0 table passed through
79
+ `scripts/stabilize_compound_surnames.py`, which changes a surface only on clear ORCID registry evidence
80
+ ([COMPOUND_SURNAMES.md](COMPOUND_SURNAMES.md)); this refresh drops one surface. Plain rebuilds of these tables broke
81
+ almost as many ORCID people's names as they fixed (compound surnames: 4,489 family names fixed, 3,108 broken, far
82
+ below the 5:1 acceptance bar; unsplit given words 26 / 21; given-name words 20 / 22), mostly pairs that registrants
83
+ write both ways about equally often, which the new data only moved across the majority threshold.
71
84
 
72
85
  ### Surname-First Words Before Dotted Initials
73
- - **`surname_first_words.csv.gz`**: 40,112 words (`word, surname_first_mentions, as_last, as_first`) that sources write as `first_name` before 2-3 dotted initials (`Dmitrieva / - / N.M.`, `Назарова / - / А.Р.`) and that the corpus otherwise uses as a surname (`as_last` >= 3 and > `as_first`). The rule that consumes it (`structured_surname_first_initials_assignment`) moves the word to the surname only when it is in this list, so given names written the same way (`Sowmya / - / K. R.`) stay unchanged. Generated by `scripts/build_surname_first_words.py` from the source-name counts export.
86
+ - **`surname_first_words.csv.gz`**: 42,178 words (`word, surname_first_mentions, as_last, as_first`) that sources write as `first_name` before 2-3 dotted initials (`Dmitrieva / - / N.M.`, `Назарова / - / А.Р.`) and that the corpus otherwise uses as a surname (`as_last` >= 3 and > `as_first`). The rule that consumes it (`structured_surname_first_initials_assignment`) moves the word to the surname only when it is in this list, so given names written the same way (`Sowmya / - / K. R.`) stay unchanged. Generated by `scripts/build_surname_first_words.py` from the source-name counts export.
87
+
88
+ ### Given Names Written in Capitals
89
+ - **`allcaps_given_words.csv.gz`**: 824 three-letter words (`word, name_people, initials_people, name_share`) that ORCID registry people write as their first given name (not in capitals, >= 10 people) making up at least 80% of those people plus the people whose three given names start with its letters. A given name of three capitals before a surname with lowercase letters stays in capitals as initials (`ESL Pedersen`, which S2AND reads as e + s + l) unless it is listed (`ANA Dias` -> `Ana`). Generated by `scripts/build_allcaps_given_words.py` from the ORCID public data file.
90
+ - **`given_name_words.csv.gz`**: 10,220 words (`word, given_people, family_people, family_head_people`) that at least 200 ORCID registry people use, at least 80% of them as a given name, and that fewer than 1.5% of those people use to open a multi-word family name. The 5,245 of them used by at least 95% as a given name and opened with by fewer than 0.5% (`jonathan`, `gareth`, `myriam`; not `andres`, `blanca`, `david`, which open Iberian double surnames) are not moved into the surname when the source wrote them in the given or middle field (`Q. / M. Jonathan / Wu` keeps surname `Wu`); before a one-word common Chinese surname all listed words are (`C. / L. Philip / Chen` keeps surname `Chen`). Generated by `scripts/build_given_name_words.py` from the ORCID public data file.
74
91
 
75
92
  ### Chinese vs Japanese Name Classifier
76
93
  - **`chinese_japanese_classifier.skops`**: Pre-trained scikit-learn model for distinguishing Chinese from Japanese names when written in Chinese characters. At runtime `sinonym.ml_fast_scorer` reads the fitted parameters directly from this archive without importing the training stack. The training script also writes a legacy `.joblib` copy for model-development comparisons; distributions omit that runtime-unused copy.
@@ -167,6 +167,7 @@ import math
167
167
  import platform
168
168
  import string
169
169
  import threading
170
+ import unicodedata
170
171
  from dataclasses import replace
171
172
  from typing import Literal
172
173
 
@@ -233,6 +234,7 @@ from sinonym.services.slavic_initials import is_digraph_initials_surname
233
234
  from sinonym.services.surname_first_words import load_surname_first_words, surname_first_initials
234
235
  from sinonym.services.token_order_prior import load_token_role_prior
235
236
  from sinonym.utils.string_manipulation import StringManipulationUtils
237
+ from sinonym.utils.unsplit_given_words import load_unsplit_given_words, standalone_words
236
238
 
237
239
  LOGGER = logging.getLogger(__name__)
238
240
 
@@ -341,6 +343,7 @@ class ChineseNameDetector:
341
343
  load_token_role_prior()
342
344
  load_order_prior()
343
345
  load_surname_first_words()
346
+ load_unsplit_given_words()
344
347
  surname_resolver = SurnameResolver(data, self._normalizer)
345
348
  ethnicity_service = EthnicityClassificationService(context)
346
349
  parsing_service = NameParsingService(context, weights=self._weights)
@@ -827,7 +830,7 @@ class ChineseNameDetector:
827
830
 
828
831
  def _clean_source_roman_token(self, token: str) -> str:
829
832
  """Clean a source Roman token while preserving source capitalization."""
830
- folded = token.translate(self._config.roman_punctuation_fold_tr)
833
+ folded = unicodedata.normalize("NFC", token.translate(self._config.roman_punctuation_fold_tr))
831
834
  return self._config.clean_roman_pattern.sub("", folded)
832
835
 
833
836
  def _roman_tokens_match_han_pinyin(self, roman_tokens: list[str], han_pinyin: tuple[str, ...]) -> bool:
@@ -1041,6 +1044,10 @@ class ChineseNameDetector:
1041
1044
  - success=True, result=formatted_name if Chinese name detected
1042
1045
  - success=False, error_message=reason if not Chinese name
1043
1046
  """
1047
+ with standalone_words(raw_name):
1048
+ return self._normalize_chinese_name_in_context(raw_name)
1049
+
1050
+ def _normalize_chinese_name_in_context(self, raw_name: str) -> ParseResult:
1044
1051
  initial_failure = self._initial_input_failure(raw_name)
1045
1052
  if initial_failure is not None:
1046
1053
  return initial_failure
@@ -115,7 +115,7 @@ PERSON_HYPHEN_LIKE = frozenset(
115
115
  # Invisible markup that carries no name content. These survive `clean_roman_pattern` (they are
116
116
  # neither Roman letters nor punctuation), leave the token unmatched by the tokenizer, and the
117
117
  # name then resolves as NON_PERSON_SOURCE_PASSTHROUGH -- so a real author is marked a non-person.
118
- # 24,933 rows of `paper_authors_full` carry one; a LEADING one also becomes the first initial in
118
+ # 24,933 rows of the paper-authors table carry one; a LEADING one also becomes the first initial in
119
119
  # scholar's `cluster_block_key`, because that key slices the raw first name.
120
120
  #
121
121
  # Deliberately EXCLUDED, per the measured split:
@@ -25,6 +25,7 @@ from sinonym.coretypes import (
25
25
  ParseResult,
26
26
  )
27
27
  from sinonym.utils.string_manipulation import StringManipulationUtils
28
+ from sinonym.utils.unsplit_given_words import standalone_words
28
29
 
29
30
  GUARDED_GIVEN_FIRST_BATCH_MIN_SHARE = 0.75
30
31
  GIVEN_NAME_SHAPE_MIN_SHARE = 0.5
@@ -342,6 +343,10 @@ class BatchAnalysisService:
342
343
 
343
344
  def _prepare_name(self, name: str, normalizer, *, need_individual: bool = True) -> _PreparedName:
344
345
  """Compute the name-local inputs shared by all batch contexts."""
346
+ with standalone_words(name):
347
+ return self._prepare_name_in_context(name, normalizer, need_individual=need_individual)
348
+
349
+ def _prepare_name_in_context(self, name: str, normalizer, *, need_individual: bool) -> _PreparedName:
345
350
  input_failure = self._input_failure(name)
346
351
  if input_failure is not None:
347
352
  return _PreparedName(
@@ -942,11 +947,12 @@ class BatchAnalysisService:
942
947
  matching_candidates = [c for c in format_entry.candidates if c.format == target_format]
943
948
  selected_candidate = matching_candidates[0] if matching_candidates else format_entry.best_candidate
944
949
 
945
- result = self._candidate_to_parse_result(
946
- selected_candidate,
947
- formatting_service,
948
- format_entry.compound_metadata,
949
- )
950
+ with standalone_words(format_entry.name):
951
+ result = self._candidate_to_parse_result(
952
+ selected_candidate,
953
+ formatting_service,
954
+ format_entry.compound_metadata,
955
+ )
950
956
  results.append(result)
951
957
 
952
958
  return results
@@ -14,10 +14,17 @@ import unicodedata
14
14
  from functools import lru_cache
15
15
 
16
16
  from sinonym.resources import read_bytes
17
+ from sinonym.services.person_name_normalization import _CREDENTIAL_KEYS, _TITLE_KEYS
18
+ from sinonym.services.source_repairs import CREDENTIAL_WORDS, SPELLED_CREDENTIAL_WORDS
17
19
 
18
20
  MAX_SURFACE_WORDS = 3
19
21
  # a given name or patronymic, not the head of a family name (``Ahmed / Mohamed / Ali``, ``Ahmad / bin / Ismail``)
20
22
  EXCLUDED_HEADS = frozenset({"mohamed", "mohammad", "bin"})
23
+ # credential and title keys that are also names: Md (Malay patronymic), Ba, Ma, Pastor, Frau, Portuguese do, Meng, Hon
24
+ _NAME_WORDS = frozenset({"ba", "beng", "do", "edd", "frau", "hon", "ma", "md", "meng", "pastor"})
25
+ _NOT_NAME_WORDS = (_CREDENTIAL_KEYS | _TITLE_KEYS | CREDENTIAL_WORDS | SPELLED_CREDENTIAL_WORDS) - _NAME_WORDS
26
+ # an MD degree written before the surname, not a Malay patronymic: the ORCID person registers Smith
27
+ _CREDENTIAL_SURFACES = frozenset({"md smith"})
21
28
 
22
29
 
23
30
  @lru_cache(maxsize=65536)
@@ -38,3 +45,9 @@ def listed_compound_suffix(words: list[str]) -> int:
38
45
  if folded[-width] not in EXCLUDED_HEADS and " ".join(folded[-width:]) in _surfaces():
39
46
  return width
40
47
  return 0
48
+
49
+
50
+ def credential_join(moved: list[str], surface: list[str]) -> bool:
51
+ """Whether joining ``moved`` given-field words into the listed ``surface`` would turn a credential or title into surname."""
52
+ folded = [fold_word(word) for word in moved]
53
+ return not _NOT_NAME_WORDS.isdisjoint(folded) or " ".join(fold_word(word) for word in surface) in _CREDENTIAL_SURFACES
@@ -62,10 +62,12 @@ VIETNAMESE_GIVEN_FIRST_EXACT_SURFACES = frozenset({"tuan le"})
62
62
  # extends the same decision to singleton/PP-only use without changing that
63
63
  # production result.
64
64
  CROSS_CULTURAL_GIVEN_FIRST_EXACT_SURFACES = frozenset({"to keku"})
65
- # These two released exact surfaces also suppress an early Japanese
65
+ # These released exact surfaces also suppress an early Japanese
66
66
  # family-first inference. Newly censused surfaces are post-selection vetoes so
67
67
  # already-correct context-supported parses keep their existing public metadata.
68
- JAPANESE_PRESELECTION_GIVEN_FIRST_EXACT_SURFACES = frozenset({"kou hiroya", "takaya miwa"})
68
+ # ``fuji ren`` is a Chinese given-first name (ORCID family name Ren) whose two
69
+ # words are a Japanese surname and a Japanese given name.
70
+ JAPANESE_PRESELECTION_GIVEN_FIRST_EXACT_SURFACES = frozenset({"fuji ren", "kou hiroya", "takaya miwa"})
69
71
  # Exact lexical false friends whose reviewed PP/VYS flips are family-first when
70
72
  # another complete paper author supplies context. Token-level exclusions would
71
73
  # suppress verified Japanese names such as Ma Kai. Yuan Tai is deliberately
@@ -137,6 +139,7 @@ VIETNAMESE_GIVEN_FIRST_CONFLICT_SURFACES = frozenset(
137
139
  IDENTITY_BACKED_EXACT_ROLES = {
138
140
  "huong yong ting": ("given", "given", "surname"),
139
141
  "ming hsien ou yang": ("given", "middle", "surname", "surname"),
142
+ "ren fuji": ("surname", "given"),
140
143
  "shiu lun au yeung": ("given", "middle", "surname", "surname"),
141
144
  "thuong le thi": ("given", "surname", "middle"),
142
145
  "trinh nguyen duy": ("middle", "surname", "given"),
@@ -354,7 +354,10 @@ class EthnicityClassificationService:
354
354
  # =================================================================
355
355
 
356
356
  # Chinese default: Accept if we have any reasonable Chinese surname evidence
357
- if self._has_sufficient_chinese_surname_strength(expanded_keys, normalized_cache):
357
+ compound_norms = frozenset(
358
+ get_normalized(token) for token in expanded_tokens if token.lower() in COMPOUND_VARIANTS
359
+ ) - frozenset(original_keys_raw)
360
+ if self._has_sufficient_chinese_surname_strength(expanded_keys, normalized_cache, compound_norms):
358
361
  return ParseResult.success_with_name("")
359
362
 
360
363
  # No Chinese evidence found
@@ -696,6 +699,7 @@ class EthnicityClassificationService:
696
699
  self,
697
700
  expanded_keys: list[str],
698
701
  normalized_cache: dict[str, str],
702
+ compound_norms: frozenset[str] = frozenset(),
699
703
  ) -> bool:
700
704
  """Return whether nonnegative surname evidence reaches the Chinese threshold."""
701
705
  chinese_surname_strength = 0.0
@@ -748,12 +752,15 @@ class EthnicityClassificationService:
748
752
  if clean_key_lower in split_result_cache:
749
753
  split_result = split_result_cache[clean_key_lower]
750
754
  else:
755
+ # the normalized form of a compact compound surname (Yuchi -> yuji) scores as a split even when
756
+ # it is a never-split word
751
757
  split_result = StringManipulationUtils.split_concatenated_name(
752
758
  clean_key_lower,
753
759
  normalized_cache,
754
760
  self._data,
755
761
  self._normalizer,
756
762
  self._config,
763
+ ignore_unsplit_list=clean_key_lower in compound_norms,
757
764
  )
758
765
  split_result_cache[clean_key_lower] = split_result
759
766
 
@@ -8,6 +8,7 @@ mixed script handling, and compound name splitting with cultural validation.
8
8
  from __future__ import annotations
9
9
 
10
10
  import string
11
+ import unicodedata
11
12
  from dataclasses import dataclass
12
13
  from functools import lru_cache
13
14
  from typing import TYPE_CHECKING, Literal
@@ -23,6 +24,7 @@ from sinonym.text_processing import CompoundDetector, TextNormalizer, TextPrepro
23
24
  from sinonym.text_processing.text_normalizer import strip_name_variation_selectors
24
25
  from sinonym.utils.string_manipulation import StringManipulationUtils
25
26
  from sinonym.utils.thread_cache import ThreadLocalCache
27
+ from sinonym.utils.unsplit_given_words import is_listed_bound_part, standalone_words
26
28
 
27
29
  if TYPE_CHECKING:
28
30
  from sinonym.coretypes import ChineseNameConfig
@@ -212,6 +214,10 @@ class NormalizationService:
212
214
  Pure function: raw input → normalized structure.
213
215
  Side-effect free, suitable for Scala interop.
214
216
  """
217
+ with standalone_words(raw_name):
218
+ return self._apply(raw_name)
219
+
220
+ def _apply(self, raw_name: str) -> NormalizedInput:
215
221
  if not raw_name or not raw_name.strip():
216
222
  return NormalizedInput.empty(raw_name)
217
223
 
@@ -381,7 +387,7 @@ class NormalizationService:
381
387
  # Clean Roman token
382
388
  clean_token = self._config.clean_roman_pattern.sub(
383
389
  "",
384
- token.translate(self._config.roman_punctuation_fold_tr),
390
+ unicodedata.normalize("NFC", token.translate(self._config.roman_punctuation_fold_tr)),
385
391
  )
386
392
  # Filter out empty tokens and tokens that are only punctuation
387
393
  if clean_token and not all(c in string.punctuation for c in clean_token):
@@ -521,7 +527,7 @@ class NormalizationService:
521
527
 
522
528
  def _clean_roman_token(self, token: str) -> str:
523
529
  """Clean a Roman token without changing its source capitalization."""
524
- folded = token.translate(self._config.roman_punctuation_fold_tr)
530
+ folded = unicodedata.normalize("NFC", token.translate(self._config.roman_punctuation_fold_tr))
525
531
  return self._config.clean_roman_pattern.sub("", folded)
526
532
 
527
533
  def _roman_matches_han_token(self, roman_token: str, han_pinyin: tuple[str, ...]) -> bool:
@@ -607,6 +613,8 @@ class NormalizationService:
607
613
  # If not found, check if it can be split into valid syllables
608
614
  if StringManipulationUtils.split_concatenated_name(token, normalized_cache, self._data, self, self._config):
609
615
  return True
616
+ if is_listed_bound_part(token):
617
+ return True
610
618
 
611
619
  # Handle hyphenated tokens by splitting and validating each part
612
620
  if "-" in token: