Japanese Deinflector is a static, browser-based Japanese morphology explorer. It is built around a reverse deinflection engine that walks an inflected surface form back through explicit intermediate steps instead of jumping straight from the surface to a dictionary entry.
The app is designed to be explainable, offline-friendly, and easy to deploy as a plain static site.
- Analyzes inflected Japanese forms and short fixed-pattern phrases
- Shows explicit intermediate chain steps such as
食べる → 食べさせる → 食べさせられる - Renders entry cards with headword, reading, alternate spellings, grammar line, and sense list
- Uses learner-facing tooltip copy for inflection nodes
- Highlights common parses with a star badge
- Ships with an offline JMdict-derived lexicon plus a small morphology supplement
- Works entirely as a static front-end once the built files are served
Example chain:
やめる → やめて → やめておく → やめとく → やめとけ
- React 18
- TypeScript
- Vite
- Custom reverse morphology engine
- Vitest + Testing Library
- JMdict / EDRDG-derived lexicon data
Install dependencies:
npm installStart the dev server:
npm run devType-check:
npm run checkRun tests:
npm run test:runBuild the production bundle:
npm run buildPreview the built static site locally:
npm run previewnpm run build produces a fully static site in dist/.
Typical output includes:
dist/index.htmldist/assets/index-*.jsdist/assets/index-*.cssdist/data/lexicon.generated.json
Important notes:
dist/is generated output, not source.dist/is ignored by.gitignorein this repository.- You generally should not hand-edit anything inside
dist/. - For source control, commit the source files plus
public/data/lexicon.generated.json, not the generateddist/directory. - For deployment to a generic static host, upload the contents of
dist/.
Vite is configured with:
base: '/'duringvite servebase: './'duringvite build
That means the built app uses relative asset URLs, so serving dist/ directly works both for local static servers and when the bundle is hosted from a subdirectory.
The checked-in runtime lexicon source lives at:
public/data/lexicon.generated.json
During the production build, Vite copies that file into:
dist/data/lexicon.generated.json
The project also ships a small supplement in:
src/data/lexiconSupplement.ts
This supplement covers morphology-critical helper entries such as:
だないいるおくそうそうだみたいだ
Regenerate the bundled lexicon from a local JMdict snapshot with:
npm run build:lexicon -- /path/to/JMdict_e.gzIf no path is provided, the script defaults to:
/tmp/JMdict_e.gz
JMdict / EDRDG references:
- Source: https://www.edrdg.org/jmdict/j_jmdict.html
- License: https://www.edrdg.org/edrdg/licence.html
The app currently ships these example searches:
やめとけ食べさせられなかった行かされていたやめさせられちゃった見られなくなってきた行っておかなきゃ読んどいてくれ行けなくはない食べないではいられない行かざるを得ない見ないわけにはいかない食べられなくもないしなければならなかったさせられっぱなし行っとけばよかったではありませんでしたじゃなくて高くなきゃいけない食べさせといて見ていられない
The current rule set covers a fairly broad slice of common learner-facing morphology, including:
- Ichidan, godan,
する,来る, and行くbehavior where special handling is needed - Core verb inflections such as negative, past, polite, imperative, volitional, potential, passive, causative, and desiderative
- Conjunctive chaining through
て / で - Auxiliary chains such as
いる,おく,しまう,くる, andなる - Common contractions such as
てる,とく,といて,ちゃう,じゃ, andなきゃ - I-adjective connective and obligation-building patterns
- Copula chains such as
だ,です,でした,では,ではありません,ではありませんでした,じゃない, andじゃなくて - Fixed patterns such as:
- obligation
- internal compulsion
- external compulsion
- soft double negation
- regret / hindsight via conditional
よいplus past - request
- hearsay
- seeming / appearance
っぱなし
The project intentionally prefers transparent intermediate analysis over maximal compression.
Key files:
src/morphology/rules.tsDeclarative reverse rules for inflection, auxiliaries, fixed patterns, and contractions.src/morphology/analysis.tsReverse search, path ranking, analyzable chunk selection, and graph construction.src/morphology/tooltips.tsTooltip titles and learner-facing explanation copy for node labels.src/morphology/pathLabels.tsUI-facing label formatting for inflection edges.src/morphology/examples.tsBuilt-in example list and expected example paths.src/morphology/lexicon.tsRuntime lexicon loading and indexing.src/components/GraphView.tsxResult grouping, entry-card rendering, inflection-chain rendering, and tooltip behavior.src/app/App.tsxTop-level app shell, search state, example picker, and lexicon loading.src/styles.cssApp styling, responsive layout, tooltip presentation, and mobile behavior.scripts/buildLexicon.tsJMdict-to-runtime JSON conversion script.
The test suite currently covers:
- engine-level deinflection path expectations
- invalid chain prevention
- regression cases for impossible stacks
- UI rendering for paths, labels, tooltips, examples, and empty states
Main test files:
src/morphology/__tests__/engine.test.tssrc/app/App.test.tsx
Before pushing, the important files to keep are:
- source under
src/ public/data/lexicon.generated.jsonscripts/buildLexicon.tspackage.jsonpackage-lock.jsonvite.config.tstsconfig.jsonREADME.md
Generated files you typically should not commit:
dist/node_modules/- coverage or cache directories
The analyzer is intentionally conservative. Known limitations include:
- honorific and humble systems are not modeled comprehensively
- sentence segmentation remains lightweight and focuses on the analyzable chunk
- dialect-heavy colloquials are only partially covered
- coverage is strongest for common educational morphology, not every literary or highly idiomatic construction
- some ambiguous surfaces still legitimately produce multiple plausible paths
When extending the project:
- update
src/morphology/rules.ts - add or update tests in
src/morphology/__tests__/engine.test.ts - update tooltip copy in
src/morphology/tooltips.tsif a new learner-facing node appears - update
src/morphology/pathLabels.tsif the UI label should differ from the internal rule label - update
src/morphology/examples.tsif the new behavior deserves a built-in showcase or regression example - regenerate
public/data/lexicon.generated.jsononly if the lexicon itself changed
Rule-authoring guidelines:
- Prefer explicit intermediate steps over shortcut analyses.
- Model contractions as their own edges when that improves teachability.
- Avoid impossible morphological stacks even if they produce superficially neat paths.
- Keep tooltip copy independently instructive and learner-friendly.