我试着做一个类似于this问题的尝试
原始输出
Uni-grams
topic1 -scuba,water,vapor,diving
topic2 -dioxide,plants,green,carbon
所需输出
Bi-gram topics
topic1 -scuba diving,water vapor
topic2 -green plants,carbon dioxide
这就是答案
from nltk.util import ngrams
for doc in docs:
docs[doc] = docs[doc] + ["_".join(w) for w in ngrams(docs[doc], 2)]
任何帮助我应该做什么更新才能只有Bigram
仅使用Bigram创建文档:
或bigrams的具体方法:
然后在
texts
中使用这些bigram的列表用于将来的操作相关问题 更多 >
编程相关推荐