<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bharaniraaj on Medium]]></title>
        <description><![CDATA[Stories by Bharaniraaj on Medium]]></description>
        <link>https://medium.com/@bharaniraaj17?source=rss-410c18a72adb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Bharaniraaj on Medium</title>
            <link>https://medium.com/@bharaniraaj17?source=rss-410c18a72adb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 08:56:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bharaniraaj17/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Sentiment Analysis using basic NLP concepts]]></title>
            <link>https://medium.com/@bharaniraaj17/sentiment-analysis-using-basic-nlp-concepts-9bf63e607b06?source=rss-410c18a72adb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bf63e607b06</guid>
            <category><![CDATA[sentiment-analysis]]></category>
            <category><![CDATA[web-scraping]]></category>
            <dc:creator><![CDATA[Bharaniraaj]]></dc:creator>
            <pubDate>Mon, 06 Nov 2023 14:45:06 GMT</pubDate>
            <atom:updated>2023-11-06T14:45:06.756Z</atom:updated>
            <content:encoded><![CDATA[<p>In the ever-expanding universe of cinema, a movie’s destiny often hinges on one crucial factor: audience verdict. With the digital age in full swing, the voice of the moviegoer has become more influential than ever. In this captivating journey, we’re about to unlock the mysteries of sentiment analysis using Natural Language Processing (NLP).</p><p><strong>The Quest for Valuable Insights</strong></p><p>In our quest to explore sentiment analysis using Natural Language Processing (NLP), we embarked on a fascinating journey to collect a diverse set of movie reviews and ratings. Armed with Python and the versatile Selenium library, we set out to scrape approximately 200 reviews for the same film, along with their associated ratings, from the IMDB website. This data collection phase was essential as it formed the base of our sentiment analysis project. The IMDB website, renowned for its treasure trove of movie reviews, offered us a valuable and varied collage of opinions. From heartfelt praises to sharp criticisms, the reviews painted a colorful spectrum of moviegoers’ perspectives, laying the foundation for our sentiment analysis exploration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*5IzkcjuvhpSw5gMcluG-nA.png" /><figcaption>A sample of reviews from the IMDB website</figcaption></figure><p>With this addition, here is a brief code snippet of how the reviews and ratings were collected from the IMDB website using Selenium.</p><pre># Import required libraries<br>from selenium import webdriver<br>from selenium.webdriver.common.by import By<br>from selenium.webdriver.support.ui import WebDriverWait<br>from selenium.webdriver.support import expected_conditions as EC<br>import pandas as pd<br>import re<br><br># Start a new WebDriver session (you&#39;ll need to have the appropriate webdriver installed)<br>driver = webdriver.Chrome()  # You can use a different webdriver depending on your browser<br><br># Open the IMDb movie reviews page<br>url = &#39;https://www.imdb.com/tt1582850/reviews&#39; # Provide the link of the required page<br>driver.get(url)<br><br># Function to click the &quot;Load More&quot; button as only 25 reviews will showed initially<br>def click_load_more():<br>    try:<br>        load_more_button = WebDriverWait(driver, 10).until(<br>            EC.element_to_be_clickable((By.CLASS_NAME, &#39;ipl-load-more__button&#39;))<br>        )<br>        load_more_button.click()<br>    except Exception as e:<br>        print(f&quot;An error occurred while clicking &#39;Load More&#39;: {str(e)}&quot;)<br><br># Click the &quot;Load More&quot; button multiple times <br>for _ in range(8):  # This will load more reviews up to a certain limit<br>    click_load_more()<br><br># Extract the reviews and ratings<br>reviews = driver.find_elements(By.CLASS_NAME, &#39;text.show-more__control&#39;)<br>ratings = driver.find_elements(By.CLASS_NAME, &#39;rating-other-user-rating&#39;)<br><br># Process the data as needed<br>data = {&#39;Review&#39;: [review.text for review in reviews],  <br>        &#39;Rating&#39;: [rating.text for rating in ratings]}<br>df = pd.DataFrame(data)<br><br># Display the DataFrame<br>print(df)<br><br># Close the WebDriver when you&#39;re done<br>driver.quit()</pre><p><strong>Sentiment Analysis Unveiled</strong></p><p>Sentiment analysis, part of NLP, is like a digital mood ring for text. It helps figure out if the text is happy, sad, or just neutral. Sentiment analysis is super useful for filmmakers, movie studios, and fans to understand what people feel about movies.</p><p><strong>Clean-Up Crew: Data Preprocessing</strong></p><p>The raw data we collected was far from clean; it needed a good wash and polish. Here’s how we scrubbed it clean:</p><p><strong>Tokenization:</strong> We broke down the reviews into individual words — the bricks for our analysis.<br><strong>Punctuation Patrol:</strong> Special characters and punctuation got the boot, as they usually lack sentiment significance.<br><strong>Stop Word Swat:</strong> Common words like “the,” “and,” and “is” were banished from our text; they tend to be mere spectators in the sentiment arena.</p><pre>from nltk.corpus import stopwords<br>from nltk.tokenize import word_tokenize<br><br>stop_words = set(stopwords.words(&#39;english&#39;))<br><br># Modify the text preprocessing step to remove stop words<br>df[&#39;Review&#39;] = df[&#39;Review&#39;].apply(lambda x: x.lower())  # Lowercase<br>df[&#39;Review&#39;] = df[&#39;Review&#39;].str.replace(&#39;[^\w\s]&#39;, &#39;&#39;)  # Remove punctuation<br>df[&#39;Review&#39;] = df[&#39;Review&#39;].apply(nltk.word_tokenize)  # Tokenization<br>df[&#39;Review&#39;] = df[&#39;Review&#39;].apply(lambda x: [word for word in x if word not in stop_words])  # Remove stop words</pre><p><strong>Role of Agent VADER</strong></p><p>The starring role in our sentiment analysis drama was claimed by VADER (Valence Aware Dictionary and sEntiment Reasoner), a sentiment analysis pre-trained model. VADER is the seasoned detective who can unravel the complex layers of sentiment analysis, even when it gets tricky, like understanding context and negation.</p><p>Once our data was polished and prepped, VADER swung into action, evaluating the sentiment of each review. The agent labeled each text as positive, negative, or neutral, all based on the depth of emotional expression it detected using compound scores. VADER’s superpower not only let us grasp the overall sentiment of the reviews but also opened a window into how the audience perceived the film’s every frame.</p><pre># Import the necessary libraries<br>import nltk  <br>from nltk.sentiment.vader import SentimentIntensityAnalyzer  <br><br># Download the VADER lexicon<br>nltk.download(&#39;vader_lexicon&#39;)<br><br># Initialize the VADER sentiment analyzer<br>sid = SentimentIntensityAnalyzer()<br><br># Define a function to calculate sentiment scores for each review<br>def calculate_sentiment(row):<br>    text = &#39; &#39;.join(row) # Join the list of tokens into a single string<br>    <br>    sentiment_scores = sid.polarity_scores(text) # Use the VADER sentiment analyzer to calculate sentiment scores for the text<br>    <br>    return sentiment_scores[&#39;compound&#39;] # Return the compound score, which represents the overall sentiment<br><br># Apply the &#39;calculate_sentiment&#39; function to each review in the DataFrame and store the compound scores in a new column<br>df[&#39;compound_score&#39;] = df[&#39;Review&#39;].apply(calculate_sentiment) </pre><p><strong>The Epic Reveal</strong></p><p>The sentiment analysis of reviews was like cracking open a treasure chest. The diversity of opinions wasn’t surprising, but it was utterly engrossing. The protagonist’s magnetic performance and the intricate plot had some viewers over the moon, leading to effervescent positive sentiments. On the flip side, others found the film to be influenced by many other films in certain aspects, which understandably translated into negative sentiments. The neutral sentiments acted like a crowd of unbiased referees, reminding us that the spectrum of opinions knows no bounds. However, most of the viewers seemed to enjoy the movie, ignoring the logical flaws and enjoying the magnificent screenplay, thus biasing more towards a positive impact.</p><p>The sentiment analysis experiment proved to reflect this reality. Our agent was able to capture the sentiment of the audience with an accuracy of 70%. All the positive reviews were perfectly captured, but a few neutral and negative reviews weren’t recognized accurately by VADER as those reviews had sarcasm and mixed-toned opinions. VADER will not be able to understand these factors effectively.</p><p><strong>Conclusion</strong></p><p>Sentiment analysis is an enchanting tool that allows us to peer into the collective heart of the audience. Scraping data, cleaning it, and applying sentiment analysis is like decoding an ancient script that holds the essence of cinematic experience. The combination of textual reviews and numeric ratings not only unveiled the film’s popularity but also showcased how varied the audience’s sentiments can be.</p><p>As a powerful tool, sentiment analysis enables us to navigate the world of cinema effectively, providing insights into the hidden emotions that movies evoke, whether it’s a blockbuster or a beloved classic, enhancing our understanding of the film industry in the digital age. Beyond cinema, sentiment analysis has wide-ranging applications in areas such as market research, brand management, and customer feedback analysis, offering valuable insights into public sentiment that can drive informed decision-making across industries.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bf63e607b06" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>