I am trying to build a suggestion tool based on a movie dataset. More specifically it will suggest a movie by title based on genre keyword.
But I couldn't pass the loop/check part of the script, here is what I have tried:
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")
The output of the tokenized_genre like this:
[['Biography', ',', 'Crime', ',', 'Drama'],
['Drama'], ['Drama', ',', 'History'],
['Adventure', ',', 'Drama', ',', 'Fantasy'],
['Biography', ',', 'Drama'],
['Biography', ',', 'Drama', ',', 'Romance']
The output of the loop:
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
I guess the mistake in the list of the tokenized words but I couldn't solve it.