CommencerCommencez gratuitement

Vocabulaire, hachages et lexèmes

Pourquoi ce code génère-t-il une erreur ?

from spacy.lang.en import English
from spacy.lang.de import German

# Create an English and German nlp object
nlp = English()
nlp_de = German()
# Get the ID for the string 'Bowie'
bowie_id = nlp.vocab.strings['Bowie']
print(bowie_id)

# Look up the ID for 'Bowie' in the vocab
print(nlp_de.vocab.strings[bowie_id])

La classe de langue English est déjà disponible sous forme d’objet nlp.

Cet exercice fait partie du cours

<cours>NLP avancé avec spaCy</cours>
Voir le cours

Exercice interactif pratique

Transformez la théorie en action avec l’un de nos exercices interactifs

Commencer l’exercice