hexenq / kuroshiro

Japanese language library for converting Japanese sentence to Hiragana, Katakana or Romaji with furigana and okurigana modes supported.
https://kuroshiro.org
MIT License
781 stars 88 forks source link

Change to sync #74

Open lvl99 opened 4 years ago

lvl99 commented 4 years ago

In reference to #50 :

I've made a quick stab at turning kuroshiro (and kuroshiro-analyzer-kuromoji) sync, and I found that the dependency kuromoji has lag when building the data files so requires callback/promise when initialising kuroshiro/kuroshiro-analyzer-kuromoji -- since @hexenq stated that other analyzers need to be async (although I haven't looked at those analyzers nor do I know if they require async parse), this is not a blocking issue to going sync IMO.

My exploration was mainly to see if it is easy enough to change the kuroshiro.convert to sync (it is at least with kuroshiro-analyzer-kuromoji). I would maybe advocate for creating additional functions with a Sync suffix to separate between async and sync return output. Other analyzers will need to support synchronous parse (i.e. parseSync) since that's used within kuroshiro.convert method: https://github.com/hexenq/kuroshiro-analyzer-kuromoji/pull/6