Entitäten mit spaCy extrahieren
Entitäten und ihre Labels auflisten
Entitäten mit spaCy extrahieren ist eine kostenlose NLP Academy-Lektion auf CoddyKit. Dies ist Lektion 2 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.
spaCy Does the Work
spaCy ships a trained NER component that finds entities for you. You feed it text and read back labeled spans. 🐍
Load a Model
First load a pipeline that includes NER. The small English model en_core_web_sm is a quick, friendly starting point.
import spacy
nlp = spacy.load("en_core_web_sm")Process Your Text
Pass a string into the pipeline to get a Doc object. The Doc holds tokens, sentences, and the entities spaCy found.
doc = nlp("Sundar Pichai leads Google in California.")The ents Property
Every Doc exposes doc.ents, a tuple of detected entities. Loop over it to inspect each one individually.
for ent in doc.ents:
print(ent)Read the Text
Each entity has a .text attribute holding the exact words matched. This is the raw span lifted from your sentence.
print(ent.text) # e.g. Sundar PichaiRead the Label
Use .label_ (with the trailing underscore) to get a readable label string like PERSON, ORG, or GPE.
print(ent.label_) # e.g. PERSONPutting It Together
One small loop prints both the text and label of every entity, turning a sentence into clean structured data.
for ent in doc.ents:
print(ent.text, ent.label_)Character Positions
Entities also expose start_char and end_char, the offsets in the original string. Handy for highlighting matches later.
print(ent.start_char, ent.end_char)Explain a Label
Forgot what GPE means? Call spacy.explain for a plain-English description of any entity label.
spacy.explain("GPE") # 'Countries, cities, states'Entities Are Spans
Each entity is a Span, a slice of the Doc. So it behaves like a mini-document you can further inspect token by token.
Collect Into a List
A quick comprehension gathers every entity into a list of tuples, ready to save, count, or feed into a report.
results = [(e.text, e.label_) for e in doc.ents]Quick Check
Which attribute gives the readable entity label?
Recap
Load a model, run nlp() on text, then loop doc.ents reading .text and .label_. That is core NER in spaCy. ✅
Häufig gestellte Fragen
Ist die Lektion „Entitäten mit spaCy extrahieren“ kostenlos?
Ja — der vollständige Text von „Entitäten mit spaCy extrahieren“ 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 „Entitäten mit spaCy extrahieren“?
Entitäten und ihre Labels auflisten 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 2 von 4.
Wie lange dauert die Lektion „Entitäten mit spaCy extrahieren“?
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
- Was gilt als Entität?
- Entitäten mit spaCy extrahieren
- Entitäten mit displaCy visualisieren
- Benutzerdefinierte Entitätsregeln hinzufügen