2017-03-10 63 views
1

使用Mallet時,如何獲取與每個文檔相關的主題列表?我想我需要使用火車主題和 - 輸出主題文檔,但是當我這樣做時,我會遇到一個錯誤。使用Mallet時,如何獲得與每個文檔相關的主題列表

我用槌(2.0.8),我用下面的bash腳本做我的造型:

MALLET=/Users/emorgan/desktop/mallet/bin/mallet 
INPUT=/Users/emorgan/desktop/sermons 
OBJECT=./object.mallet 

$MALLET import-dir --input $INPUT --output $OBJECT --keep-sequence --remove-stopwords 

$MALLET train-topics --input $OBJECT --num-topics 10 --num-top-words 1 \ 
--num-iterations 50 \ 
--output-doc-topics ./topics.txt \ 
--output-topic-keys ./keys.txt \ 
--xml-topic-report ./topic.xml \ 
--output-topic-docs ./docs.txt 

不幸的是,./docs.txt還沒有生成。相反,我得到以下錯誤:在線程

異常「主要」 java.lang.ClassCastException:java.net.URI中不能轉換爲java.lang.String 在cc.mallet.topics.ParallelTopicModel.printTopicDocuments(ParallelTopicModel .java:1773) at cc.mallet.topics.tui.TopicTrainer.main(TopicTrainer.java:281)

更具體地說,我希望Mallet生成文檔列表以及分配給它們的相關主題,或者我想要一個主題列表,然後是關聯文檔列表。我如何創建這樣的列表?

回答

0

至少在木槌2.0.7中,它是--output-doc-topics ./topics.txt,它給出了所需的表(每個文檔的主題組成)。當輸出格式從2.0.7更改爲2.0.8時,文件的主要內容保持不變。

+0

是的,謝謝。當使用--output-doc-topics選項時,2.0.7版會輸出文件。我將繼續使用2.0.7版本,直到問題在新版本的Mallet中得到解決。謝謝你,jknappen。 – ericleasemorgan

相關問題