Created
November 30, 2011 10:09
-
-
Save puneetlakhina/1408564 to your computer and use it in GitHub Desktop.
Make n grams from a list of words
This file contains 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 ngram(words,n): | |
return ["_".join(words[i:i+n]) for i in range(0,len(words)-n+1)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment