Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpaCy Lemmatizer use in Lesson 2 #3

Open
EdwardJRoss opened this issue Jul 12, 2019 · 5 comments · May be fixed by #4
Open

SpaCy Lemmatizer use in Lesson 2 #3

EdwardJRoss opened this issue Jul 12, 2019 · 5 comments · May be fixed by #4

Comments

@EdwardJRoss
Copy link

In 2-svd-nmf-topic-modeling.ipynb under the section Spacy you use:

from spacy.lemmatizer import Lemmatizer
lemmatizer = Lemmatizer()
[lemmatizer.lookup(word) for word in word_list]

Unfortunately this creates an empty lemmatizer that will just always return what's input, and may give the wrong impression.

Instead you should use something like:

nlp = spacy.load("en_core_web_sm")
lemmatizer = nlp.Defaults.create_lemmatizer()
[lemmatizer.lookup(word) for word in word_list]

Also the command to download the English model at the start of this section is written as:
spacy -m download en_core_web_sm
when it should either be python -m spacy download en_core_web_sm or spacy download en_core_web_sm

Thanks

@EdwardJRoss EdwardJRoss linked a pull request Jul 12, 2019 that will close this issue
@elishadammie
Copy link

thanks for the assistance

@elishadammie
Copy link

I have issues with lecture 2.

nlp = spacy.load("en")

it returns an error

@gorgi
Copy link

gorgi commented Feb 2, 2020

In Spacy version 2.2.3, the parameterless constructor is removed. The code now shows error:

TypeError: init() missing 1 required positional argument: 'lookups'

Thanks for the workaround @EdwardJRoss

@huum4n
Copy link

huum4n commented Oct 1, 2021

change in spacy v3
https://spacy.io/usage/linguistic-features#lemmatization
as in the discussion below:
explosion/spaCy#9235

If you install the package spacy-lookups-data, you can replace the rule-based lemmatizer with a lookup lemmatizer.

pip install spacy[lookups]

this is a workaround for spacy v3

nlp = spacy.blank('en')
nlp.add_pipe('lemmatizer', config={'mode':'lookup'}).initialize()
[nlp(word)[0].lemma_ for word in word_list]

@juliewu-md
Copy link

This seems to not immediately fail: https://issueexplorer.com/issue/fastai/course-nlp/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants