kuromoji.js icon indicating copy to clipboard operation
kuromoji.js copied to clipboard

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

Open oaroid opened this issue 4 years ago • 8 comments

ローカルでは以下のコードの状態で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

oaroid avatar Nov 03 '20 09:11 oaroid

have anyone founded a solution to this?

DhansAL avatar May 05 '21 16:05 DhansAL

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

larvata avatar May 06 '21 07:05 larvata

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

chinenvinicius avatar Aug 06 '22 04:08 chinenvinicius

@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

larvata avatar Aug 06 '22 05:08 larvata

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

chinenvinicius avatar Aug 09 '22 12:08 chinenvinicius

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

larvata avatar Aug 10 '22 04:08 larvata

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

chinenvinicius avatar Aug 13 '22 07:08 chinenvinicius

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

miusuncle avatar Apr 13 '24 02:04 miusuncle