How morgan1998/kanji-wizard-data-pipeline works
Purpose
A Node.js data-processing repository that builds enriched Japanese kanji/vocabulary datasets, likely for TSV export and Anki-style study material. It combines kanji, JMdict-derived vocabulary, JLPT classifications, and vocabulary-frequency data from the cited upstream sources.
Entry Points and Operations
• src/index.js is the likely CLI/application entry point, with argument handling in src/utils/cli-parser.js.
• src/pipeline.js coordinates the processing stages.
• src/build-tsv.js provides the output-building path.
• scripts/download-data.js obtains or refreshes required source datasets before processing.
Input Loading Boundary
Source-specific loaders normalize external dataset files into internal records:
• src/io/loaders/kanji-loader.js
• src/io/loaders/vocab-loader.js
• src/io/loaders/associated-vocab-jlpt-map-loader.js
• src/io/loaders/associated-vocab-frequency-map-loader.js
This boundary isolates differences among kanji data, dictionary vocabulary, JLPT vocabulary lists, and frequency datasets.
Vocabulary Analysis and Association
Vocabulary is tokenized and connected back to kanji:
• src/processors/tokenizers/vocab-tokenizer.js
• src/services/morphology.js
• src/processors/enrichers/kanji-associated-vocab-assigner.js
The morphology service is the linguistic-analysis boundary; tokenization results enable the pipeline to determine which vocabulary entries are associated with each kanji rather than relying only on raw string matching.
Enrichment Stages
The pipeline augments associated vocabulary with study-relevant metadata:
• src/processors/enrichers/associated-vocab-jlpt-assigner.js
• src/processors/enrichers/associated-vocab-frequency-assigner.js
• types/kanji-entry-schema.ts
JLPT and frequency maps are applied to vocabulary associated with each kanji. The TypeScript schema defines the intended structure of the final kanji-entry model, even though runtime code is JavaScript.
Selection and Output
Filtering constrains generated records before serialization:
• src/processors/filterers/jlpt-filterer.js
• src/processors/filterers/frequency-filterer.js
• src/io/writer.js
Control flow is: acquire source data → load/normalize records and lookup maps → tokenize vocabulary → associate vocabulary to kanji → enrich with JLPT/frequency metadata → filter → build/write TSV output.
External Data and Infrastructure
The repository depends on downloadable public datasets rather than a hosted application backend: JLPT kanji data, JMdict-simplified vocabulary, JLPT vocabulary classifications, and JPDB/Yomitan-derived frequency information. Runtime infrastructure is local Node.js execution with filesystem-based input/output; no web server or database is indicated by the tree.
Main entry points: download-data.js Dataset downloader · pipeline.js Processing pipeline · kanji-loader.js Kanji loader · vocab-loader.js Vocabulary loader
Components 19
Data acquisition
- Dataset downloader · Refreshes public source datasets locally.
scripts/download-data.js - Public source datasets · Kanji, JMdict vocabulary, JLPT lists, and frequency data.
Input normalization
- Kanji loader
src/io/loaders/kanji-loader.js - Vocabulary loader · Normalizes JMdict-derived vocabulary.
src/io/loaders/vocab-loader.js - JLPT map loader
src/io/loaders/associated-vocab-jlpt-map-loader.js - Frequency map loader
src/io/loaders/associated-vocab-frequency-map-loader.js
Processing pipeline
- CLI entry point
src/index.js - Argument parser
src/utils/cli-parser.js - Processing pipeline
src/pipeline.js - Vocabulary tokenizer
src/processors/tokenizers/vocab-tokenizer.js - Morphology service · Provides token analysis used for kanji association.
src/services/morphology.js - Kanji-vocabulary association
src/processors/enrichers/kanji-associated-vocab-assigner.js - JLPT enrichment
src/processors/enrichers/associated-vocab-jlpt-assigner.js - Frequency enrichment
src/processors/enrichers/associated-vocab-frequency-assigner.js - Kanji entry schema · Defines the final enriched kanji-entry model.
types/kanji-entry-schema.ts
Selection and export
- JLPT filter
src/processors/filterers/jlpt-filterer.js - Frequency filter
src/processors/filterers/frequency-filterer.js - TSV builder
src/build-tsv.js - TSV writer · Writes generated study-material data to local files.
src/io/writer.js
Connections 24
- Public source datasets → Dataset downloader: downloaded by
- Dataset downloader → Kanji loader: local kanji data
- Dataset downloader → Vocabulary loader: local vocabulary data
- Dataset downloader → JLPT map loader: local JLPT lists
- Dataset downloader → Frequency map loader: local frequency data
- CLI entry point → Argument parser: parses options
- CLI entry point → Processing pipeline: runs
- Processing pipeline → Kanji loader: loads kanji
- Processing pipeline → Vocabulary loader: loads vocabulary
- Processing pipeline → JLPT map loader: loads JLPT map
- Processing pipeline → Frequency map loader: loads frequency map
- Vocabulary loader → Vocabulary tokenizer: vocabulary records
- Vocabulary tokenizer → Morphology service: analyzes tokens
- Morphology service → Kanji-vocabulary association: token analysis
- Kanji loader → Kanji-vocabulary association: kanji records
- Kanji-vocabulary association → JLPT enrichment: associated vocabulary
- JLPT map loader → JLPT enrichment: JLPT lookup
- JLPT enrichment → Frequency enrichment: enriched entries
- Frequency map loader → Frequency enrichment: frequency lookup
- Frequency enrichment → JLPT filter: enriched kanji entries
- JLPT filter → Frequency filter: JLPT-selected entries
- Frequency filter → TSV builder: selected entries
- Kanji entry schema → TSV builder: output model
- TSV builder → TSV writer: TSV content