0Pricing
NLP Academy · Lektion

Satzzeichen und Symbole entfernen

Zeichen bereinigen, die Modelle verwirren

Satzzeichen und Symbole entfernen ist eine kostenlose NLP Academy-Lektion auf CoddyKit. Dies ist Lektion 3 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des NLP Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der NLP Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Punctuation Is Noise Too

After stopwords, the next clutter is symbols. Commas, dollar signs, and emoji can confuse a model, so we often strip punctuation away.

Why It Matters

Without cleanup, your model sees cat, and cat as two different tokens. That trailing comma splits one word into two features.

Python Knows the Marks

The string module hands you every common mark in one constant called punctuation, so you never type them out by hand.

import string
print(string.punctuation)

The translate Trick

The fastest way to delete characters is str.translate with a table that maps each mark to nothing at all.

table = str.maketrans("", "", string.punctuation)
clean = "hello, world!".translate(table)
print(clean)

Per-Token Cleaning

You can also strip marks token by token. Apply translate inside a comprehension, then drop any token that became empty.

clean = [t.translate(table) for t in tokens]
clean = [t for t in clean if t]

Regex for Symbols

Need more control than the fixed list? A regex can wipe anything that is not a letter, number, or space.

import re
clean = re.sub(r"[^a-zA-Z0-9 ]", "", text)

Beware of Useful Marks

Some symbols carry meaning. Stripping every dot turns u.s.a into usa, and that may not be what you want for your task.

Numbers Are a Choice

Digits are not punctuation, but they are often noise. Decide on purpose whether to keep or drop numbers for your data.

no_digits = re.sub(r"\d+", "", text)

Watch Unicode Symbols

The ASCII punctuation set misses curly quotes and emoji. A Unicode-aware regex catches the symbols a fixed list leaves behind.

clean = re.sub(r"[^\w\s]", "", text)

Collapse Extra Spaces

Removing marks can leave gaps and double spaces. A quick whitespace squeeze tidies the result back into clean words.

clean = re.sub(r"\s+", " ", clean).strip()

Order of Operations

Sequence matters. Strip punctuation before you split or compare, so trailing marks never sneak into your final tokens.

Quick Check

Pick the cleanest way to delete punctuation from a string.

Recap

You can now strip punctuation with translate or regex, handle Unicode and numbers on purpose, and squeeze leftover spaces for clean tokens.

Häufig gestellte Fragen

Ist die Lektion „Satzzeichen und Symbole entfernen“ kostenlos?

Ja — der vollständige Text von „Satzzeichen und Symbole entfernen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des NLP Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der NLP Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Satzzeichen und Symbole entfernen“?

Zeichen bereinigen, die Modelle verwirren Du übst NLP Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um NLP Academy zu starten?

Keine Vorkenntnisse erforderlich. NLP Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 3 von 4.

Wie lange dauert die Lektion „Satzzeichen und Symbole entfernen“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser NLP Academy-Lektion Code schreiben und ausführen?

Ja. Jede NLP Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Was sind Stopwörter?
  2. Stopwörter mit NLTK filtern
  3. Satzzeichen und Symbole entfernen
  4. Eine wiederverwendbare Funktion für sauberen Text erstellen
← Zurück zu NLP Academy