2011-06-28 7 views
1

Javaのようなもので共起クラスを書く方法は、nグラムのファイルをとり、単語を計算する与えられた入力項に対して共起する。単語共起 - nグラムの集合内にある用語の共起を見つける

Lucene(インデックス)やHadoopのn-gramリストに対するmap-reduceのようなライブラリやパッケージはありますか?

ありがとうございました。回数を行う

// Co-occurrence matrix 
Hashmap<String,HashMap<String,Integer>> map = new HashMap(); 

// List of ngrams 
ArrayList<ArrayList<String>> ngrams = ..... // assume we've loaded them into here already 

// build the matrix 
for(ArrayList<String> ngram:ngrams){ 
    // Calculate word co-occurrence in ngram for all words 
    // result is an map strings-> count 
    // words in alphabetical order 
    Hashmap<String,<ArrayList<String>,Integer> wordCoocurrence = cooccurrence(ngram) // assume we have this 

    // then just join this with original 
} 

// and just query with words in alphabetic order 

+0

誰もが考えています... Think Solr/Luceneはこれには最良のアプローチかもしれませんが... ... – NightWolf

+2

...それは本当に必要なのですか?コーパスが数百万のトークン、またはngramsが数百万である場合、単純なjavaまたはpythonプログラムが行います。 – dagnelies

+0

私はそのようなことを一度だけ行いました。perlとmysqlをウェブページに表示しました。 – nflacco

答えて

2

オクラホマので、ここで

は擬似コードっぽいJavaの....あなたがngramsのファイルに2つの異なる単語の共起を見つけたいと仮定これはおそらく豚ではかなり可愛いでしょうが、あなたはおそらく私よりもよく知っています

関連する問題