Fix example code for spacy-wordnet (#11593)

* Fix example code for spacy-wordnet

It looks like in the most recent version, 0.1.0, it's no longer possible
to pass the lang parameter to the component separately. Doing so will
raise an error.

* Apply suggestions from code review

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>

* Cleanup

* More cleanup

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
This commit is contained in:
Paul O'Leary McCann 2022-10-11 23:45:05 +09:00 committed by GitHub
parent 29649589fc
commit 2e52479eec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2460,20 +2460,20 @@
"import spacy",
"from spacy_wordnet.wordnet_annotator import WordnetAnnotator ",
"",
"# Load an spacy model (supported models are \"es\" and \"en\") ",
"nlp = spacy.load('en')",
"# Spacy 3.x",
"nlp.add_pipe(\"spacy_wordnet\", after='tagger', config={'lang': nlp.lang})",
"# Spacy 2.x",
"# Load a spaCy model (supported languages are \"es\" and \"en\") ",
"nlp = spacy.load('en_core_web_sm')",
"# spaCy 3.x",
"nlp.add_pipe(\"spacy_wordnet\", after='tagger')",
"# spaCy 2.x",
"# nlp.add_pipe(WordnetAnnotator(nlp.lang), after='tagger')",
"token = nlp('prices')[0]",
"",
"# wordnet object link spacy token with nltk wordnet interface by giving acces to",
"# WordNet object links spaCy token with NLTK WordNet interface by giving access to",
"# synsets and lemmas ",
"token._.wordnet.synsets()",
"token._.wordnet.lemmas()",
"",
"# And automatically tags with wordnet domains",
"# And automatically add info about WordNet domains",
"token._.wordnet.wordnet_domains()"
],
"author": "recognai",