budoux icon indicating copy to clipboard operation
budoux copied to clipboard

feat(js): add loadDefaultJapaneseWordParser() and expose ja_word in loadDefaultParsers()

Open codeXsidd opened this issue 1 month ago • 1 comments

Problem

The ja_word model is bundled and exported from the JavaScript package, but it lacks the convenience loader function and is missing from the loadDefaultParsers() map, making it inaccessible via the CLI's -l flag.

Current Behavior

index.ts exports jaWordModel (the raw model object) but provides no loadDefaultJapaneseWordParser() convenience function. All other four models have one:

  • loadDefaultJapaneseParser() → uses ja.json
  • loadDefaultSimplifiedChineseParser() → uses zh-hans.json
  • loadDefaultTraditionalChineseParser() → uses zh-hant.json
  • loadDefaultThaiParser() → uses h.json
  • ja_word — no loader function exists

Additionally, loadDefaultParsers() hardcodes only four language entries (ja, zh-hans, zh-hant, h). As a result, the CLI flag -l ja_word\ silently falls back to the default Japanese parser instead of using the word-level model.

The Python CLI supports -l ja_word\ through dynamic filesystem discovery of all .json\ files in the models directory. The JavaScript CLI has no equivalent path.

Expected Behavior

  • A loadDefaultJapaneseWordParser() function should be exported from index.ts, consistent with the pattern for all other default parsers.
  • loadDefaultParsers() should include the 'ja_word' entry so that the CLI flag -l ja_word\ works correctly.
  • The ja_word entry should be listed in the CLI's --help\ output under available languages.

Reproduction

\\ s import { loadDefaultParsers } from 'budoux'; const parsers = loadDefaultParsers(); console.log(parsers.has('ja_word')); // false — should be true \\

Or via CLI: \\ash budoux -l ja_word '今日は天気です。'

Falls back silently to ja model instead of ja_word

\\

Technical Context

codeXsidd avatar Nov 02 '26 16:11 codeXsidd

Closing as not planned — please see https://github.com/google/budoux/pull/1489 for details on how experimental models like ja_word are scoped.

tushuhei avatar Nov 03 '26 11:11 tushuhei