This project analyzes Twitter data to determine the sentiment of tweets based on positive and negative word lists. It calculates positive scores, negative scores, and net scores for each tweet, and stores the results in a CSV file.
sentiment_analysis.py
: The main Python script for analyzing Twitter data.project_twitter_data.csv
: Input CSV file containing Twitter data (Number of Retweets, Number of Replies, Tweet Text).positive_words.txt
: List of positive words used for sentiment analysis.negative_words.txt
: List of negative words used for sentiment analysis.resulting_data.csv
: Output CSV file containing the analyzed data.
- Make sure you have the necessary input files (
project_twitter_data.csv
,positive_words.txt
, andnegative_words.txt
). - Run the
sentiment_analysis.py
script. - The script will generate a new file called
resulting_data.csv
containing the analyzed data.
- strip_punctuation(wrd): Removes punctuation characters from a word.
- get_pos(sentences): Counts the number of positive words in a sentence.
- get_neg(sentences): Counts the number of negative words in a sentence.
The main script reads Twitter data from project_twitter_data.csv
, analyzes the sentiment of each tweet, and writes the results to resulting_data.csv
.
- Number of Retweets
- Number of Replies
- Positive Score
- Negative Score
- Net Score
python sentiment_analysis.py
# social-media-sentiment-analysis