Standalone punctuation breaks negation handling and reverses sentiment predictions
Maintainers usually reply within 2 days
@vivek-3728 is already working on this.
Since Nov 1, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 87/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- machine-learning
Research direction
The issue identifies the tokenizer in mess_mood/text.py and gives a reproduction for standalone punctuation between a negation word and the next word. Start by running those examples, then inspect the token cleanup and negation handling in that file. Add regression coverage for the listed examples; done means punctuation creates no empty features and the punctuated and unpunctuated sentences produce the same sentiment prediction.
Written by the indexing model from the issue text.
Description
Description
I found a bug in the tokenizer where punctuation appearing as a separate word creates empty tokens and interferes with negation handling.
As a result, adding punctuation to a sentence can completely reverse its sentiment prediction, even though the actual words remain unchanged.
Steps to Reproduce
Run:
from mess_mood.text import tokenize
print(tokenize("not fresh"))
print(tokenize("not ... fresh"))
print(tokenize("good ... food"))
Actual output:
['not_fresh']
['not_', 'fresh', 'not__fresh']
['good', '', 'food', 'good_', '_food']
The issue also affects the trained sentiment classifier:
from mess_mood.data import load_reviews
from mess_mood.evaluate import fit
model = fit(load_reviews())
print(model.predict("not fresh"))
print(model.predict("not ... fresh"))
Actual predictions:
negative
positive
Expected Behavior
Standalone punctuation should not generate empty tokens or interrupt negation.
Both "not fresh" and "not ... fresh" should produce the same meaningful features and sentiment prediction.
Actual Behavior
When punctuation is separated by whitespace, the tokenizer strips it into an empty string but continues processing it as a normal token.
This creates invalid features such as not_, good_, and _food.
More importantly, the empty token interrupts negation handling. Instead of recognizing not_fresh, the tokenizer processes fresh as a normal word, causing the classifier to change its prediction from negative to positive.
Root Cause
In mess_mood/text.py, punctuation is stripped using:
words = [w.strip(".,!?;:\"'()[]{}") for w in text.lower().split()]
However, tokens that become empty after stripping are not filtered out before stopword removal and negation processing.
Suggested Fix
Filter out empty tokens after punctuation stripping, before applying negation and feature-generation logic.
Regression tests should cover standalone punctuation, particularly between a negation word and the word it modifies.
Related Issue
This is related to #2, but the root cause is different.
Issue #2 concerned punctuation attached to words. This issue specifically concerns standalone punctuation creating empty tokens and breaking negation handling, resulting in incorrect sentiment predictions.
- Dominant language
- Python
- Stars
- 0
- Forks
- 3
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 13
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from techcsispit/mess-mood
-
k_fold: 3 of the 113 reviews are never in any 5-fold test foldPossibly taken @vivek-3728 claimed this 17 days ago. Openadvanced bug
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
techcsispit/mess-mood#14 · 2 comments · 1 assignee ·
Maintainers usually reply within 2 days
All issues in techcsispit/mess-mood
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
FinanceFlash/unvibecode#509 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
FAIRmat-NFDI/nomad-distro-dev#161 ·
-
bug v2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
modelcontextprotocol/python-sdk#3821 · 1 comment ·
Maintainers usually reply within 1 day
-
bug severity:low
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
Log-odds calibration uses upper middle score instead of median for even candidate setsPossibly taken @flysheep-ai claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day