kuromoji.js
kuromoji.js copied to clipboard
ローカルでは動くのに、Webサーバー上ではkuromoji.jsが動作しません
ローカルでは以下のコードの状態で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>
have anyone founded a solution to this?
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
how u would modify it? i dont have any clue @larvata
@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
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
Have you tried the kuromoji demo site?
For me, it takes 15s for loading.
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
You can cache the dict data once fetched. Take a look at an approach at https://miusuncle.github.io/japen/.