Skip to content

fix: improve headword reconciliation for pinyin variants - #7

Open
tofutim wants to merge 1 commit into
developfrom
feature/issue-6-investigate-bad-definition-for
Open

tofutim wants to merge 1 commit into
developfrom
feature/issue-6-investigate-bad-definition-for

Conversation

@tofutim

@tofutim tofutim commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

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). The reconcile_headwords function only handled u:/ü normalization, not spacing or tone-number formatting differences.

Findings:

  • 29,972 duplicate headword pairs in dictmaster.db (same traditional+simplified, different pinyin formatting)
  • 12,472 Arabic MiniMax translations contain Latin characters (e.g. جسيمAspect — Arabic+English concatenated)
  • Other bad MiniMax translations: Vietnamese trạng từ (means "adverb", not "aspect particle"), truncated Thai, garbled Farsi

Changes:

  • New _pinyin_merge_key() normalizes spaces, hyphens, tone numbers, and u:/ü to produce a canonical merge key
  • Rewritten reconcile_headwords() uses merge-key grouping (handles >2 variants per headword, also merges dialect_forms)
  • New find_bad_translations() detects Latin-character contamination in non-Latin script languages
  • 10 new tests covering spacing variants, hyphens, tone merging, case preservation

Test plan

  • All 37 merge tests pass (10 new)
  • All 193 dictmaster tests pass
  • No regressions in non-FTS tests (223 passed)
  • Run reconcile_headwords on production dictmaster.db to verify duplicate reduction
  • Run find_bad_translations to get full count of flagged entries for future cleanup

Closes #6

🤖 Generated with Claude Code

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>
tofutim added a commit that referenced this pull request Aug 11, 2026
…ht framing

ARR October 2026 revision, Tier 2 items #5 (English-pivot ablation) and
#6 (per-language error taxonomy), plus framing tweaks and Future Work
paragraph on native-speaker evaluation.

Content additions:

§5.4 (new)
  * Pivot ablation paragraph reporting Llama-3.3-70B (open-weight, Groq)
    with vs. without English pivot on 50 headwords each in vi + th.
    Vietnamese: pivot CometKiwi 0.568 vs. direct 0.502 (Δ +0.067);
    Thai:       pivot 0.520          vs. direct 0.526 (Δ +0.006).
    Finding: pivot bias is language-dependent, not uniform quality loss.
    Directly addresses AC pivot criticism + gKVr Anglocentric bias.

§5.5 (new)
  * Per-language error-taxonomy pointer to Appendix~C's full 18-lang
    table (mono-gloss rate, mean segments, median length, CJK-inclusion,
    zh-echo). Addresses AC error analysis + gKVr per-lang breakdown +
    cky5 hallucination ask.

Appendix~C: tab:error-taxonomy — full 18-lang breakdown.

Framing (Task #7 in revision plan):
  * Abstract, §1 intro, §6 Limitations, §7 Conclusion: replaced
    "single commercial LLM" and "single LLM" wordings with "single
    open-weight LLM (MiniMax M2.5)", noting Fireworks/NIM third-party
    hosting supports reproducibility. Reframes gKVr's "single
    proprietary model" as partly a paper-clarity issue.

§7 Future Work:
  * Native-speaker eval paragraph: explicitly acknowledged as
    gold-standard validation that requires per-language recruitment
    funding beyond the pipeline's $150 API cost; the model-based
    semantic metrics in §5.2-§5.3 are the strongest automated proxy.
    Preempts reviewer criticism for what we're deferring.

Layout:
  * tab:comparison widened from 5 to 7 columns (BSc F1 + COMET-DA);
    compressed column widths and dropped % symbols in numeric cells
    to fit single-column tabular. Renders cleanly (overfull hbox
    ~4pt, cosmetic).
  * Conclusion compressed to a single tighter paragraph so body stays
    within 8 ACL pages.
  * §1 removed historical "Dictionario Hispanico Sinicum" decoration
    sentence + Under-resourced-languages example enumeration in §7 to
    reclaim space.

Final: 11 pages total, 8 body pages (ACL-compliant), 3 pages
references + appendices. lualatex + bibtex + 2× lualatex clean.

#8 (open-weight second-model verification via Gemma-4-31B on Cerebras
free tier) is running in a background job; the corresponding §5.6 and
tab:verify addition will land in a follow-up commit with the release
bump.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant