N-gramN-gramは文字列をN文字単位で区切って1要素としたものです。 N-gramは全文検索を高速に行うためのインデックスとして良く使われます。 Nが2のものをbi-gram(バイグラム)、Nが3のものをtri-gram(トライグラム)と呼びます。 Nが4以上は応用例が少なくメジャーでないためか、私は聞いたことがありません。 例えば最初の文章をbi-gramで表現して並べると以下のとおりです。 文字列の先頭からはじめて、1文字ずつずらしながら、2文字単位で1要素としていきます。 Enumerable#each_consRubyではEnumerable#each_consを使って、このようなN-gramを簡単に作ることができます。 Enumerable#each_consのRubyリファレンスマニュアルの解説は以下のとおりです。 要素を重複ありで n 要素ずつに区切り、 ブロックに渡
NAME ngram-format - File format for ARPA backoff N-gram models SYNOPSIS \data\ ngram 1=n1 ngram 2=n2 ... ngram N=nN \1-grams: p w [bow] ... \2-grams: p w1 w2 [bow] ... \N-grams: p w1 ... wN ... \end\ DESCRIPTION The so-called ARPA (or Doug Paul) format for N-gram backoff models starts with a header, introduced by the keyword \data\, listing the number of N-grams of each length. Following that, N-g
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く