Skip to content

Instantly share code, notes, and snippets.

@nozma
Last active August 16, 2017 14:34
Show Gist options
  • Select an option

  • Save nozma/20ea9d7e2a0335921bdce27b213f87aa to your computer and use it in GitHub Desktop.

Select an option

Save nozma/20ea9d7e2a0335921bdce27b213f87aa to your computer and use it in GitHub Desktop.
# coding: utf-8
def n_gram(n, s):
result = []
for i in range(0, len(s)-n+1):
result.append(s[i:i+n])
return result
print(n_gram(2, 'I am an NLPer'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment