Loading...
Given a text and two lists of words (positive and negative), count how many positive and negative words appear in the text and determine the overall sentiment.
Input format:
Output: Print "positive X negative Y LABEL" where X and Y are counts, and LABEL is "positive" if X > Y, "negative" if Y > X, or "neutral" if equal.
All matching is case-insensitive.
good,great,happy bad,sad,terrible I feel good and great today
positive 2 negative 0 positive
Step 1: Parse word lists Positive: {good, great, happy} Negative: {bad, sad, terrible}
Step 2: Count in text "i feel good and great today" Positive matches: "good", "great" → 2 Negative matches: none → 0
Step 3: Determine label 2 > 0 → "positive"