2012-03-27 44 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