Gemini Advanced is a premium generative-AI assistant that can interpret customer reviews and propose practical Python workflows. Its usefulness depends on checking generated code and results rather than accepting them automatically. section 5.5.6 section 6.2.2
Prompting for Portuguese review analysis
Ask: "I have a dataframe with a column review_comment_message containing customer reviews in Portuguese. Propose Python code to extract positive reviews using keyword search." Gemini Advanced supplies a pandas-based approach with Portuguese keywords, case-insensitive matching, and a filtered dataframe. A separate prompt, "What is the sentiment of these reviews?", can classify individual reviews as positive, neutral, negative, or mixed. section 5.5.6 section 6.2.2
import pandas as pd
# Load your dataframe
df = pd.read_csv('olist_order_reviews_dataset.csv')
# List of positive keywords in Portuguese
positive_keywords = ['ótimo', 'excelente', 'bom', 'incrível',
'maravilhoso', 'perfeito', 'gostei', 'satisfeito', 'recomendo',
'amei']
# Define a function to check if a review contains positive keywords
def is_positive(review):
for keyword in positive_keywords:
if keyword.lower() in review.lower():
return True
return False
# Apply the function to the 'review_comment_message' column
df['is_positive'] = df['review_comment_message'].apply(is_positive)
# Create a new dataframe with only positive reviews
positive_reviews_df = df[df['is_positive']]
# Save the positive reviews to a new CSV file
positive_reviews_df.to_csv('positive_reviews.csv', index=False)
Inspect a complete pandas listing that loads review data, checks Portuguese positive keywords, creates an is_positive column, and saves the filtered reviews. section 5.5.6
Table 6.1 Direct sentiment analysis with generative AIs
|
Review translated by Google Translate
|
Review score
|
True sentiment
|
Sentiment analysis by ChatGPT 4
|
Sentiment analysis by Gemini Advanced
|
|---|---|---|---|---|
|
I received it well before the stipulated time.
|
5
|
positive
|
positive
The customer received the product well before the stipulated deadline, indicating a positive experience with the delivery.
|
positive
The reviewer received the product well before the estimated delivery date.
|
|
Good product, but what came to me does not match the photo in the ad.
|
3
|
neutral
|
mixed/neutral
The review mentions that the product is good (positive sentiment), but also states that the received product does not match the photo in the advertisement (negative sentiment). This combination of sentiments makes the overall sentiment mixed or neutral.
|
mixed
The reviewer says the product is good, but it doesn’t match the photo in the ad.
|
|
I would like to know why my product has not yet arrived at my residence and nobody has given me satisfaction or anything like that.
|
1
|
negative
|
negative
The customer is expressing dissatisfaction with the fact that the product has not yet arrived at their residence and that they haven’t received any explanation or communication regarding the delay. This indicates a negative experience with the delivery and customer service.
|
negative
The reviewer hasn’t received the product yet and hasn’t received any updates from the seller.
|
Compare Gemini Advanced’s classifications with review scores and translated review meanings across positive, mixed or neutral, and negative cases. section 6.2.2
Use Gemini Advanced constructively by:
- Checking generated imports, dependencies, and execution behavior; an earlier solution contained NLTK import problems and required manual correction. section 5.5.6
- Questioning hidden translation steps, because translating non-English text can add complexity and potential bias. section 5.5.6
- Evaluating classifications against known review scores before drawing broader conclusions. section 6.2.2
