UNIT-V
Rubric: 10m Code + 5m Viva +
5m Record
EASY
10 Marks
Session: 59:59
Bubblewrap Sandbox Active
Problem Statement
In social media analytics (JNTU-GV MCA UNIT-V), sentiment analysis classifies customer feedback into POSITIVE, NEGATIVE, or NEUTRAL opinions based on opinion mining lexicon weights.
You are given:
1. A list of known positive sentiment terms.
2. A list of known negative sentiment terms.
3. A student or customer social media post.
Calculate the net sentiment score: (Count of Positive Words - Count of Negative Words).
- If Net Score > 0 -> Print "POSITIVE"
- If Net Score < 0 -> Print "NEGATIVE"
- If Net Score == 0 -> Print "NEUTRAL"
Input Format
Line 1: Positive words separated by space.
Line 2: Negative words separated by space.
Line 3: The social media text post to analyze.
Output Format
Print POSITIVE, NEGATIVE, or NEUTRAL.
Constraints
Case-insensitive word comparison.
Post length <= 1000 characters.
Status
Lang
Score
Time
Submitted
No prior submissions for this problem.
Ready
Click Run Code to evaluate against sample test
cases, or Submit Solution for full evaluation.
No compiler or execution errors recorded.
#include <stdio.h>
int main() { return 0; }
#include <iostream>
using namespace std;
int main() { return 0; }
import java.util.*;
public class Main {
public static void main(String[] args) {
// Your Java solution
}
}
import sys
def main():
lines = sys.stdin.read().splitlines()
if len(lines) < 3:
return
pos_words = set(lines[0].lower().split())
neg_words = set(lines[1].lower().split())
post_words = lines[2].lower().split()
score = 0
for w in post_words:
if w in pos_words:
score += 1
elif w in neg_words:
score -= 1
if score > 0:
print("POSITIVE")
elif score < 0:
print("NEGATIVE")
else:
print("NEUTRAL")
if __name__ == "__main__":
main()