Last active
January 21, 2018 09:33
-
-
Save shirayuca/9819a0ce297ae98271d6 to your computer and use it in GitHub Desktop.
markov.gs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// マルコフ連鎖で1文を要約する | |
function markov(cell) { | |
var segmenter = new TinySegmenter(); // インスタンス生成 | |
var segs = segmenter.segment(cell); // 単語の配列が返る | |
var dic = makeDic(segs); | |
return makeSentence(dic); | |
} | |
// マルコフ連鎖で複数文を要約する | |
function markov_array(cells) { | |
var text = cells.join(""); | |
var segmenter = new TinySegmenter(); // インスタンス生成 | |
var segs = segmenter.segment(text); // 単語の配列が返る | |
var dic = makeDic(segs); | |
return makeSentence(dic); | |
} | |
// マルコフ連鎖用辞書の作成 ----- (※2) | |
function makeDic(words) { | |
var tmp = ["@"]; | |
var dic = {}; | |
…以下、『JS+Node-jsによるWebクローラー/ネットエージェント開発テクニック』参照 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment