Sentiment Analysis for a CSV Column
Operator: Abdulla Al Fahad. How tools are built and checked
"Good value but the lid is a bit awkward" scores -0.30 here, a mild negative, and "Not bad at all - boils fast and looks great" scores +0.90. Those two numbers show what this tool does: it reads each text with a handful of transparent rules over a 404-word lexicon, and it can optionally run a small neural network over the same rows so you can see where the two disagree.
Both methods are for English text. The rule-based scorer is instant and explainable word by word; the neural model is better at phrasing it has seen and worse at being explained. Neither knows your product, sarcasm or a domain's slang, so treat the output as a first pass over a column, not a verdict on any one row.
Key features
- A VADER-style scorer written for this site, with its lexicon of valences from -3.6 to +3.6
- Negation within three words, intensifiers and dampeners, all-capitals emphasis and exclamation marks
- The word "but" shifts weight to what follows it
- A small set of emoticons and emojis
- A box where you can type one sentence and see which words counted and by how much
- An optional DistilBERT sentiment model that runs on your device, with download progress and cancel
- Score, label, and for model rows a confidence and an agreement flag
How the rule-based scorer and the neural model each label a row
Choose the text column; every other column is kept and carried into the export. Rows with empty text get no score and no label, and are counted separately. An optional comparison column (product, month, channel) gives the mean score and the share of positive and negative rows for each of its 25 largest values. Files up to 25 MB and 300,000 rows are scored by the rule-based method; the neural model is limited to the first 2,000 rows and each text is cut at 1,500 characters.
How it works
Each lexicon word carries a valence. A booster word such as very or extremely among the three words before it adds 0.293 (the closest word counts fully, the next 0.95 times, the third 0.9 times) in the direction of the valence; a dampener such as slightly subtracts it. A negation word such as not, never or any word ending in n't in the same three-word window multiplies the valence by -0.74, so "not good" is about -1.8 and "not bad" is about +2.3. An all-caps word in mixed-case text adds 0.733.
Words before the word but count half, and words after count one and a half. The valences are summed; up to four exclamation marks add 0.292 each in the direction of the sum, and more than one question mark adds a little more. The sum x becomes a compound score between -1 and 1 as x divided by the square root of x squared plus 15. A compound of at least 0.05 is labelled positive, at most -0.05 negative, otherwise neutral.
The neural model is Xenova/distilbert-base-uncased-finetuned-sst-2-english, a DistilBERT network fine-tuned on single sentences from movie reviews (the Stanford SST-2 task), converted for the browser in 8-bit form. Its base model carries the Apache-2.0 licence. The first run downloads about 68 MB from Hugging Face, and the ONNX runtime comes from this site; the browser then caches both. The model returns only positive or negative with a confidence, so it has no neutral class, and a very short or flat text still gets a side.
Agreement is counted only where the rule-based scorer picked a side, since it is the only one that can say neutral.
Common use cases
- Scoring 5,000 product reviews, comparing the mean score of each product, and reading the 200 rows where the rule-based and neural labels disagree
- Scoring the comment column of a survey export; the NPS Calculator on this site then compares the words promoters and detractors use, so the two views can be read together
How to use this tool
- Upload the file or load the example and confirm the text column.
- Read the rule-based counts and the distribution of scores; optionally pick a column to compare.
- Optionally run the model and wait for the download and scoring to finish, or cancel at any time.
- Type a few of your own sentences into the box to see which words drive the score.
Example
Ten product reviews (load example)
id,product,review
1,Desk lamp,Love it! Bright and the setup was easy.
2,Desk lamp,Arrived late and the switch is broken. Very disappointing.
3,Desk lamp,It's fine. Does the job.
4,Kettle,Not bad at all - boils fast and looks great
5,Kettle,TERRIBLE. Stopped working after a week and support was useless.
6,Kettle,Good value but the lid is a bit awkward
7,Backpack,Comfortable and sturdy. Best bag I've owned!!
8,Backpack,The zipper broke and customer service never replied
9,Backpack,Delivered on Tuesday
10,Backpack,I don't hate it but I wouldn't recommend itRule-based scores
1 +0.904 positive Love, Bright, easy
2 -0.886 negative late, broken, disappointing (boosted by Very)
3 +0.226 positive fine
4 +0.896 positive bad (negated), fast, great
5 -0.833 negative TERRIBLE (caps), support (+1.6), useless
6 -0.296 negative Good (halved by but), awkward (x1.5)
7 +0.862 positive Comfortable, Best
8 -0.527 negative broke
9 0.000 neutral
10 -0.510 negative hate (negated, halved), recommend (negated, x1.5)
4 positive, 1 neutral, 5 negativeTips for best results
- Sort the exported file by score and read both ends and the middle. The rows near zero are where mixed reviews and missed phrasing hide.
- Run the model on a sample and read only the disagreements. They are the quickest way to learn what your own data does to each method.
- Add your own strong words by testing them in the sentence box first. If a domain word such as sick or killer is neutral here, that is a lexicon gap, not a bug in your file.
Common pitfalls
Lexicon scoring only sees words it knows. Complaints phrased with plain words, such as "the battery does not work", score 0 here.
A negation window of three words is a heuristic. "I don't think it is good" is handled; a long clause between not and the adjective is not.
The model was tuned on movie-review sentences. Product reviews, tickets and tweets are close enough to work often, but legal, medical and non-English text are not what it was trained on.
Labels are for aggregate patterns. Do not use them to decide anything about an individual customer or employee from one score.
Common errors and how to fix them
- The model download fails or stalls
- The model files come from Hugging Face. A content blocker, a network restriction or a corporate proxy can stop them. The rule-based results are unaffected.
- "The browser ran out of memory while running the model"
- Close other heavy tabs or lower the row count by splitting the file; the model reads at most 2,000 rows per run.
Where each method fails
These are real outputs from the scorer, included because they are the cases that matter when you read your own results:
- "Great, another update that breaks everything" scores +0.18 (positive): the lexicon sees great and breaks and cannot read sarcasm.
- "I expected better" scores +0.53 (positive): better is positive and nothing in the rules knows it describes a shortfall.
- "Not great, not terrible" scores +0.10, barely positive: both negations flip the words correctly, and the sum is a small number that the thresholds call positive.
- "The battery does not work" and "This phone is sick" both score 0: neither contains a word in the lexicon.
- Text in other languages is scored as neutral because no word matches.
Choosing between the two methods
Use the rule-based score when you need to explain a result: the sentence box shows every word that counted, you can score 300,000 rows in a moment, and nothing is downloaded. Use the model when the texts are full sentences that look like reviews, because it reads phrasing the lexicon cannot, such as complaints written with plain words.
The most useful output is often the disagreement. Where the two methods give opposite signs, the text is usually mixed, sarcastic, or written in a style one of them has not seen, and those are the rows worth reading by hand before you trust an average.
Frequently asked questions
Is the lexicon the same as the original VADER one?
No. The rules follow the VADER design, including the constants for boosters, negation and capitals, but the lexicon is a separate list of about 400 words written for this tool, so scores will not match the published VADER values.
Why does the model not have a neutral label?
The SST-2 task it was fine-tuned on is binary, so it only outputs positive or negative with a confidence. A confidence near 50% is its way of saying it is unsure.
What does the agreement figure measure?
Among rows where the rule-based scorer chose positive or negative, the share where the model chose the same side. It says how often the two methods agree, not which one is right.