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
。