Testing sentiment analysis 1

PHOTO EMBED

Fri May 31 2024 16:51:22 GMT+0000 (Coordinated Universal Time)

Saved by @madgakantara

from pymongo import MongoClient
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
import statistics
def analyze_sentiment(text):
    """
    Analyzes the sentiment of the given text using VADER.
    Returns the compound sentiment score.
    """
    analyzer = SentimentIntensityAnalyzer()
    sentiment = analyzer.polarity_scores(text)
    return sentiment['compound']
neutral_comments_klm = [
    "I have a flight booked with KLM.",
    "I'm flying with KLM next month.",
    "I've used KLM for my travels before.",
    "I'm considering KLM for my upcoming trip.",
    "KLM operates flights to various destinations.",
    "I'll be flying with KLM for my vacation.",
    "KLM offers flights at competitive prices.",
    "I'll be traveling with KLM for work.",
    "I've heard about KLM's services.",
    "KLM is one of the airlines I'm considering.",
    "I've seen advertisements for KLM.",
    "I'll be using KLM for my international flight.",
    "KLM provides options for connecting flights.",
    "I need to check KLM's flight schedule.",
    "I'm looking into KLM's frequent flyer program.",
    "I received an email from KLM.",
    "I'm exploring flight options with KLM.",
    "KLM offers flights with various amenities.",
    "I'll be flying with KLM for my family visit.",
    "KLM has partnerships with other airlines.",
    "I'll be using KLM for my business trip.",
    "KLM has a website for booking flights.",
    "I'll be flying with KLM because of the route.",
    "KLM provides options for different classes.",
    "I've considered KLM for my travel plans.",
    "KLM offers online check-in.",
    "I've received information about KLM's services.",
    "I'll be flying with KLM due to convenience.",
    "KLM has a mobile app for flight management.",
    "I'll be using KLM for my upcoming trip abroad.",
    "KLM offers options for booking accommodations.",
    "I've heard about KLM's customer service.",
    "I'll be considering KLM for future travels.",
    "KLM provides options for flight upgrades.",
    "I'll be flying with KLM because of recommendations.",
    "KLM offers options for flight insurance.",
    "I've checked KLM's flight status online.",
    "I'll be flying with KLM for personal reasons.",
    "KLM provides options for seat selection.",
    "I've received promotions from KLM.",
    "I'll be flying with KLM for leisure travel.",
    "KLM offers options for in-flight entertainment.",
    "I've read about KLM's safety measures.",
    "I'll be flying with KLM because of scheduling.",
    "KLM provides options for booking car rentals.",
    "I've looked into KLM's baggage policies.",
    "I'll be flying with KLM for holiday travel.",
    "KLM offers options for travel insurance.",
    "I've explored KLM's route map.",
    "I'll be considering KLM for my next trip.",
    "KLM provides options for airport transfers.",
    "I've browsed KLM's website for information.",
    "I'll be flying with KLM due to flexibility.",
    "KLM offers options for flight add-ons.",
    "I've researched KLM's onboard services.",
    "I'll be considering KLM for my future travels.",
    "KLM provides options for special assistance.",
    "I've looked into KLM's loyalty program.",
    "I'll be flying with KLM for my international trip.",
    "KLM offers options for travel packages.",
    "I've compared KLM's fares with other airlines.",
    "I'll be considering KLM for my next vacation.",
    "KLM provides options for dietary preferences.",
    "I've checked KLM's reviews online.",
    "I'll be flying with KLM for my trip to Europe.",
    "KLM offers options for travel upgrades.",
    "I've explored KLM's flight routes.",
    "I'll be considering KLM for my next adventure.",
    "KLM provides options for group bookings."
]


list_of_scores = []
for text in neutral_comments_klm:
    score = analyze_sentiment(text)
    list_of_scores.append(score)
aveage_score = statistics.mean(list_of_scores)
print(aveage_score)


content_copyCOPY