2012-03-27 41 views
2

我想使用--use-ngrams true選項運行木槌,但似乎無法使其工作。Mallet:局部N-grams

./bin/mallet import-dir --input path --output topic-input.mallet --keep-seqence -- removed stopwords 

現在,我要培養一種外用NGRAM型號:我採用進口我的數據

bin/mallet train-topics --input topic-input.mallet --use-ngrams true --num-topics 30 --xml-topic-report topic-report.xml 

但我發現了這個錯誤:

Exception in thread "main" java.lang.ClassCastException: cc.mallet.types.FeatureSequence cannot be cast to cc.mallet.types.FeatureSequenceWithBigrams 
at cc.mallet.topics.TopicalNGrams.estimate(TopicalNGrams.java:78) 
at cc.mallet.topics.tui.Vectors2Topics.main(Vectors2Topics.java:249) 

,你可以看到我正在運行mallet作爲命令行工具,而不是撬動它的API來使其工作。有什麼建議麼?

回答

4

找到了答案:

必須導入您想在使用 '--keep-序列bgirams' 參數運行外用-NGRAM造型的目錄(如

./bin/mallet import-dir --input path --output topic-input.mallet --keep-sequence-bigrams --remove-stopwords 

而且那麼,您將主題模型運行爲:

bin/mallet train-topics --input topic-input.mallet --use-ngrams true --num-topics 30 --xml-topic-report topic-report.xml