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

Install error on negspacy (pip install) #1

Closed
GB-TA opened this issue Aug 15, 2019 · 5 comments
Closed

Install error on negspacy (pip install) #1

GB-TA opened this issue Aug 15, 2019 · 5 comments

Comments

@GB-TA
Copy link

GB-TA commented Aug 15, 2019

Describe the bug
Getting the below error with pip install negspacy command in Anacondo Prompt.

To Reproduce
Steps to reproduce the behavior:
Run Anaconda Prompt as Administrator
type - pip install negspacy and enter
Expected behavior
negspacy package gets install and should be present in C:\ProgramData\Anaconda3\Lib\site-packages

Screenshots
(base) C:\WINDOWS\system32>pip install C:\negspacy-0.1.0a0.tar.gz
Processing c:\negspacy-0.1.0a0.tar.gz
ERROR: Command errored out with exit status 1:
command: 'c:\programdata\anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\xx\AppData\Local\Temp\pip-req-build-4b2hz8em\setup.py'"'"'; file='"'"'C:\Users\xx\AppData\Local\Temp\pip-req-build-4b2hz8em\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: C:\Users\xxAppData\Local\Temp\pip-req-build-4b2hz8em
Complete output (7 lines):
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\xx\AppData\Local\Temp\pip-req-build-4b2hz8em\setup.py", line 10, in
long_description=open("README.md").read(),
File "c:\programdata\anaconda3\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 274: character maps to
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Desktop (please complete the following information):

  • OS: Windows

Additional context
Add any other context about the problem here.

@jenojp
Copy link
Owner

jenojp commented Aug 16, 2019

Hi, thank you for raising this issue. Please try installing again and let me know if you continue to get the issue.

pip install negspacy --upgrade

I think I fixed the windows decoding issue.

@jenojp
Copy link
Owner

jenojp commented Aug 16, 2019

Replicated the issue on azure and had no issue when installing the new version. Let me know if you're still having the problem. Thanks!

@GB-TA
Copy link
Author

GB-TA commented Aug 16, 2019

Thank Jeno for fixing the issue with negspacy install. I was able to install negspacy and import the packages.

Ran:
nlp = spacy.load("en_core_web_sm")
negex = Negex(nlp)
nlp.add_pipe(negex, last=True)
Im trying to see how negation works with different scenarios:
doc = nlp(" Client is not on the Terrorists watchlist.")
Result:
Terrorists True
doc = nlp(" Client is not on the Terrorists Watch list.")
Result:
Terrorists True
doc = nlp(" Client is not on the Terrorist Watchlist.")
Result : NULL
doc = nlp(" Client is not on the Terrorists watch list.")
Result : NULL
doc = nlp(" Client is not on the terrorists watch list.")
Result : NULL

doc = nlp("Client is not affiliated to Soverign citizen.")
Result : Soverign True
doc = nlp("Client is not affiliated to soverign citizen.")
Result : NULL

Could you please check and explain why the negation detection is failing with some texts which is very close to how the successful ones are written? Is there a NER dictionary that is being being used behind the seen to identify Org entities?
Please let me know if there is a way to fix this

@jenojp
Copy link
Owner

jenojp commented Aug 16, 2019

Oh good! I'm glad that issue is resolved.

Yes - You're using the built in spaCy NER in the backend. If you have a specific dictionary of entities you'd like to process, I would suggest using the EntityRuler in spaCy. Just make sure it's added "ahead" of the negation component in the processing pipeline.

This way you could make your own new entities or add patterns to existing ones.

import spacy
from spacy.pipeline import EntityRuler
from negspacy.negation import Negex

nlp = spacy.load("en_core_web_sm")
ruler = EntityRuler(nlp)
patterns = [{"label": "MYENT", "pattern": [{"LOWER": "sovereign"}, {"LOWER": "citizen"}]}]
# add others in patterns list

ruler.add_patterns(patterns)
nlp.add_pipe(ruler)

negex = Negex(nlp)
nlp.add_pipe(negex, last=True)

doc = nlp("Client is not affiliated to sovereign citizen.")

 for e in doc.ents:
    print(e.text, e._.negex)

@jenojp jenojp closed this as completed Aug 16, 2019
@GB-TA
Copy link
Author

GB-TA commented Aug 17, 2019

Thank you! Looking forward to enhancements on this. Great work with this package!

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

2 participants