🛠️ToolsShed

Contatore di Frequenza Parole

Analizza il testo e conta quante volte appare ogni parola, ordinato per frequenza.

Il contatore di frequenza delle parole analizza un blocco di testo e ti dice quante volte appare ogni parola, classificate dalla più alla meno comune. È uno strumento potente per scrittori, redattori, studenti e analisti di dati che hanno bisogno di capire la distribuzione del vocabolario di un documento o identificare parole usate eccessivamente.

Incolla il tuo testo e lo strumento lo tokenizza in parole individuali, normalizza le maiuscole ("The", "the" e "THE" contano come la stessa parola) e visualizza una tabella di frequenza ordinata per conteggio. Le parole vuote comuni possono essere filtrate per concentrarsi sulle parole di contenuto significativo.

L'analisi della frequenza delle parole ha applicazioni oltre la scrittura: in linguistica è alla base dei punteggi di leggibilità, nel marketing rivela i termini che i clienti usano di più e nel SEO aiuta a identificare la densità naturale delle parole chiave nel contenuto.

Domande Frequenti

Implementazione del Codice

from collections import Counter
import re

STOP_WORDS = {
    "a", "an", "the", "and", "or", "but", "in", "on", "at", "to",
    "for", "of", "with", "by", "from", "is", "are", "was", "were",
    "it", "this", "that", "be", "as", "not", "i", "you", "he", "she",
}

def word_frequency(text: str, stop_words: bool = True, top_n: int = 10) -> list[tuple[str, int]]:
    # Lowercase and extract words
    words = re.findall(r"[a-z']+", text.lower())
    if stop_words:
        words = [w for w in words if w not in STOP_WORDS]
    counter = Counter(words)
    return counter.most_common(top_n)

text = """To be or not to be, that is the question.
Whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune."""

for word, count in word_frequency(text):
    print(f"{word:<20} {count}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.