0Pricing
NLP Academy · Lezione

Assegnare un punteggio a una recensione contando gli indizi

Sommare le occorrenze positive meno quelle negative

Assegnare un punteggio a una recensione contando gli indizi è una lezione NLP Academy gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento NLP Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso NLP Academy include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

The Core Idea

To judge a review, count positive cue words, count negative ones, and compare. This simple score already captures a lot of the feeling.

Tokenize First

Split the review into words before counting. Each token becomes one thing you can check against your positive and negative lists.

tokens = review.lower().split()

Count the Hits

Loop over the tokens and tally matches. Every word in the positive set adds to pos; every negative word adds to neg.

pos = sum(t in positive for t in tokens)
neg = sum(t in negative for t in tokens)

Subtract for a Score

The overall score is positive hits minus negative hits. A larger number means a happier review, and a negative one means complaints.

score = pos - neg

Turn Score Into a Label

Map the number to a verdict. A score above zero is positive, below zero is negative, and exactly zero is neutral.

label = "positive" if score > 0 else "negative" if score < 0 else "neutral"

A Worked Example

For I love this but the price is bad, you get one positive and one negative hit, so the score is zero, a neutral verdict.

Wrap It in a Function

Bundle the steps into a reusable function so you can score any review with a single call instead of repeating the logic.

def score_review(text):
    toks = text.lower().split()
    return sum(t in positive for t in toks) - sum(t in negative for t in toks)

Strengths of Counting

This method is fast, needs no training data, and is easy to explain. That transparency makes it a great first baseline for any project.

It Ignores Word Order

Counting treats text as a loose bag, so it cannot tell good not from not good. Losing order is its biggest blind spot.

Repeated Cues Add Up

Saying great, great, great counts three times and rightly pushes the score higher, since strong feeling often repeats key words.

When Counting Falls Short

Mixed reviews and subtle wording can produce a misleading zero. That is your signal a learned model may serve you better later.

Quick Check

Trace the logic on a short sentence.

Recap

You scored reviews by counting cues: tokenize, tally, subtract, then label by sign. It is fast and clear but ignores word order. Next we fix negation traps. ✅

Domande Frequenti

La lezione «Assegnare un punteggio a una recensione contando gli indizi» è gratuita?

Sì — il testo completo di «Assegnare un punteggio a una recensione contando gli indizi» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso NLP Academy, passa a CoddyKit PRO. Il corso NLP Academy include 4 lezioni in totale.

Cosa imparerò in «Assegnare un punteggio a una recensione contando gli indizi»?

Sommare le occorrenze positive meno quelle negative Eserciti NLP Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare NLP Academy?

Non è richiesta alcuna esperienza precedente. NLP Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.

Quanto tempo richiede la lezione «Assegnare un punteggio a una recensione contando gli indizi»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione NLP Academy?

Sì. Ogni lezione NLP Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Che cos'è l'analisi del sentiment?
  2. Creare un elenco di parole positive e negative
  3. Assegnare un punteggio a una recensione contando gli indizi
  4. Gestire negazioni e casi limite
← Torna a NLP Academy