我想用槌子来训练主题。我的数据在一个文件中,所以我研究了 mallet 文档以了解如何构建这个 One Single 文件。
在Mallet 网站的One 文件下,每行一个实例部分,据说:
[URL] [语言] [页面文本...]
在这种情况下,每行的第一个标记(空格分隔,可选逗号)成为实例名称,第二个标记成为标签,并且该行上的所有其他文本都被解释为一系列单词标记。
所以根据上面的引用,我以这种方式创建了我的单个文件:
127 en some text here...
982 en some text here...
1003 en some text here...
...
然后导入这个单个文件:
bin\mallet import-file --input data.txt --output data.mallet --keep-sequence
之后,我训练了 3 个主题:
bin\mallet train-topics --input data.mallet --num-topics 3 --output-doc-topics data_composition.txt --word-topic-counts-file data_wcounts.txt
但是,当我打开 时data_composition.txt
,它具有以下结构:
#doc source topic proportion ...
0 null-source 0 0.4057970941066742 1 0.3188405930995941 2 0.2753623127937317
所以现在的问题是:为什么 mallet 会null-source
在这个合成文件上打印?我希望它在源标题下打印 URL(在我的例子中是 ID)。
编辑:
我想要这样的东西:
#doc source topic proportion ...
0 127 0 0.4057970941066742 1 0.3188405930995941 2 0.2753623127937317
1 982 ... (topic probabilities) ...
2 1003 ... (topic probabilities) ...
提前致谢!