File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Adjective Comparative and Superlative Generator using NLP Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 1+ from nltk .corpus import wordnet
12import nltk
23nltk .download ('wordnet' )
34
4- from nltk .corpus import wordnet
55
66def 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+
2628def 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 ("\n Adjective\t Comparative\t Superlative" )
3234 print ("------------------------------------------" )
3335 for adj , c , s in comp_sup :
3436 print (f"{ adj } \t \t { c } \t \t { s } " )
3537
38+
3639if __name__ == "__main__" :
3740 main ()
You can’t perform that action at this time.
0 commit comments