Answers for "nltk bigrams"

2

nltk bigrams

>>> import nltk
>>> from nltk.tokenize import word_tokenize
>>> text = "to be or not to be"
>>> tokens = nltk.word_tokenize(text)
>>> bigrm = nltk.bigrams(tokens)
>>> print(*map(' '.join, bigrm), sep=', ')
to be, be or, or not, not to, to be
Posted by: Guest on August-08-2020
0

nltk bigrams

bigrm = list(nltk.bigrams(text.split()))
Posted by: Guest on August-08-2020

Python Answers by Framework

Browse Popular Code Answers by Language