I am having a problem calling my class and function to my main code. I created a class and do the method in it and just call it in my main code.
This is my class:
from nltk.corpus import wordnet
class syn:
def synon():
f = open('filename', "r")
first = f.readline()
print("1. ", first)
input_ans = input('Answer: ')
synonyms = []
for syn in wordnet.synsets(first):
for l in syn.lemmas():
synonyms.append(l.name())
if input_ans == first:
score += 0
print("Wrong")
elif input_ans in set(synonyms):
print("Correct")
score += 1
else:
score += 0
print("Wrong")
This is my main code:
import os
from synonyms import syn
from nltk.corpus import wordnet
a = syn()
a.synon()
It does not print anything.