Skip to content

Fix CJK-collapsing concept node ids in the graph builder#3

Open
SungFeng-Huang wants to merge 1 commit into
voidful:mainfrom
SungFeng-Huang:fix/cjk-node-ids
Open

Fix CJK-collapsing concept node ids in the graph builder#3
SungFeng-Huang wants to merge 1 commit into
voidful:mainfrom
SungFeng-Huang:fix/cjk-node-ids

Conversation

@SungFeng-Huang

Copy link
Copy Markdown

Bug

The inline slug pattern [^a-zA-Z0-9_]_ in scripts/hungyi_graph.py maps every CJK character to an underscore, so all same-length Chinese concepts collapse into one node id:

  • 語言模型, 機器學習, 深度學習, 語音辨識, 語音合成, … all slug to concept_____-style ids (only the length varies)
  • the shipped wiki/graph/graph.json contains 4 such collapsed buckets, each silently merging many distinct concepts — the node label is just whichever concept was written last, and graph query for a Chinese term returns a mixed-up node

Fix

Extract a CJK-preserving slug() helper — keep ASCII alphanumerics plus kana (U+3040–30FF), CJK ideographs (incl. Ext-A) and compatibility ideographs, collapse everything else to single underscores — and use it at all six node-id sites (4 concept, 2 series).

After rebuilding: the 4 collapsed buckets become 16 distinct CJK concept nodes (+12 recovered concepts), and e.g. graph query "語音辨識" resolves to its own node with sensible neighbors.

Notes

  • Tracked wiki/graph outputs are intentionally not regenerated in this PR to keep the diff reviewable — they refresh on the next python3 scripts/hungyi_kb.py graph build.
  • ASCII ids also normalize slightly (runs of separators collapse to a single _, edges stripped): safe because node ids are rebuilt from source on every graph build and never persisted across builds.
  • Independent of Fix requirements for a working fresh install (networkx>=3.4, add yt-dlp) #2.

The inline slug pattern [^a-zA-Z0-9_] -> '_' maps every CJK character to
an underscore, so all same-length Chinese concepts collapse into ONE node
id: 語言模型 / 機器學習 / 深度學習 / 語音辨識 / 語音合成 ... all become
concept_____ and overwrite each other (the shipped graph has 4 such
collapsed buckets, each silently merging many distinct concepts).

Extract a CJK-preserving slug() helper — keep ASCII alphanumerics plus
kana, CJK ideographs (incl. Ext-A) and compatibility ideographs; collapse
everything else to single underscores — and use it at all six node-id
sites (4 concept, 2 series). Rebuilding the graph after this fix: the 4
collapsed buckets become 16 distinct CJK concept nodes (+12 recovered
concepts), and graph query resolves e.g. 語音辨識 to its own node.

Tracked wiki/graph outputs are intentionally NOT regenerated here to keep
the diff reviewable — they refresh on the next `graph build`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SungFeng-Huang added a commit to SungFeng-Huang/hung-yi-lee-skill that referenced this pull request Jul 6, 2026
Branch layout (mirror main / PR-clean fix branches / integration), the
generic feature set (CJK node fix -> PR voidful#3, external corpus + provenance,
alignment layer + miner, portability/sanitize, conda wiring), and the
explicit non-goal: personal integration glue stays outside this fork —
only the generic external-corpus contract ships here.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SungFeng-Huang added a commit to SungFeng-Huang/hung-yi-lee-skill that referenced this pull request Jul 8, 2026
Branch layout (mirror main / PR-clean fix branches / integration), the
generic feature set (CJK node fix -> PR voidful#3, external corpus + provenance,
alignment layer + miner, portability/sanitize, conda wiring), and the
explicit non-goal: personal integration glue stays outside this fork —
only the generic external-corpus contract ships here.

Co-Authored-By: Claude Fable 5 <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