nmp install kuromoji
でフルにインストールするか辞書ファイルとkuromoji.jsのみ配置してください。
let input = "東京観光のために千葉県から電車に乗ってきた"; let response = ""; kuromoji.builder({ dicPath: "./node_modules/kuromoji/dict" }).build(function(err, tokenizer){ let tokenized_word = tokenizer.tokenize(input); let cmp_noun_list_val = cmp_noun_list(tokenized_word); let frequency = list2key_value(cmp_noun_list_val); let score_lr_val = score_lr(frequency, IGNORE_WORDS, 1, 1); let term_importance_val = term_importance(frequency, score_lr_val); let score_lt_list = sort_by_importance(term_importance_val); for (let data of score_lt_list) { let word = modify_agglutinative_lang(data.cmp_noun); response = response + word + "\t" + data.importance + "\n"; } console.log(response); });