Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

extract bigrams python

from nltk import word_tokenize 
from nltk.util import ngrams


text = ['cant railway station', 'citadel hotel', 'police stn']
for line in text:
    token = nltk.word_tokenize(line)
    bigram = list(ngrams(token, 2))

    # the '2' represents bigram...you can change it to get ngrams with different size
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #extract #bigrams #python
ADD COMMENT
Topic
Name
2+9 =