【发布时间】:2015-01-02 08:29:39
【问题描述】:
我是主题建模的新手,我正在尝试使用 Mallet 库,但我有一个问题。
我正在使用 LDA 的简单并行线程实现来查找某些实例的主题。我的问题是ParallelTopicModel 中的估计函数是什么?
我在API 中进行了搜索,但没有描述。我也读过this tutorial。
谁能解释一下这个函数是什么?
编辑
这是我的代码示例:
public void runModel(Sting [] str){
ParallelTopicModel model = new ParallelTopicModel(numTopics);
ArrayList<Pipe> pipeList = new ArrayList<Pipe>();
// Pipes: lowercase, tokenize, remove stopwords, map to features
pipeList.add(new CharSequenceLowercase());
pipeList.add(new CharSequence2TokenSequence(Pattern.compile("\\p{L}[\\p{L}\\p{P}]+\\p{L}")));
pipeList.add(new TokenSequence2FeatureSequence());
InstanceList instances = new InstanceList(new SerialPipes(pipeList));
instances.addThruPipe(new StringArrayIterator(str));
model.addInstances(instances);
model.setNumThreads(THREADS);
model.setOptimizeInterval(optimizeation);
model.setBurninPeriod(burninInterval);
model.setNumIterations(numIterations);
// model.estimate();
}
【问题讨论】:
-
您的标记正则表达式有点奇怪。首先,
\p{L}(小写字符)是\p{P}(可打印字符)的子集,所以[\p{L}]p{P}]与@987654328 相同@。其次,如果您的所有字符都是可打印的,那么每个文档只会得到一个标记(它从第一个小写字母开始,到最后一个字母结束)。
标签: java lda topic-modeling mallet