【问题标题】:topic modeling using keywords for topics使用主题的关键字进行主题建模
【发布时间】:2014-11-29 11:44:59
【问题描述】:

我需要通过以下方式进行主题建模:

例如:

我需要从一个文档中提取 5 个主题。该文档是单个文档。我有 5 个主题的关键字,并且与这 5 个关键字相关,我需要提取主题。

5 个主题的关键字是: 关键字 1-(汽车、赛车、...) 关键字 2-(事故、保险、...) ......

对应的输出应该是: 主题 1-​​(车辆、扭矩、速度...) 主题2-(索赔,金额,....)

这是怎么做到的?

【问题讨论】:

  • 回答问题的最佳机会不是仅仅寻求帮助,而是让人们知道您正在积极尝试自己解决问题。你已经做了什么来解决这个问题?

标签: lda topic-modeling


【解决方案1】:

这个 LDA 主题建模库是一个很好的起点,它是为与 NodeJS 一起使用而编写的。

https://www.npmjs.org/package/lda

var lda = require('lda');
// Example document.
var text = 'Cats are small. Dogs are big. Cats like to chase mice. Dogs like to eat bones.';

// Extract sentences.
var documents = text.match( /[^\.!\?]+[\.!\?]+/g );

// Run LDA to get terms for 2 topics (5 terms each).
var result = lda(documents, 2, 5);
The above example produces the following result with two topics (topic 1 is "cat-related", topic 2 is "dog-related"):

Topic 1
cats (0.21%)
dogs (0.19%)
small (0.1%)
mice (0.1%)
chase (0.1%)

Topic 2
dogs (0.21%)
cats (0.19%)
big (0.11%)
eat (0.1%)
bones (0.1%)

这应该让你开始走上这条路。请注意,您可能需要根据主题和文档的数量来调整它们以适应您要提取的信息量。

这不是魔法。

http://en.wikipedia.org/wiki/Latent_Dirichlet_allocation

【讨论】:

    猜你喜欢
    • 2016-08-13
    • 2016-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多