Py-Mood-Marker is a Python application designed to analyze conversational data, focusing on extracting sentiments and emotions from text. It reads data from a JSON file, processes each entry to determine the sentiment, emotional content, and overall intensity of sentiments, and outputs enhanced data with these additional metadata.
- Sentiment Analysis: Utilizes VADER (Valence Aware Dictionary and sEntiment Reasoner) to determine the overall sentiment intensity of the text.
- Emotion Analysis: Identifies various emotions present in the text using NRCLex.
- Contraction Expansion: Expands contracted forms (e.g., "I'm" to "I am") in the text for better analysis.
Before running the application, ensure you have the following Python packages installed:
- contractions
- NRCLex
- vaderSentiment
You can install these packages using pip:
pip install contractions nrclex vaderSentiment
- Place your JSON data file in the same directory as the script. The data file should be named
data.json
. - Run the script by executing the following command
python mark_mood.py
The script will process the data, perform sentiment and emotion analysis using VADER and NRCLex, expand contractions, and print the enhanced data to the console.
The input data file should be in the following format:
{"role": "caller", "text": "in what way what do you mean ?"}
{"role": "rep", "text": "It just not telling you the truth..."}
{"role": "rep", "text": "actually told me that ..."}
{"role": "rep", "text": "probably started..."}
This format consists of JSON objects with two key-value pairs: "role" and "text." The "role" indicates the speaker's role, and the "text" contains the spoken text.
The output format, after processing, will look like this:
{
"role": "caller",
"text": "is well because again it is still fresh...",
"vader_emotion_scores": {
"neg": 0.1,
"neu": 0.8,
"pos": 0.1,
"compound": 0.2
},
"emotion_scores": {
"joy": 3,
"positive": 3
}
}
In the output, the "role" and "text" remain the same, but additional metadata is added:
vader_emotion_scores
: A dictionary containing sentiment scores (negative, neutral, positive, and compound) from VADER analysis.emotion_scores
: A dictionary containing emotion scores based on NRCLex analysis.
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.