Created
September 22, 2011 12:14
-
-
Save acrymble/1234637 to your computer and use it in GitHub Desktop.
Python get Ngrams
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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