Я думаю, что проблема с вашим вкладом.У вас есть лишний пробел после ,
, поэтому, когда вы разделяете на ,
, ваши слова становятся ["Action", " Adventure"," Drama"]
В wordnet нет таких слов, как Adventure
и Drama
(обратите внимание на пробел вначало слова).Вот почему вы не получаете вывод для 2-го и 3-го слова.
Обходной путь для ввода
разделить на ", "
вместо ","
str = "Action, Adventure, Drama"
def process_genre(str):
for genre in str.split(", "):
result = []
for syn in wordnet.synsets(genre):
for l in syn.lemmas():
result.append(l.name())
print(result)
process_genre(str)
Вывод:
['action', 'action', 'activity', 'activeness', 'military_action', 'action', 'natural_process', 'natural_action', 'action', 'activity', 'action', 'action', 'action', 'action_mechanism', 'legal_action', 'action', 'action_at_law', 'action', 'action', 'action', 'sue', 'litigate', 'process', 'carry_through', 'accomplish', 'execute', 'carry_out', 'action', 'fulfill', 'fulfil']
['adventure', 'escapade', 'risky_venture', 'dangerous_undertaking', 'gamble', 'chance', 'risk', 'hazard', 'take_chances', 'adventure', 'run_a_risk', 'take_a_chance', 'venture', 'hazard', 'adventure', 'stake', 'jeopardize']
['play', 'drama', 'dramatic_play', 'drama', 'dramatic_event', 'drama', 'drama']