sinonym 0.6.0__tar.gz → 0.6.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.
- {sinonym-0.6.0 → sinonym-0.6.2}/PKG-INFO +1 -1
- {sinonym-0.6.0 → sinonym-0.6.2}/docs/timo.md +2 -2
- {sinonym-0.6.0 → sinonym-0.6.2}/pyproject.toml +1 -1
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/coretypes/routing_resolution.py +1 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/order_prior.py +11 -11
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/person_name_normalization.py +2 -3
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/text_processing/text_preprocessor.py +0 -2
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/timo/_resolution.py +42 -40
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_s2and_review_regressions.py +115 -18
- {sinonym-0.6.0 → sinonym-0.6.2}/.gitignore +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/LICENSE +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/README.md +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/docs/batch_processing.md +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/docs/canonical_name_evaluation.md +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/docs/scalar_source_surname_repartition_evaluation.md +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/docs/unicode_hyphen_policy_review.md +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/scripts/README.md +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/scripts/build_east_asian_name_lexicons.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/scripts/check_test_status.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/scripts/data/reviewed_japanese_possible_surnames.csv +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/scripts/generate_name_statistics.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/scripts/generate_surname_romanizations.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/scripts/name_order_routing_rules.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/scripts/train_ml_classifier_for_chinese_vs_japanese.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/scripts/verify_multiprocess.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/__init__.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/chinese_names_data.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/coretypes/__init__.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/coretypes/config.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/coretypes/results.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/COMPOUND_SURNAMES.md +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/EAST_ASIAN_NAME_LEXICONS.md +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/README.md +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/acl_2025_authors.txt +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/chinese_japanese_classifier.skops +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/compound_surnames.csv.gz +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/east_asian_roman_lexicons.json.gz +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/familyname_orcid.csv +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/given_position.csv +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/givenname_orcid.csv +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/japanese_native_lexicons.json.gz +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/model_features.json +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/name_order_routing/README.md +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/name_order_routing/pp_abstain_labels.jsonl +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/name_order_routing/pp_vys_abstain_labels.jsonl +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/surname_first_words.csv.gz +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/surname_romanizations.csv +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/token_role_prior.csv.gz +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/data/two_token_order_prior.csv.gz +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/detector.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/ml_fast_scorer.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/ml_flag_data.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/ml_model_components.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/name_punctuation.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/patterns/__init__.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/patterns/compiled_patterns.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/patterns/regex_builders.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/pipeline/__init__.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/pipeline/name_order_routing.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/resources.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/__init__.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/batch_analysis.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/cache.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/compound_surnames.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/east_asian_name_order.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/ethnicity.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/formatting.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/initialization.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/name_lookup.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/non_person.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/normalization.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/order_metadata.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/parsing.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/process_pool.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/slavic_initials.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/surname_first_words.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/services/token_order_prior.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/text_processing/__init__.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/text_processing/compound_detector.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/text_processing/text_normalizer.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/timo/__init__.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/timo/config.yaml +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/timo/integration_test.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/timo/interface.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/utils/__init__.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/utils/string_manipulation.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/sinonym/utils/thread_cache.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/_case_assertions.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/_korean_atomic_cases.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/conftest.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/data/hangul_name_order_gold.json +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/data/manufactured_initials_cohorts.json +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/data/reviewed_korean_source_assignments.tsv +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/data/reviewed_source_pattern_assignments.jsonl +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/data/spaced_cjk_name_order_gold.json +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/data/timo_parity/manifest.json +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/data/timo_parity/requests.jsonl +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/data/vietnamese_name_order_gold.json +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_acl.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_all_chinese_inputs.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_basic_chinese_names.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_batch.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_batch_crash_guard.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_batch_scalar_parity.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_bug_report_fixes.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_canonical_name_integration.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_canonical_results.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_check_test_status.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_chinese_classification_evidence_gates.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_chinese_compound_surname_provenance.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_cjk_component_leaks.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_compound_names.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_compound_surname_formats.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_config_immutability.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_detector_initialization_and_validation.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_east_asian_lexicon_builder.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_east_asian_name_order.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_fixability_proposal_fixes.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_han_surname_readings.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_hangul_name_order_gold.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_initial_policy_chinese.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_initial_policy_non_chinese.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_initial_policy_routing.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_manufactured_initials.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_middle_names.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_misc.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_mixed_production_cases.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_mixed_scripts.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_ml_fast_scorer.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_ml_japanese_detection.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_multiprocess_pool.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_name_formatting.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_name_order_routing_label_fixtures.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_name_order_routing_rules.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_name_statistics_data.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_non_chinese_exact_source_fixes.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_non_chinese_rejection.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_package_metadata.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_performance.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_person_name_normalization.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_pr29_pr30_paper_context_repairs.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_reference_scripts.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_regional_variants.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_regression_proposals.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_review_finding_regressions.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_reviewed_non_person_patterns.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_reviewed_structured_source_repairs.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_scalar_clean_source_surname_repartition.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_spaced_cjk_name_order_gold.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_strict_spaced_japanese_routing.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_surname_romanizations.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_timo_contract.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_timo_interface.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_timo_parity_fixture.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_timo_performance.py +0 -0
- {sinonym-0.6.0 → sinonym-0.6.2}/tests/test_vietnamese_name_order_gold.py +0 -0
|
@@ -221,7 +221,7 @@ Some TIMO rules use statistics of the Semantic Scholar corpus or the source fiel
|
|
|
221
221
|
| `corpus_compound_surname_assignment` | joins a listed compound surname (`Ana / Silva / Santos` → `Ana / Silva Santos`) | reorders on corpus evidence alone; list built from the S2 corpus and ORCID |
|
|
222
222
|
| `edge_particle_surname_assignment` | moves a family particle glued to the end of the middle field into a one-word surname (`Ana / Maria-da / Silva` → `Ana / Maria / da Silva`, `A. / Gehrmann-De / Ridder` → `A. / Gehrmann-De Ridder`) | reads the source field boundary |
|
|
223
223
|
| `given_name_phrase_assignment` | keeps a Spanish or Portuguese given-name phrase out of the surname (`Sofía / del Carmen / Jaramillo Quiroz` → `Sofía del Carmen / Jaramillo Quiroz`) | reads the source field boundary; phrase list chosen on ORCID registry family names |
|
|
224
|
-
| `corpus_order_prior_assignment
|
|
224
|
+
| `corpus_order_prior_assignment` | settles a two-token Chinese name to the order the corpus writes for that pair, after the router picks a parse without a venue pool (PP-only routing); with a venue pool the router's pick stands. `vys_corpus_order_prior_assignment` is kept in the enum for compatibility but is no longer emitted (since 0.6.1) | the canonical APIs have no router decision |
|
|
225
225
|
| `corpus_token_order_prior_assignment` | swaps a two-token Latin name written surname-first (`Schoenmakers / Birgitte` → `Birgitte / Schoenmakers`) | reorders on corpus evidence alone; tuned on S2 bylines |
|
|
226
226
|
| `structured_initials_surname_assignment` for a glued given initial | `J.Dias / de / Deus` → `J. / Dias de Deus` | measured in TIMO only |
|
|
227
227
|
|
|
@@ -231,7 +231,7 @@ These are shared by TIMO and the canonical APIs:
|
|
|
231
231
|
|---|---|---|
|
|
232
232
|
| a surname written before 2-3 dotted initials (`Dmitrieva / - / N.M.`), when the corpus uses the word mostly as a surname; common Chinese surnames keep the Chinese initials form (`W.-M. Zhang`) | `structured_surname_first_initials_assignment` | `normalize_person_name_components` only (needs the fields) |
|
|
233
233
|
| dotted initials with a Slavic digraph before one surname word stay as written (`Ya. B. Beikin`) | `structured_initials_surname_assignment` | all |
|
|
234
|
-
| a Chinese reversal of a two-token name is undone when the corpus writes the pair in the source order (`Ding Zhang`) | `corpus_order_prior_assignment` | all |
|
|
234
|
+
| a Chinese reversal of a two-token name is undone when the corpus writes the pair in the source order (`Ding Zhang`) | `corpus_order_prior_assignment` | all (TIMO: without a venue pool) |
|
|
235
235
|
| a romanized given-first Japanese name is not reversed (`Yu Kume`); the canonical APIs use the focal name only, TIMO also uses the paper | `japanese_given_first_reorder_veto_preserve_input` | all |
|
|
236
236
|
| the directional Japanese dictionary flip stands down when the corpus token roles say the input is given-first (`Yoko Kozuki`) | `scalar_baseline` | all |
|
|
237
237
|
|
|
@@ -81,6 +81,7 @@ class ResolutionReason(str, Enum):
|
|
|
81
81
|
PP_SELECTED = "pp_selected"
|
|
82
82
|
VYS_SELECTED = "vys_selected"
|
|
83
83
|
CORPUS_ORDER_PRIOR_ASSIGNMENT = "corpus_order_prior_assignment"
|
|
84
|
+
# kept for API compatibility; not emitted since 0.6.1 (the order prior no longer applies with a venue pool)
|
|
84
85
|
VYS_CORPUS_ORDER_PRIOR_ASSIGNMENT = "vys_corpus_order_prior_assignment"
|
|
85
86
|
CORPUS_COMPOUND_SURNAME_ASSIGNMENT = "corpus_compound_surname_assignment"
|
|
86
87
|
EDGE_PARTICLE_SURNAME_ASSIGNMENT = "edge_particle_surname_assignment"
|
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
S2 corpus (May 2026 snapshot, 691M rows) were written as ``first=a last=b`` versus ``first=b last=a``. Only pairs
|
|
5
5
|
with >= 100 mentions and a >= 80% majority that the Chinese parser can read are kept. The prior settles the
|
|
6
6
|
orientation of an ambiguous two-token Chinese name (`Xi Lu` / `Lu Xi`) by how the corpus itself writes that pair,
|
|
7
|
-
which keeps every mention of the pair on one surname.
|
|
8
|
-
venue pool
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
which keeps every mention of the pair on one surname. In TIMO it applies only when the router picks a parse without a
|
|
8
|
+
venue pool (PP-only routing); the canonical APIs use it to keep the source order of a reversed two-token Chinese name. On
|
|
9
|
+
abstain the source order stands: the corpus majority overrode the person's own surname far more often than it fixed it
|
|
10
|
+
(ORCID registry: 19,574 broken vs 2,275 fixed). With a venue pool the router has already weighed the venue's convention,
|
|
11
|
+
and the prior overrode it wrongly about twice as often as rightly even when it required an 86% majority (publisher
|
|
12
|
+
ORCID-linked author rows routed with production-style venue pools, against the registered family name: 2,675 surnames
|
|
13
|
+
fixed vs 5,685 broken). The cost is block consistency: without the prior some mentions of a pair keep the other
|
|
14
|
+
orientation, so more of a person's papers land in different disambiguation blocks (863 more people split in the same
|
|
15
|
+
evaluation).
|
|
15
16
|
"""
|
|
16
17
|
from __future__ import annotations
|
|
17
18
|
|
|
@@ -25,7 +26,6 @@ from sinonym.resources import read_bytes
|
|
|
25
26
|
|
|
26
27
|
PRIOR_MIN_MENTIONS = 100
|
|
27
28
|
PRIOR_MIN_SHARE = 0.8
|
|
28
|
-
POOL_PRIOR_MIN_SHARE = 0.86
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def _fold(token: str) -> str:
|
|
@@ -52,14 +52,14 @@ def load_order_prior() -> None:
|
|
|
52
52
|
_table()
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
def corpus_surname_for(given: str, surname: str
|
|
55
|
+
def corpus_surname_for(given: str, surname: str) -> str | None:
|
|
56
56
|
"""Return the token the corpus writes as the surname for this pair, or None when the prior is silent."""
|
|
57
57
|
g, s = _fold(given), _fold(surname)
|
|
58
58
|
if not g or not s or g == s:
|
|
59
59
|
return None
|
|
60
60
|
a, b = (g, s) if g < s else (s, g)
|
|
61
61
|
entry = _table().get((a, b))
|
|
62
|
-
if entry is None
|
|
62
|
+
if entry is None:
|
|
63
63
|
return None
|
|
64
64
|
majority = entry[0]
|
|
65
65
|
corpus_surname = b if majority == "ab" else a
|
|
@@ -23,7 +23,6 @@ from sinonym.coretypes import CanonicalName, NameComponents
|
|
|
23
23
|
from sinonym.name_punctuation import (
|
|
24
24
|
INVISIBLE_MARKUP_DELETE_TRANSLATION,
|
|
25
25
|
PERSON_JOINER_FOLD_TRANSLATION,
|
|
26
|
-
attach_detached_diacritics,
|
|
27
26
|
fold_internal_name_joiners,
|
|
28
27
|
fold_spaced_transliteration_apostrophes,
|
|
29
28
|
strip_soft_hyphens,
|
|
@@ -694,7 +693,7 @@ class PersonNameNormalizationService:
|
|
|
694
693
|
"""Normalize one raw name string into semantic canonical components."""
|
|
695
694
|
if not isinstance(raw_name, str):
|
|
696
695
|
return self._invalid("name must be a string")
|
|
697
|
-
raw_name =
|
|
696
|
+
raw_name = strip_soft_hyphens(raw_name)
|
|
698
697
|
if reviewed_non_person_text_pattern(raw_name) is not None:
|
|
699
698
|
return self._non_person("reviewed non-person input")
|
|
700
699
|
|
|
@@ -838,7 +837,7 @@ class PersonNameNormalizationService:
|
|
|
838
837
|
if any(value is not None and not isinstance(value, str) for value in values.values()):
|
|
839
838
|
return self._invalid("name components must be strings or null")
|
|
840
839
|
values = {
|
|
841
|
-
role:
|
|
840
|
+
role: strip_soft_hyphens(value) if value else value for role, value in values.items()
|
|
842
841
|
}
|
|
843
842
|
first_name, middle_name, last_name, suffix = values["given"], values["middle"], values["surname"], values["suffix"]
|
|
844
843
|
source_surface = " ".join(value for value in (first_name, middle_name, last_name) if value)
|
|
@@ -15,7 +15,6 @@ from __future__ import annotations
|
|
|
15
15
|
import re
|
|
16
16
|
from typing import TYPE_CHECKING
|
|
17
17
|
|
|
18
|
-
from sinonym.name_punctuation import attach_detached_diacritics
|
|
19
18
|
from sinonym.utils.string_manipulation import StringManipulationUtils
|
|
20
19
|
|
|
21
20
|
if TYPE_CHECKING:
|
|
@@ -50,7 +49,6 @@ class TextPreprocessor:
|
|
|
50
49
|
"""
|
|
51
50
|
|
|
52
51
|
surname_first_parenthetical = bool(self._surname_first_parenthetical_re.match(raw))
|
|
53
|
-
raw = attach_detached_diacritics(raw)
|
|
54
52
|
|
|
55
53
|
# Single pass for most cleaning operations
|
|
56
54
|
raw = self._config.clean_pattern.sub(self._clean_replacement, raw)
|
|
@@ -49,7 +49,7 @@ from sinonym.services.non_person import (
|
|
|
49
49
|
REVIEWED_HANGUL_ORGANIZATION_MARKERS,
|
|
50
50
|
reviewed_non_person_source_pattern,
|
|
51
51
|
)
|
|
52
|
-
from sinonym.services.order_prior import
|
|
52
|
+
from sinonym.services.order_prior import corpus_surname_for
|
|
53
53
|
from sinonym.services.person_name_normalization import (
|
|
54
54
|
EAST_ASIAN_GIVEN_HOMOGRAPH_PARTICLES,
|
|
55
55
|
EAST_ASIAN_GIVEN_SYLLABLES,
|
|
@@ -219,6 +219,7 @@ _REVIEWED_TRAILING_AFFILIATION_ROSTERS = frozenset(
|
|
|
219
219
|
),
|
|
220
220
|
},
|
|
221
221
|
)
|
|
222
|
+
_REVIEWED_TRAILING_AFFILIATION_ROSTER_SIZES = frozenset(len(roster) for roster in _REVIEWED_TRAILING_AFFILIATION_ROSTERS)
|
|
222
223
|
_REVIEWED_CLEANUP_PREFIX_CREDENTIAL_KEYS = frozenset({"dnb"})
|
|
223
224
|
_CYRILLIC_NAME_TOKEN_RE = re.compile(r"[\u0410-\u042f\u0401][\u0410-\u044f\u0401\u0451'\u2019-]+")
|
|
224
225
|
_FEMININE_CYRILLIC_SURNAME_SUFFIXES = (
|
|
@@ -1261,9 +1262,7 @@ class SourceAuthorFields(_Model):
|
|
|
1261
1262
|
return " ".join(part for part in (first, middle, last) if part).strip()
|
|
1262
1263
|
|
|
1263
1264
|
|
|
1264
|
-
def _corpus_order_prior_parsed(
|
|
1265
|
-
parsed: ParsedName | None, raw_name: str, min_share: float = PRIOR_MIN_SHARE,
|
|
1266
|
-
) -> ParsedName | None:
|
|
1265
|
+
def _corpus_order_prior_parsed(parsed: ParsedName | None, raw_name: str) -> ParsedName | None:
|
|
1267
1266
|
"""Flip a two-token parse to the orientation the corpus writes for that pair, when the prior is strong.
|
|
1268
1267
|
|
|
1269
1268
|
A name written only in a CJK script is surname-first, so the romanized-pair prior never overrides it."""
|
|
@@ -1272,7 +1271,7 @@ def _corpus_order_prior_parsed(
|
|
|
1272
1271
|
given, surname = parsed.given_tokens[0], parsed.surname_tokens[0]
|
|
1273
1272
|
if "-" in given or "-" in surname or not given.isalpha() or not surname.isalpha():
|
|
1274
1273
|
return None
|
|
1275
|
-
corpus_surname = corpus_surname_for(given, surname
|
|
1274
|
+
corpus_surname = corpus_surname_for(given, surname)
|
|
1276
1275
|
if corpus_surname is None or corpus_surname == surname:
|
|
1277
1276
|
return None
|
|
1278
1277
|
# the per-character script scan runs last: it is the costliest check and only matters for a flip
|
|
@@ -1433,6 +1432,9 @@ def _reviewed_paper_wide_trailing_affiliation_assignment(
|
|
|
1433
1432
|
surname_is_recognized: Callable[[str], bool],
|
|
1434
1433
|
) -> NameComponents | None:
|
|
1435
1434
|
"""Repair a leaked trailing ``a`` only on a fully reviewed paper roster."""
|
|
1435
|
+
# runs once per author, so building the roster key for every author of a huge paper is quadratic
|
|
1436
|
+
if len(paper_authors) not in _REVIEWED_TRAILING_AFFILIATION_ROSTER_SIZES:
|
|
1437
|
+
return None
|
|
1436
1438
|
roster_key = tuple(_source_component_key(peer) for peer in paper_authors)
|
|
1437
1439
|
if roster_key not in _REVIEWED_TRAILING_AFFILIATION_ROSTERS:
|
|
1438
1440
|
return None
|
|
@@ -2034,6 +2036,21 @@ class _Resolver:
|
|
|
2034
2036
|
return True
|
|
2035
2037
|
return False
|
|
2036
2038
|
|
|
2039
|
+
def _canonicalized_assignment(self, selected: NameComponents) -> NameComponents | None:
|
|
2040
|
+
"""Return ``selected`` with its initials canonicalized, or None when the normalizer rejects it."""
|
|
2041
|
+
|
|
2042
|
+
if not self._selected_has_personal_initials(selected):
|
|
2043
|
+
return selected
|
|
2044
|
+
normalized = self._source_normalizer.normalize_components(
|
|
2045
|
+
first_name=selected.given_name,
|
|
2046
|
+
middle_name=selected.middle_name,
|
|
2047
|
+
last_name=selected.surname,
|
|
2048
|
+
suffix=selected.suffix,
|
|
2049
|
+
)
|
|
2050
|
+
if normalized.outcome is not PersonNameOutcome.PERSON or normalized.canonical_name is None:
|
|
2051
|
+
return None
|
|
2052
|
+
return normalized.canonical_name.normalized
|
|
2053
|
+
|
|
2037
2054
|
def _source_assignment_resolution(
|
|
2038
2055
|
self,
|
|
2039
2056
|
*,
|
|
@@ -2045,25 +2062,17 @@ class _Resolver:
|
|
|
2045
2062
|
|
|
2046
2063
|
SOURCE non-assignment resolutions remain byte-exact. These assignments
|
|
2047
2064
|
already have proven semantic roles, but their source-derived components
|
|
2048
|
-
bypass the ordinary formatters.
|
|
2065
|
+
bypass the ordinary formatters. A terminal assignment the normalizer
|
|
2066
|
+
rejects (e.g. collaboration text a source put in the surname) is passed
|
|
2067
|
+
through as a non-person source instead of failing the whole paper; the
|
|
2068
|
+
reviewed-rule loop skips rejected rules instead (see
|
|
2069
|
+
``_reviewed_source_rules_resolution``).
|
|
2049
2070
|
"""
|
|
2050
2071
|
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
last_name=selected.surname,
|
|
2056
|
-
suffix=selected.suffix,
|
|
2057
|
-
)
|
|
2058
|
-
if normalized.outcome is not PersonNameOutcome.PERSON or normalized.canonical_name is None:
|
|
2059
|
-
message = f"source assignment could not be normalized: {selected!r}"
|
|
2060
|
-
raise RuntimeError(message)
|
|
2061
|
-
selected = normalized.canonical_name.normalized
|
|
2062
|
-
return ResolvedAuthorFields.from_selected_components(
|
|
2063
|
-
source=source,
|
|
2064
|
-
selected=selected,
|
|
2065
|
-
reason=reason,
|
|
2066
|
-
)
|
|
2072
|
+
canonical = self._canonicalized_assignment(selected)
|
|
2073
|
+
if canonical is None:
|
|
2074
|
+
return self._source_resolution(source, ResolutionReason.NON_PERSON_SOURCE_PASSTHROUGH)
|
|
2075
|
+
return ResolvedAuthorFields.from_selected_components(source=source, selected=canonical, reason=reason)
|
|
2067
2076
|
|
|
2068
2077
|
def _hard_scalar_resolution(
|
|
2069
2078
|
self,
|
|
@@ -2308,11 +2317,9 @@ class _Resolver:
|
|
|
2308
2317
|
)
|
|
2309
2318
|
hangul_assignment = reviewed_hangul_affiliation_person_assignment(source)
|
|
2310
2319
|
if hangul_assignment is not None:
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
selected=
|
|
2314
|
-
reason=pattern_reason,
|
|
2315
|
-
)
|
|
2320
|
+
canonical = self._canonicalized_assignment(hangul_assignment)
|
|
2321
|
+
if canonical is not None:
|
|
2322
|
+
return ResolvedAuthorFields.from_selected_components(source=source, selected=canonical, reason=pattern_reason)
|
|
2316
2323
|
middle_dot_assignment = reviewed_middle_dot_packed_transliteration_assignment(source)
|
|
2317
2324
|
if middle_dot_assignment is not None:
|
|
2318
2325
|
return ResolvedAuthorFields.from_selected_components(
|
|
@@ -2371,13 +2378,14 @@ class _Resolver:
|
|
|
2371
2378
|
)
|
|
2372
2379
|
for rule, reason in assignment_rules:
|
|
2373
2380
|
selected = rule()
|
|
2374
|
-
if selected is
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
+
if selected is None:
|
|
2382
|
+
continue
|
|
2383
|
+
canonical = self._canonicalized_assignment(selected)
|
|
2384
|
+
if canonical is None:
|
|
2385
|
+
# a pattern matched a shape the normalizer rejects ("E. / A. / and Solomon"): let the later
|
|
2386
|
+
# stages read the row instead of failing the whole paper
|
|
2387
|
+
continue
|
|
2388
|
+
return ResolvedAuthorFields.from_selected_components(source=source, selected=canonical, reason=reason)
|
|
2381
2389
|
return None
|
|
2382
2390
|
|
|
2383
2391
|
def _reviewed_cleanup_resolution(
|
|
@@ -2710,12 +2718,6 @@ class _Resolver:
|
|
|
2710
2718
|
if capped is not None:
|
|
2711
2719
|
reason = ResolutionReason.VYS_GIVEN_CHAIN_CAP_INPUT if vys else ResolutionReason.GIVEN_CHAIN_CAP_INPUT
|
|
2712
2720
|
parsed, batch_reason = capped, reason
|
|
2713
|
-
prior_parsed = (
|
|
2714
|
-
_corpus_order_prior_parsed(parsed, raw_name, POOL_PRIOR_MIN_SHARE) if decision in ("pp", "vys") else None
|
|
2715
|
-
)
|
|
2716
|
-
if prior_parsed is not None:
|
|
2717
|
-
reason = ResolutionReason.VYS_CORPUS_ORDER_PRIOR_ASSIGNMENT if vys else ResolutionReason.CORPUS_ORDER_PRIOR_ASSIGNMENT
|
|
2718
|
-
parsed, batch_reason = prior_parsed, reason
|
|
2719
2721
|
return self.terminal_resolution(
|
|
2720
2722
|
source=source,
|
|
2721
2723
|
paper_authors=paper_authors,
|
|
@@ -4,6 +4,8 @@ Each case is a structured source exactly as the author-refresh backfill sent it
|
|
|
4
4
|
reviewer-confirmed correct fields.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
import unicodedata
|
|
8
|
+
|
|
7
9
|
import pytest
|
|
8
10
|
|
|
9
11
|
from sinonym.coretypes.routing_resolution import ResolutionProvenance, ResolutionReason
|
|
@@ -66,18 +68,34 @@ def test_scalar_baseline_still_canonicalizes_initials_without_moving_boundary(pr
|
|
|
66
68
|
assert resolve(predictor, "J", None, "Smith") == ("J.", "", "Smith")
|
|
67
69
|
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
#
|
|
71
|
-
|
|
72
|
-
(("
|
|
73
|
-
(("
|
|
74
|
-
|
|
75
|
-
(("
|
|
71
|
+
DECOMPOSED_ACCENT_CASES = [
|
|
72
|
+
# names written in NFD (each accent a combining mark after its letter); adjacent accented letters and stacked
|
|
73
|
+
# marks used to be moved onto the neighbouring letter (Dvořaḱ, Núnẽz, Nguyêñ)
|
|
74
|
+
(("Antonín", None, "Dvořák"), ("Antonín", "", "Dvořák")),
|
|
75
|
+
(("José", None, "Núñez"), ("José", "", "Núñez")),
|
|
76
|
+
(("Jiří", None, "Kořínek"), ("Jiří", "", "Kořínek")),
|
|
77
|
+
(("Aracelis", None, "Calzadilla-Núñez"), ("Aracelis", "", "Calzadilla-Núñez")),
|
|
78
|
+
(("Văn", None, "Nguyễn"), ("Văn", "", "Nguyễn")),
|
|
76
79
|
]
|
|
77
80
|
|
|
78
81
|
|
|
79
|
-
@pytest.mark.parametrize(("source", "expected"),
|
|
80
|
-
def
|
|
82
|
+
@pytest.mark.parametrize(("source", "expected"), DECOMPOSED_ACCENT_CASES)
|
|
83
|
+
def test_decomposed_accents_stay_on_their_letters(predictor, source, expected):
|
|
84
|
+
decomposed = tuple(unicodedata.normalize("NFD", part) if part else part for part in source)
|
|
85
|
+
assert tuple(unicodedata.normalize("NFC", part) for part in resolve(predictor, *decomposed)) == expected
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_stacked_dot_marks_are_kept_as_written(predictor):
|
|
89
|
+
# Turkish names with a dotted capital plus combining dots used to have a dot moved onto the next letter (İ̇ṡmail)
|
|
90
|
+
assert resolve(predictor, "İ̇̇smail", None, "Sağir") == ("İ̇̇smail", "", "Sağir")
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@pytest.mark.parametrize(("source", "expected"), [
|
|
94
|
+
(("John", None, "Smith^1"), ("John", "", "Smith^1")),
|
|
95
|
+
(("Mazen`", None, "Abdalla"), ("Mazen'", "", "Abdalla")),
|
|
96
|
+
])
|
|
97
|
+
def test_ascii_caret_and_backtick_are_not_accents(predictor, source, expected):
|
|
98
|
+
# a caret footnote or a backtick used as an apostrophe used to become an accent (Smitĥ, Mazeǹ)
|
|
81
99
|
assert resolve(predictor, *source) == expected
|
|
82
100
|
|
|
83
101
|
|
|
@@ -295,7 +313,7 @@ ORDER_PRIOR_CASES = [
|
|
|
295
313
|
(("Chen", None, "Hong"), ("Hong", "", "Chen")),
|
|
296
314
|
(("Lu", None, "Rong"), ("Rong", "", "Lu")),
|
|
297
315
|
# on abstain the source order stands even against the corpus majority: there the prior broke 19,574 registered
|
|
298
|
-
# surnames and fixed 2,275 (ORCID
|
|
316
|
+
# surnames and fixed 2,275 (ORCID registry)
|
|
299
317
|
(("Lu", None, "Xi"), ("Lu", "", "Xi")),
|
|
300
318
|
(("Gong", None, "Lei"), ("Gong", "", "Lei")),
|
|
301
319
|
(("Liu", None, "Yang"), ("Liu", "", "Yang")),
|
|
@@ -320,9 +338,12 @@ def test_corpus_order_prior_reason_is_reported(predictor):
|
|
|
320
338
|
assert author.resolution_reason.value == "corpus_order_prior_assignment"
|
|
321
339
|
|
|
322
340
|
|
|
323
|
-
def
|
|
324
|
-
#
|
|
325
|
-
|
|
341
|
+
def test_corpus_order_prior_applies_without_a_pool_below_the_old_pool_bar(predictor):
|
|
342
|
+
# the corpus writes Jing Yu 82% of the time: below the 86% bar 0.6.0 used with a pool, above the 80% no-pool bar
|
|
343
|
+
instance = Instance(pp_authors=[SourceAuthorFields(first_name="Jing", last_name="Yu")])
|
|
344
|
+
author = predictor.predict_batch([instance])[0].authors[0]
|
|
345
|
+
assert author.resolution_reason == ResolutionReason.CORPUS_ORDER_PRIOR_ASSIGNMENT
|
|
346
|
+
assert (author.first_name, author.last_name) == ("Jing", "Yu")
|
|
326
347
|
|
|
327
348
|
|
|
328
349
|
@pytest.mark.parametrize("surname", ["Efendi̇oğlu", "Çi̇ner", "Yerlikaya Aydemi̇r"])
|
|
@@ -644,12 +665,88 @@ def test_order_prior_does_not_override_a_router_decision_made_with_a_venue_pool(
|
|
|
644
665
|
assert with_pool.resolution_reason != ResolutionReason.CORPUS_ORDER_PRIOR_ASSIGNMENT
|
|
645
666
|
|
|
646
667
|
|
|
647
|
-
def
|
|
648
|
-
# a
|
|
668
|
+
def test_order_prior_does_not_rewrite_a_vys_pick(predictor):
|
|
669
|
+
# with a venue pool the router's pick stands against the corpus majority; this source wrote `Zhou YI`, so Yi is the
|
|
670
|
+
# surname, and 0.6.0's prior flipped it
|
|
649
671
|
byline = list(VYS_PRIOR_BYLINE)
|
|
650
|
-
byline[5] = ("
|
|
672
|
+
byline[5] = ("Zhou", "Yi")
|
|
651
673
|
authors = [SourceAuthorFields(first_name=first, last_name=last) for first, last in byline]
|
|
652
674
|
author = predictor.predict_batch([Instance(pp_authors=authors, vys_other_names=VYS_PRIOR_POOL)])[0].authors[5]
|
|
653
|
-
assert (author.first_name, author.last_name) == ("
|
|
654
|
-
assert author.resolution_reason == ResolutionReason.
|
|
675
|
+
assert (author.first_name, author.last_name) == ("Zhou", "Yi")
|
|
676
|
+
assert author.resolution_reason == ResolutionReason.VYS_SELECTED
|
|
655
677
|
assert author.resolution_provenance == ResolutionProvenance.VYS
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
def test_order_prior_does_not_rewrite_a_pp_pick_made_with_a_venue_pool(predictor):
|
|
681
|
+
# as above for a PP pick: this source wrote `Sun XU`, so Xu is the surname, and 0.6.0's prior flipped it
|
|
682
|
+
byline = list(VYS_PRIOR_BYLINE)
|
|
683
|
+
byline[5] = ("Sun", "Xu")
|
|
684
|
+
authors = [SourceAuthorFields(first_name=first, last_name=last) for first, last in byline]
|
|
685
|
+
author = predictor.predict_batch([Instance(pp_authors=authors, vys_other_names=VYS_PRIOR_POOL)])[0].authors[5]
|
|
686
|
+
assert (author.first_name, author.last_name) == ("Sun", "Xu")
|
|
687
|
+
assert author.resolution_reason == ResolutionReason.PP_SELECTED
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
def test_rejected_source_assignment_keeps_the_paper(predictor):
|
|
691
|
+
# a source put collaboration text in one surname; that author is passed through as written and the paper still resolves
|
|
692
|
+
authors = [
|
|
693
|
+
SourceAuthorFields(first_name="Heba", last_name="Bintalib"),
|
|
694
|
+
SourceAuthorFields(first_name="S", middle_names="Hamza", last_name="Abbas"),
|
|
695
|
+
SourceAuthorFields(first_name="Klaus", last_name="Warnatz"),
|
|
696
|
+
SourceAuthorFields(first_name="John", middle_names="R", last_name="Hurst (and On Behalf Of The Eglildnet Consort"),
|
|
697
|
+
]
|
|
698
|
+
rows = predictor.predict_batch([Instance(pp_authors=authors)])[0].authors
|
|
699
|
+
assert len(rows) == 4
|
|
700
|
+
assert [(r.first_name, r.last_name) for r in rows[:3]] == [("Heba", "Bintalib"), ("S.", "Abbas"), ("Klaus", "Warnatz")]
|
|
701
|
+
assert (rows[3].first_name, rows[3].middle_names, rows[3].last_name) == (
|
|
702
|
+
"John",
|
|
703
|
+
"R",
|
|
704
|
+
"Hurst (and On Behalf Of The Eglildnet Consort",
|
|
705
|
+
)
|
|
706
|
+
assert rows[3].resolution_reason == ResolutionReason.NON_PERSON_SOURCE_PASSTHROUGH
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
def test_rejected_given_phrase_assignment_is_passed_through(predictor):
|
|
710
|
+
author = predictor.predict_batch(
|
|
711
|
+
[Instance(pp_authors=[SourceAuthorFields(first_name="M.", middle_names="del Carmen", last_name="Garcia Lopez 1,2")])],
|
|
712
|
+
)[0].authors[0]
|
|
713
|
+
assert (author.first_name, author.middle_names, author.last_name) == ("M.", "del Carmen", "Garcia Lopez 1,2")
|
|
714
|
+
assert author.resolution_reason == ResolutionReason.NON_PERSON_SOURCE_PASSTHROUGH
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
def test_rejected_reviewed_rule_pick_keeps_the_author(predictor):
|
|
718
|
+
# a reviewed pattern matches but the normalizer rejects its pick: the rule is skipped and the author is still written
|
|
719
|
+
instance = Instance(pp_authors=[SourceAuthorFields(first_name="E.A.", last_name="and Solomon")])
|
|
720
|
+
author = predictor.predict_batch([instance])[0].authors[0]
|
|
721
|
+
assert (author.first_name, author.middle_names, author.last_name) == ("E.A.", "", "and Solomon")
|
|
722
|
+
assert author.resolution_reason == ResolutionReason.NON_PERSON_SOURCE_PASSTHROUGH
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
def test_rejected_hangul_affiliation_pick_does_not_fail_the_paper(predictor):
|
|
726
|
+
source = SourceAuthorFields(first_name="MD", middle_names="PhD 서울대학교", last_name="J University")
|
|
727
|
+
author = predictor.predict_batch([Instance(pp_authors=[source])])[0].authors[0]
|
|
728
|
+
assert (author.first_name, author.middle_names, author.last_name) == ("MD", "PhD 서울대학교", "J University")
|
|
729
|
+
assert author.resolution_reason == ResolutionReason.NON_PERSON_SOURCE_PASSTHROUGH
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
def test_reviewed_roster_check_is_skipped_for_papers_of_other_sizes(predictor, monkeypatch):
|
|
733
|
+
# the roster rule runs once per author; building its roster key on every author of a large paper is quadratic
|
|
734
|
+
from sinonym.timo import _resolution # noqa: PLC0415
|
|
735
|
+
|
|
736
|
+
key_calls = []
|
|
737
|
+
original_key = _resolution._source_component_key # noqa: SLF001
|
|
738
|
+
monkeypatch.setattr(_resolution, "_source_component_key", lambda s: key_calls.append(s) or original_key(s))
|
|
739
|
+
keys_per_rule_call = []
|
|
740
|
+
original = _resolution._reviewed_paper_wide_trailing_affiliation_assignment # noqa: SLF001
|
|
741
|
+
|
|
742
|
+
def counting(source, paper_authors, normalizer, surname_is_recognized):
|
|
743
|
+
before = len(key_calls)
|
|
744
|
+
result = original(source, paper_authors, normalizer, surname_is_recognized)
|
|
745
|
+
keys_per_rule_call.append(len(key_calls) - before)
|
|
746
|
+
return result
|
|
747
|
+
|
|
748
|
+
monkeypatch.setattr(_resolution, "_reviewed_paper_wide_trailing_affiliation_assignment", counting)
|
|
749
|
+
authors = [SourceAuthorFields(first_name=f"Given{i}", last_name=f"Surname{i}") for i in range(50)]
|
|
750
|
+
predictor.predict_batch([Instance(pp_authors=authors)])
|
|
751
|
+
assert len(keys_per_rule_call) == 50
|
|
752
|
+
assert sum(keys_per_rule_call) == 0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|