Skip to content

feat: added ngram algorithm #6074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 4, 2022
6 changes: 3 additions & 3 deletions strings/ngram.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def create_ngram(sentence: str, ngram_size: int) -> list:
['I ', ' a', 'am', 'm ', ' a', 'an', 'n ', ' N', 'NL', 'LP', 'Pe', 'er']
"""

ngrams = []
for i in range(len(sentence) - ngram_size + 1):
ngrams.append(sentence[i : i + ngram_size])
ngrams = [
sentence[i : i + ngram_size] for i in range(len(sentence) - ngram_size + 1)
]
return ngrams


Expand Down