import pandas as pd
df = pd.read_csv("Reviews.csv", encoding="utf-8")
print(df["Review Text"].head())
def classificar_sentimento(texto):
texto = texto.lower()
if any(p in texto for p in ["excelente", "bom", "ótimo", "adoro", "recomendo"]):
return "Positivo"
elif any(n in texto for n in ["péssimo", "ruim", "horrível", "não recomendo", "fraco"]):
return "Negativo"
else:
return "Neutro"
df["Sentimento"] = df["Review Text"].apply(classificar_sentimento)
print(df[["Review Text", "Sentimento"]].head())
from google import genai
import os
client = genai.Client(api_key=os.environ["GOOGLE_API_KEY"])
def classificar_sentimento_llm(texto):
resp = client.models.generate_content(
model="gemini-2.5-flash",
contents=f"Classifique o sentimento como Positivo, Negativo ou Neutro: {texto}"
)
return resp.text.strip().capitalize()
df["Sentimento"] = df["Review Text"].apply(classificar_sentimento_llm)
df.to_csv("Reviews_Classificados.csv", encoding="utf-8", index=False)
print("Arquivo Reviews_Classificados.csv criado com sucesso!")