LoslegenKostenlos loslegen

Simple components

The example shows a custom component that prints the character length of a document. Can you complete it? spacy has already been imported for you.

Diese Übung ist Teil des Kurses

Advanced NLP with spaCy

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Define the custom component
def length_component(doc):
    # Get the doc's length
    doc_length = ____
    print("This document is {} tokens long.".format(doc_length))
    # Return the doc
    ____
Code bearbeiten und ausführen