0% found this document useful (0 votes)
6 views4 pages

SMA Exp3

The experiment focuses on monitoring a brand's online reputation through social media mentions, sentiment analysis, and influencer identification. It involves data collection via web scraping and APIs, preprocessing of data, applying NLP techniques for sentiment classification, and generating insights through visualization. The results aim to enhance brand image and consumer engagement by addressing feedback and leveraging positive discussions.

Uploaded by

sampole709
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

SMA Exp3

The experiment focuses on monitoring a brand's online reputation through social media mentions, sentiment analysis, and influencer identification. It involves data collection via web scraping and APIs, preprocessing of data, applying NLP techniques for sentiment classification, and generating insights through visualization. The results aim to enhance brand image and consumer engagement by addressing feedback and leveraging positive discussions.

Uploaded by

sampole709
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

DEPARTMENT OF COMPUTER

ENGINEERING
Experiment No. 03
Semester B.E. Semester VIII – Computer Engineering

Subject Social Media Analysis Lab

Subject Professor In-


Prof. Amit Aylani
charge

Academic Year 2024-25

Student Name Anurag Chaudhari

Roll Number 21102A0065

Title: Monitor the online reputation of a specific brand by collecting social media
mentions, analyzing the sentiment of these mentions, and identifying the top
influencers discussing the brand.
Description:

The primary goal of this experiment is to monitor the online reputation of a specific brand by collecting
social media mentions, analyzing their sentiment, and identifying key influencers discussing the brand. This
will help in understanding public perception, addressing negative feedback, and leveraging positive
discussions for brand growth.
Methodology:
1. Data Collection:
 Use web scraping and APIs (such as Twitter/X API, Facebook Graph API, and Reddit API) to collect
social media mentions related to the brand.
 Gather data including text, timestamps, user details, and engagement metrics (likes, shares,
retweets, comments).
2. Preprocessing:
 Remove stop words, emojis, special characters, and unnecessary metadata.
 Standardize text by converting to lowercase and applying lemmatization or stemming.
3. Sentiment Analysis:
 Apply NLP techniques to classify mentions as positive, negative, or neutral.
 Use pre-trained models like VADER (for short social texts) or fine-tuned transformer models (BERT,
RoBERTa) for sentiment classification.
4. Influencer Identification:
 Rank users based on engagement metrics (follower count, retweets, mentions, replies).
 Use network analysis to identify key opinion leaders discussing the brand.
5. Insights and Visualization:
 Generate sentiment trend graphs to track reputation over time.
 Create a network graph of influencers and their reach.
 Identify emerging patterns and topics associated with the brand.

SMA Lab - Semester VIII – Computer Engineering


Program Code:

!pip install asyncpraw

import praw
from textblob import TextBlob
import pandas as pd

CLIENT_ID = 'wR4s22ZsHO85tg5kvqpx7g'
CLIENT_SECRET = 'Ko7OcgyNlmVjupa-OlDaHbTmCwpURA'
USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'

reddit = praw.Reddit(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
user_agent=USER_AGENT,
check_for_async=False
)

def collect_mentions(brand_name, limit=10, comment_limit=5):


mentions = []
for submission in reddit.subreddit("all").search(brand_name,
limit=limit):
author_karma = getattr(submission.author, 'link_karma', 0)

mentions.append({
'type': 'post',
'text': submission.title + " " + submission.selftext,
'author': getattr(submission.author, 'name', 'Deleted'),
'karma': author_karma,
'upvotes': submission.score
})

submission.comments.replace_more(limit=0)
for comment in submission.comments[:comment_limit]:
mentions.append({
'type': 'comment',
'text': comment.body,
'author': getattr(comment.author, 'name', 'Deleted'),
'karma': getattr(comment.author, 'link_karma', 0),
'upvotes': comment.score
})

return mentions

SMA Lab - Semester VIII – Computer Engineering


def analyze_sentiment(mentions):
data = [{
'type': mention['type'],
'text': mention['text'],
'author': mention['author'],
'karma': mention['karma'],
'upvotes': mention['upvotes'],
'sentiment': TextBlob(mention['text']).sentiment.polarity
} for mention in mentions]
return pd.DataFrame(data)

def identify_top_contributors(df, top_n=5):


return (df.groupby('author')
.agg({'karma': 'max', 'upvotes': 'sum', 'sentiment': 'mean'})
.reset_index()
.sort_values(by=['upvotes', 'karma'], ascending=[False, False])
.head(top_n))

brand_name = "iphone"
mentions = collect_mentions(brand_name, limit=20, comment_limit=3)
df = analyze_sentiment(mentions)
top_contributors = identify_top_contributors(df, top_n=10)

df

top_contributors[['author', 'karma', 'sentiment', 'upvotes']]

print("Average Sentiment Score:", df['sentiment'].mean())

Output:

SMA Lab - Semester VIII – Computer Engineering


Conclusion:
This experiment enables the brand to monitor its online reputation by collecting social media mentions and
analyzing sentiment. By leveraging sentiment analysis, the brand can track public perception over time and
address both positive and negative feedback. Identifying top influencers helps the brand engage with key
opinion leaders, amplifying positive discussions and managing potential risks. The insights gained from this
process allow for data-driven decision-making, improved brand image, and better consumer engagement.
Continuous monitoring ensures timely responses to trends, fostering a stronger connection with the
audience.

SMA Lab - Semester VIII – Computer Engineering

You might also like