PIXELBANKv8.2.1
Menu

Sentiment Word Counter

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:

  • Line 1: Comma-separated positive words
  • Line 2: Comma-separated negative words
  • Line 3: The text to analyze

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.

Example:

Input:
good,great,happy
bad,sad,terrible
I feel good and great today
Output:
positive 2 negative 0 positive
Reasoning:

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"

Constraints:

  • Case-insensitive matching
  • Words compared after lowercasing
  • Output format: "positive X negative Y LABEL"
Editor

Test Results

0/0
Run code to see test results.