jenojp / negspacy

spaCy pipeline object for negating concepts in text
MIT License
274 stars 36 forks source link

Example from README is not working #31

Closed anapaulagomes closed 3 years ago

anapaulagomes commented 3 years ago

First of all, thanks for this awesome library.

Describe the bug When running the example from the README with the version 1.0.0 I get the following error:

TypeError: __init__() missing 4 required positional arguments: 'name', 'neg_termset', 'extension_name', and 'chunk_prefix'

To Reproduce

Steps to reproduce the behavior:

import spacy
from negspacy.negation import Negex

nlp = spacy.load("en_core_web_sm")
negex = Negex(nlp, ent_types=["PERSON","ORG"])

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() missing 4 required positional arguments: 'name', 'neg_termset', 'extension_name', and 'chunk_prefix'

Expected behavior

Expecting it to work as in the README example with the latest version.

Desktop (please complete the following information):

jenojp commented 3 years ago

whoops! That line was supposed to be removed from the README. Can you take a look and try again? Thank you for raising the issue!


nlp = spacy.load("en_core_web_sm")
nlp.add_pipe("negex", config={"ent_types":["PERSON","ORG"]})```
anapaulagomes commented 3 years ago

Is it working on your side? Here is still failing for this example:

ValueError: [E002] Can't find factory for 'negex' for language English (en). This usually happens when spaCy calls `nlp.create_pipe` with a custom component name that's not registered on the current language class. If you're using a Transformer, make sure to install 'spacy-transformers'. If you're using a custom component, make sure you've added the decorator `@Language.component` (for function components) or `@Language.factory` (for class components).

And for the next one too:

from negspacy.negation import Negex
from negspacy.termsets import termset

ts = termset("en")

nlp = spacy.load("en_core_web_sm")
nlp.add_pipe(
    "negex",
    config={
        "neg_tersmset":ts.get_patterns()
    }
)

Error:

thinc.config.ConfigValidationError: 

Config validation error

negex -> neg_tersmset   extra fields not permitted
jenojp commented 3 years ago

Sorry another typo in the README. Change "neg_tersmet" to "neg_termset". Thank you for pointing these out!

    "negex",
    config={
        "neg_termset":ts.get_patterns()
    }
)