fix: improve headword reconciliation for pinyin variants#7
Open
tofutim wants to merge 1 commit into
Open
Conversation
The reconciliation logic only handled u:/ü normalization, missing the much larger class of duplicates caused by different pinyin formatting between sources (CC-CEDICT char-level "dong4 tai4 zhu4 ci2" vs Wiktextract word-level "dongtai4 zhuci2"). This caused 動態助詞 and ~29K other entries to appear as duplicates with separate definitions. Changes: - Add _pinyin_merge_key() that strips spaces, hyphens, tone numbers, and parenthesized annotations to produce a canonical merge key - Rewrite reconcile_headwords() to use merge-key grouping instead of pairwise SQL comparison (handles >2 variants per headword) - Also merge dialect_forms when consolidating headwords - Add find_bad_translations() to detect MiniMax quality issues (Latin characters in non-Latin script languages like Arabic) - Add 10 new tests covering spacing variants, hyphens, tone merging, case preservation, and the _pinyin_merge_key function Closes #6 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Investigates and fixes the bad definition for 動態助詞 reported in #6.
Root cause: The dictionary had two separate entries for 動態助詞 — one from CC-CEDICT (
dong4 tai4 zhu4 ci2, character-level pinyin) and one from Wiktextract (dongtai4 zhuci2, word-level pinyin). Thereconcile_headwordsfunction only handledu:/ünormalization, not spacing or tone-number formatting differences.Findings:
جسيمAspect— Arabic+English concatenated)trạng từ(means "adverb", not "aspect particle"), truncated Thai, garbled FarsiChanges:
_pinyin_merge_key()normalizes spaces, hyphens, tone numbers, andu:/üto produce a canonical merge keyreconcile_headwords()uses merge-key grouping (handles >2 variants per headword, also merges dialect_forms)find_bad_translations()detects Latin-character contamination in non-Latin script languagesTest plan
reconcile_headwordson production dictmaster.db to verify duplicate reductionfind_bad_translationsto get full count of flagged entries for future cleanupCloses #6
🤖 Generated with Claude Code