Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 72147bd

Browse files
Merge pull request #2961 from avinashkranjan/deepsource-transform-3eadc4ef
format code with autopep8
2 parents 78b97be + 2ce2f81 commit 72147bd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎N-Grams NLP/script.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33
import nltk
44
nltk.download('punkt')
55

6+
67
def gen_ngrams(txt, n):
78
tokens = word_tokenize(txt)
89
ngs = list(ngrams(tokens, n))
910
return ngs
1011

12+
1113
def main():
1214
u = input("Enter a sentence: ")
1315
n = int(input("Enter the value of n for n-grams: "))
14-
16+
1517
ngs = gen_ngrams(u, n)
16-
18+
1719
print(f"Input Sentence: {u}")
1820
print(f"{n}-grams: {ngs}")
1921

22+
2023
if __name__ == "__main__":
2124
main()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /