induwara.lk
induwara.lkAI · Text

AI Sentiment Analyzer — Free, Server-Side, No Signup

Detect whether any English text reads as positive, negative, or neutral. A DistilBERT classifier runs server-side and an AFINN-111 lexicon runs alongside it as a transparent cross-check. No signup, no upload to a third-party UI, no model download to your browser.

By Induwara AshinsanaUpdated May 12, 2026
Detect sentimentDistilBERT · server-side
Sources cited
Inference runs server-side. Text is sent once for scoring and not stored.228 / 10,000
Try a sample
Two analyses run in one click: a DistilBERT classifier (server-side) and the AFINN-111 lexicon for a transparent second opinion.

What this does

Reads any English text and labels it as positive, negative, or neutral, with a confidence score. A DistilBERT classifier runs server-side; the AFINN-111 lexicon runs alongside it as a deterministic cross-check. For longer passages the result is broken down sentence-by-sentence so you can see where the tone swings.

Methodology: DistilBERT-SST-2 fine-tuned for binary sentiment with a confidence threshold of 65% to extract a third "neutral" class. Cross-checked against the AFINN-111 lexicon (186curated terms). Sources linked under “Sources” below.

How it works

The page runs two independent analyses on the same input and shows both, side by side. They use very different methods, and watching them agree (or disagree) is the fastest way to judge how trustworthy a single reading is.

1. Transformer model (server-side)

The primary classifier is distilbert/distilbert-base-uncased-finetuned-sst-2-english, a DistilBERT model fine-tuned on the Stanford Sentiment Treebank v2 corpus. We call the Hugging Face Inference API (api-inference.huggingface.co) from a server-only Next.js route handler. The browser never downloads model weights — the only payload it sends is your text, and the only payload it receives is a small JSON result. The same route is reused for batch scoring: the whole text plus each sentence (up to a cap) are sent in one request so we avoid round-trip overhead on longer passages.

The SST-2 head outputs two probabilities (POSITIVE and NEGATIVE) that sum to 1. To get a third "neutral" class without retraining we treat low-confidence outputs as neutral: if the top probability is below 65%, the result is reclassified. The threshold is deliberate — neutral passages tend to push a binary classifier toward 50/50, so the confidence itself is the signal.

2. AFINN-111 lexicon (cross-check, always on)

The second pass is a word-by-word lookup against a curated subset of AFINN-111, the public-domain sentiment lexicon by Finn Årup Nielsen. Tokens are NFKC-normalized, lowercased, stripped of punctuation, and summed against their integer valence scores (-5 ... +5). The sum is divided by token count to give a comparative score; values above +0.15 are positive, below -0.15 are negative, the rest are neutral. The exact formula:

comparative = Σ valence(t) for t in tokens(text)
              ─────────────────────────────────────
                       count(tokens(text))

if comparative ≥ +0.15 → positive
if comparative ≤ −0.15 → negative
otherwise              → neutral

The AFINN pass is pure JavaScript with no API call, so it always runs even when neural inference is not configured on this build. It is also fully deterministic — the same text always produces the same score — which is useful for spot-checking or for cases where you need a sentiment value you can reproduce offline.

3. Per-sentence breakdown

For inputs of more than one sentence, both passes run separately on each split (terminal punctuation followed by whitespace, or a line break). This surfaces swings the overall label hides — a glowing review with one buried complaint, an otherwise-flat news paragraph that turns sharply at the end. The split drops fragments shorter than eight characters so emojis, abbreviations, and stray punctuation don't get their own row.

Both analyses are deterministic given the same input. The HF Inference API is stateless: every call is independent and we send no identifiers. If the API is rate-limited or unreachable, the lexicon result is still returned so the page never shows a dead state.

Worked examples

Glowing review

I just got back from dinner at The Lagoon and it was wonderful. The fish was perfectly cooked, the service was attentive without being intrusive, and the view at sunset is genuinely stunning.

  1. Model: POSITIVE with ≈ 0.99 confidence (passes 0.65 threshold) → positive
  2. AFINN hits: wonderful(+4), stunning(+4) → score = +8
  3. Comparative = +8 / ≈ 30 tokens ≈ +0.27 → positive
  4. Per-sentence: all three sentences trip the POSITIVE class
  5. Verdict: model & lexicon agree → confident positive

Bad-service complaint

Booked an airport pickup through their app and the driver never showed up. Support took forty minutes to answer and then blamed me for the cancellation.

  1. Model: NEGATIVE with ≈ 0.98 confidence → negative
  2. AFINN hits: never(−1) → score = −1, comparative ≈ −0.04 → neutral
  3. Per-sentence: both sentences scored NEGATIVE by the model
  4. Verdict: model says negative confidently; AFINN's hit list is thin because the complaint is descriptive rather than name-calling — this is exactly where the neural model earns its keep

Neutral edge case

The Central Bank of Sri Lanka announced that the next monetary policy review will take place on the third Tuesday of next month.

  1. Model: POSITIVE 0.58 → below 0.65 threshold → reclassified neutral
  2. AFINN hits: none → score = 0 → comparative = 0 → neutral
  3. Verdict: agreement, neutral. Demonstrates the threshold rule turning a hedged binary output into a faithful three-class label.

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a misclassification, edge case, or have a model suggestion?

Email me at [email protected] — most fixes ship within 24 hours.