Skip to content

Instantly share code, notes, and snippets.

@nozma
Last active August 17, 2017 13:06
Show Gist options
  • Select an option

  • Save nozma/9cb4d3553946a5af7386df948c3132f8 to your computer and use it in GitHub Desktop.

Select an option

Save nozma/9cb4d3553946a5af7386df948c3132f8 to your computer and use it in GitHub Desktop.
# coding: utf-8
def n_gram(n, s):
return [s[i:i+n] for i in range(0, len(s)-n+1)]
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