diff --git a/Adjective Comparative and Superlative Generator using NLP/script.py b/Adjective Comparative and Superlative Generator using NLP/script.py index 7e97816291..87d7f1dccf 100644 --- a/Adjective Comparative and Superlative Generator using NLP/script.py +++ b/Adjective Comparative and Superlative Generator using NLP/script.py @@ -1,16 +1,17 @@ +from nltk.corpus import wordnet import nltk nltk.download('wordnet') -from nltk.corpus import wordnet def get_comp_sup(adjs): comp_sup = [] - + for adj in adjs: synsets = wordnet.synsets(adj) if synsets: syn = synsets[0] - comp_forms = [lemma.name().replace('_', ' ') for lemma in syn.lemmas()] + comp_forms = [lemma.name().replace('_', ' ') + for lemma in syn.lemmas()] if len(comp_forms) >= 2: comp_form = comp_forms[1] else: @@ -20,18 +21,20 @@ def get_comp_sup(adjs): else: superl_form = adj + "est" comp_sup.append((adj, comp_form, superl_form)) - + return comp_sup + def main(): adjs = input("Enter a list of adjectives (comma-separated): ").split(',') - + comp_sup = get_comp_sup(adjs) - + print("\nAdjective\tComparative\tSuperlative") print("------------------------------------------") for adj, c, s in comp_sup: print(f"{adj}\t\t{c}\t\t{s}") + if __name__ == "__main__": main()