首页 > 代码库 > topic model - LDA 1
topic model - LDA 1
http://blog.csdn.net/pipisorry/article/details/42129099
step1 : install gensim
step 2 :Corpora and Vector Spaces
将用字符串表示的文档转换为用id表示的文档向量:
documents = ["Human machine interface for lab abc computer applications", "A survey of user opinion of computer system response time", "The EPS user interface management system", "System and human system engineering testing of EPS", "Relation of user perceived response time to error measurement", "The generation of random binary unordered trees", "The intersection graph of paths in trees", "Graph minors IV Widths of trees and well quasi ordering", "Graph minors A survey"]""" #use StemmedCountVectorizer to get stemmed without stop words corpus Vectorizer = StemmedCountVectorizer # Vectorizer = CountVectorizer vectorizer = Vectorizer(stop_words=‘english‘) vectorizer.fit_transform(documents) texts = vectorizer.get_feature_names() # print(texts) """ texts = [doc.lower().split() for doc in documents] # print(texts) dict = corpora.Dictionary(texts) #自建词典 # print dict, dict.token2id #通过dict将用字符串表示的文档转换为用id表示的文档向量 corpus = [dict.doc2bow(text) for text in texts] print(corpus)【http://www.52nlp.cn/%E】
from:http://blog.csdn.net/pipisorry/article/details/42129099
ref:http://radimrehurek.com/gensim/tutorial.html
topic model - LDA 1
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。