Creare un elenco di parole positive e negative
Il proprio lessico del sentiment
Creare un elenco di parole positive e negative è una lezione NLP Academy gratuita su CoddyKit. Questa è la lezione 2 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.
Meet the Lexicon
A lexicon is simply a list of words tagged with sentiment. It is the dictionary your rule-based detector will look words up in. 📖
Two Buckets to Start
Begin with two lists: positive words and negative words. Each list holds terms that reliably signal one feeling on their own.
Positive Words
Fill the positive set with words readers say when happy: good, great, love, excellent, amazing. Keep them lowercase for easy matching.
positive = {"good", "great", "love", "excellent", "amazing"}Negative Words
The negative set collects complaint words: bad, awful, hate, terrible, broken. These are the red flags your detector hunts for.
negative = {"bad", "awful", "hate", "terrible", "broken"}Why Use a Set
A Python set checks membership instantly, so testing if a word is positive stays fast even when your lists grow large.
Lowercase Everything
Great and GREAT should match the same entry, so store words lowercased and lowercase incoming text too. This keeps matching consistent.
Checking a Word
Looking a word up is one line. The in operator tells you instantly whether a term lives in your positive list.
word = "love"
is_pos = word in positiveBorrow a Ready Lexicon
You do not have to start blank. Tools like NLTK ship curated opinion lexicons with thousands of scored words you can reuse.
Watch for Overlap
A word should not sit in both lists, so keep your sets disjoint. Conflicts make scoring ambiguous and confuse your final label.
Domain Matters
Sentiment is domain-specific. For a hotel, quiet is positive; for a party, it is not. Tune the lexicon to your specific use case.
Keep It Growing
Treat your lists as living data. When the detector misses a clear cue, just add that word, so the lexicon steadily improves over time.
Quick Check
Think about why we chose this data structure.
Recap
You built a lexicon: positive and negative word sets, lowercased and disjoint, for fast lookups. You can borrow NLTK lists and tune them per domain. Next we score full reviews. ✅
Domande Frequenti
La lezione «Creare un elenco di parole positive e negative» è gratuita?
Sì — il testo completo di «Creare un elenco di parole positive e negative» è 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 «Creare un elenco di parole positive e negative»?
Il proprio lessico del sentiment 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 2 di 4.
Quanto tempo richiede la lezione «Creare un elenco di parole positive e negative»?
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
- Che cos'è l'analisi del sentiment?
- Creare un elenco di parole positive e negative
- Assegnare un punteggio a una recensione contando gli indizi
- Gestire negazioni e casi limite