Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

extract n grams from text python

from nltk import ngrams

sentence = 'this is a foo bar sentences and i want to ngramize it'

n = 6
sixgrams = ngrams(sentence.split(), n)

for grams in sixgrams:
  print grams
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #extract #grams #text #python
ADD COMMENT
Topic
Name
8+1 =