Skip to content

Instantly share code, notes, and snippets.

@acrymble
Created September 22, 2011 12:14
Show Gist options
  • Select an option

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

Select an option

Save acrymble/1234637 to your computer and use it in GitHub Desktop.
Python get Ngrams
def getNGrams(wordlist, n):
ngrams = []
for i in range(len(wordlist)-(n-1)):
ngrams.append(wordlist[i:i+n])
return ngrams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment