我正在尝试为给定句子生成二元组列表,例如,如果我键入:
To be or not to be
我希望您的程序能够生成。 to be, be or, or not, not to, to be
我尝试了下面的代码,但只是给了我
<generator object bigrams at 0x0000000009231360>
这是我的代码:
import nltk
bigrm = nltk.bigrams(text)
print(bigrm)
那么我该怎么做才能得到想要的东西?我想要一个像上面那样的单词组合列表(例如,to be, be or, or not, not to, to be)。
list(bigrm)
- alvas