We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 78b97be + 2ce2f81 commit 72147bdCopy full SHA for 72147bd
N-Grams NLP/script.py
@@ -3,19 +3,22 @@
3
import nltk
4
nltk.download('punkt')
5
6
+
7
def gen_ngrams(txt, n):
8
tokens = word_tokenize(txt)
9
ngs = list(ngrams(tokens, n))
10
return ngs
11
12
13
def main():
14
u = input("Enter a sentence: ")
15
n = int(input("Enter the value of n for n-grams: "))
-
16
17
ngs = gen_ngrams(u, n)
18
19
print(f"Input Sentence: {u}")
20
print(f"{n}-grams: {ngs}")
21
22
23
if __name__ == "__main__":
24
main()
0 commit comments