Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions PyDictionary/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,23 @@ def getAntonyms(self, formatted=True):
return [self.antonym(term, formatted) for term in self.args]

@staticmethod
def antonym(word, formatted=False):
if len(word.split()) > 1:
def antonym(term, formatted=False):
if len(term.split()) > 1:
print("Error: A Term must be only a single word")
else:
try:
data = _get_soup_object("http://www.thesaurus.com/browse/{0}".format(word))
data = _get_soup_object("http://www.thesaurus.com/browse/{0}".format(term))
terms = data.select("section.antonyms")[0].findAll("li")
if len(terms) > 5:
terms = terms[:5:]
li = []
for t in terms:
li.append(t.select("span.text")[0].getText())
if formatted:
return {word: li}
return {term: li}
return li
except:
print("{0} has no Antonyms in the API".format(word))
print("{0} has no Antonyms in the API".format(term))

@staticmethod
def meaning(term, disable_errors=False):
Expand Down