Skip to content

Commit dfa2a01

Browse files
Merge pull request #2957 from avinashkranjan/deepsource-transform-214b15bd
format code with autopep8
2 parents 26a21e1 + de1afa2 commit dfa2a01

File tree

1 file changed

+9
-6
lines changed
  • Adjective Comparative and Superlative Generator using NLP

1 file changed

+9
-6
lines changed
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
from nltk.corpus import wordnet
12
import nltk
23
nltk.download('wordnet')
34

4-
from nltk.corpus import wordnet
55

66
def get_comp_sup(adjs):
77
comp_sup = []
8-
8+
99
for adj in adjs:
1010
synsets = wordnet.synsets(adj)
1111
if synsets:
1212
syn = synsets[0]
13-
comp_forms = [lemma.name().replace('_', ' ') for lemma in syn.lemmas()]
13+
comp_forms = [lemma.name().replace('_', ' ')
14+
for lemma in syn.lemmas()]
1415
if len(comp_forms) >= 2:
1516
comp_form = comp_forms[1]
1617
else:
@@ -20,18 +21,20 @@ def get_comp_sup(adjs):
2021
else:
2122
superl_form = adj + "est"
2223
comp_sup.append((adj, comp_form, superl_form))
23-
24+
2425
return comp_sup
2526

27+
2628
def main():
2729
adjs = input("Enter a list of adjectives (comma-separated): ").split(',')
28-
30+
2931
comp_sup = get_comp_sup(adjs)
30-
32+
3133
print("\nAdjective\tComparative\tSuperlative")
3234
print("------------------------------------------")
3335
for adj, c, s in comp_sup:
3436
print(f"{adj}\t\t{c}\t\t{s}")
3537

38+
3639
if __name__ == "__main__":
3740
main()

0 commit comments

Comments
 (0)