Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

create bigram in python

from nltk.tokenize import word_tokenize
from nltk.util import ngrams

def get_ngrams(text, n ):
    n_grams = ngrams(word_tokenize(text), n)
    return [ '_'.join(grams) for grams in n_grams]

get_ngrams("this is a sentence",  2)
 
PREVIOUS NEXT
Tagged: #create #bigram #python
ADD COMMENT
Topic
Name
6+1 =