我需要从中ngrams
提取text
。我在用着:
from textblob import TextBlob
text = TextBlob('me king of python')
print(text.ngrams(n=3)
将文本(python 之王)拆分为三元组,它给出:
[WordList(['me', 'king', 'of']), WordList(['king', 'of', 'python'])]
现在我需要将每个 WordList 的项目加入:
x = {word for word in ' '.join(text.ngrams(n=3)) }
print x
它给了我以下错误:
TypeError: sequence item 0: expected string or Unicode, WordList found
我知道解决方案很愚蠢,但我不擅长 python,我不明白wordlists
。