Я пытаюсь создать инструмент предложения на основе набора данных mov ie. Точнее, он будет предлагать mov ie по названию на основе ключевого слова жанра.
Но я не смог пройти цикл / проверку части скрипта, вот что я попробовал:
import nltk
import pandas as pd
from nltk.tokenize import word_tokenize
import random
#CSV READ & GENRE-TITLE
data = pd.read_csv("data.csv")
df_title = data["title"]
df_genre = data["genre"]
#TOKENIZE
tokenized_genre = [word_tokenize(i) for i in df_genre]
choice = {}
while choice != "exit":
choice = input("Please enter a word = ")
for word in {choice}:
if word in df_genre:
"""The random title of the random adventure movie will be implemented here"""
else:
print("The movie of the genre doesn't exist")
Вывод tokenized_genre
примерно так:
[['Biography', ',', 'Crime', ',', 'Drama'],
['Drama'], ['Drama', ',', 'History'],
['Adventure', ',', 'Drama', ',', 'Fantasy'],
['Biography', ',', 'Drama'],
['Biography', ',', 'Drama', ',', 'Romance']
Вывод l oop:
Please enter a word = adventure
The movie of the genre doesn't exist
Please enter a word = Adventure
The movie of the genre doesn't exist
Я предполагаю ошибку в списке лексемы, но я не смог их решить.