-
Notifications
You must be signed in to change notification settings - Fork 95
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
about nlp.add_pipe
in the demo
#79
Comments
It can be used like this. import spacy
from spacy.language import Language
from quickumls.spacy_component import SpacyQuickUMLS
@Language.component('quickumls_component')
def quickumls_component(doc):
return SpacyQuickUMLS(nlp, <Path to quickUmls install dir>)(doc)
nlp.add_pipe('quickumls_component', last=True)
doc = nlp(full_rpts.iloc[0]) |
Hi everyone, |
@shrimonmuke0202 did you solve this problem?? |
Hi there, thank you so much for sharing a solution! I was able to get past the add_pipe error but not further. Could you explain what the line of code on doc = nlp(full_rpts.iloc[0]) does? I was trying to put into something like |
full_rpts.iloc[0] returns a string from pandas dataframe, so def quickumls_component(doc):
return SpacyQuickUMLS(nlp, <Path to quickUmls install dir>)(doc) |
Is the Path to quickUmls install dir supposed to be the same as quickumls_fp in this code block?
If so, I am doing this yet get this message:
and no output from the print statements from the code in OP's block However, this works fine
But I am trying to implement medspacy as I extract items from the QuickUMLS output in a super inneficient way and this seems like the proper way. For what it's worth, this is how I do it:
|
Describe the bug
when i run the demo code,there something wrong about “nlp.add_pipe(quickumls_component)”,
Traceback (most recent call last):
File "umlsdemo.py", line 8, in
nlp.add_pipe(quickumls_component)
File "/home/mayt/anaconda3/envs/umls/lib/python3.7/site-packages/spacy/language.py", line 769, in add_pipe
raise ValueError(err)
ValueError: [E966]
nlp.add_pipe
now takes the string name of the registered component factory, not a callable component. Expected string, but got <quickumls.spacy_component.SpacyQuickUMLS object at 0x7f24b35e5cd0> (name: 'None').If you created your component with
nlp.create_pipe('name')
: remove nlp.create_pipe and callnlp.add_pipe('name')
instead.If you passed in a component like
TextCategorizer()
: callnlp.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 runnlp.add_pipe('your_name')
to add it to the pipeline.To Reproduce
**Environment **
Additional context
it seems relate to spacy accroding to https://stackoverflow.com/questions/67906945/valueerror-nlp-add-pipe-now-takes-the-string-name-of-the-registered-component-f while i still don't konw how to modify the code~~
The text was updated successfully, but these errors were encountered: