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

Does this work on spacy 3? #8

Open
dhirajsuvarna opened this issue Apr 26, 2022 · 2 comments
Open

Does this work on spacy 3? #8

dhirajsuvarna opened this issue Apr 26, 2022 · 2 comments

Comments

@dhirajsuvarna
Copy link

Hi,

I tried to use this in spacy 3, however, I got an error as spacy 3 has change add_pipe api inputs.

ValueError: [E966] `nlp.add_pipe` now takes the string name of the registered component factory, not a callable component. Expected string, but got <spacy_langdetect.spacy_langdetect.LanguageDetector object at 0x000001BF616DAF10> (name: 'language-detector').

- If you created your component with `nlp.create_pipe('name')`: remove nlp.create_pipe and call `nlp.add_pipe('name')` instead.

- If you passed in a component like `TextCategorizer()`: call `nlp.add_pipe` with the string name instead, e.g. `nlp.add_pipe('textcat')`.

- If you're using a custom component: Add the decorator `@Language.component` (for function components) or `@Language.factory` (for class components / factories) to your custom component and assign it a name, e.g. `@Language.component('your_name')`. You can then run `nlp.add_pipe('your_name')` to add it to the pipeline.
@haris525
Copy link

haris525 commented May 5, 2022

Yes it seems to be the old code...I didn't have time to figure out the exact issue, but you can use this code, and it will work.

import spacy 
nlp = spacy.load("en_core_web_sm") 
nlp.add_pipe("language_detector") 
doc = nlp('This is a second and this is another text') 
print(doc._.language)

@djohn156
Copy link

Hi, this didn't help for me, but this issue provided the right solution.

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

No branches or pull requests

3 participants