Skip to content

Instantly share code, notes, and snippets.

@acrymble
Created July 5, 2011 20:05
Show Gist options
  • Select an option

  • Save acrymble/1065787 to your computer and use it in GitHub Desktop.

Select an option

Save acrymble/1065787 to your computer and use it in GitHub Desktop.
Python Ngram result 2
test1 = 'here are four words'
test2 = 'this test sentence has eight words in it'
getNGrams(test1.split(), 5)
-> []
getNGrams(test2.split(), 5)
-> [['this', 'test', 'sentence', 'has', 'eight'],
['test', 'sentence', 'has', 'eight', 'words'],
['sentence', 'has', 'eight', 'words', 'in'],
['has', 'eight', 'words', 'in', 'it']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment