takuyaa / kuromoji.js

JavaScript implementation of Japanese morphological analyzer
830 stars 117 forks source link

ローカルでは動くのに、Webサーバー上ではkuromoji.jsが動作しません #43

Open oaroid opened 3 years ago

oaroid commented 3 years ago

ローカルでは以下のコードの状態でkuromoji.jsを使えるのですが、Webサーバー(Lolipop)にアップした途端に以下のようなエラーが出て使えません。 このエラーは一体どのようにしたら解決できるのでしょうか?サーバーの問題なんでしょうか? お聞きしたいです。よろしくお願いいたします。

<script src="assets/kuromoji.js"></script>
<script>
kuromoji.builder({ dicPath: "assets/dict" }).build(function (err, tokenizer) {
    // tokenizer is ready
    var path = tokenizer.tokenize("すもももももももものうち");
    console.log(path);
});
</script>

image

DhansAL commented 3 years ago

have anyone founded a solution to this?

larvata commented 3 years ago

It seems caused by the server decompress the .gz file automatically. You should check the webserver config.

Or modify the kuromoji code to prevent decompressing the dict: https://github.com/hexenq/kuroshiro/issues/27#issuecomment-686428617

chinenvinicius commented 1 year ago

how u would modify it? i dont have any clue @larvata

larvata commented 1 year ago

@chinenvinicius please check out the link above. You need to comment 2 lines: 50-51 https://github.com/takuyaa/kuromoji.js/blob/master/src/loader/BrowserDictionaryLoader.js

chinenvinicius commented 1 year ago

in my case im being able to load the file because i put the exact path. however its .dat.gz files are taking 30 secods to load all file. im not sure what im doing wrong. @larvata

larvata commented 1 year ago

@chinenvinicius Have you tried the kuromoji demo site? For me, it takes 15s for loading.

image
chinenvinicius commented 1 year ago

so im using kuroshiro.js to put furigana on kanji. and kuroshiro.js is dependent on kuromji dictionary. On local server. its takes less than one second to load it. however when i put on live sever it takes about 30 seconds or even more. does the speed has anything to the sever or the code ? @larvata

miusuncle commented 2 months ago

You can cache the dict data once fetched. Take a look at an approach at https://miusuncle.github.io/japen/.