将文本文档列表转换为语料库词典,然后使用以下方法将其转换为词袋模型:
dictionary = gensim.corpora.Dictionary(docs) # docs is a list of text documents
corpus = [dictionary.doc2bow(doc) for doc in docs]
Run Code Online (Sandbox Code Playgroud)
我们可以使用以下方法找出字典中特定单词的索引值:
dictionary.doc2idx(["righteous","height"])
Run Code Online (Sandbox Code Playgroud)
有没有办法找到存储在字典中特定索引处的单词?