topic model,model

來源:互聯網
上載者:User

topic model,model
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 corpusVectorizer = StemmedCountVectorizer# Vectorizer = CountVectorizervectorizer = 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


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.