aolieman / pyspotlight Goto Github PK
View Code? Open in Web Editor NEWThis project forked from ubergrape/pyspotlight
A thin wrapper around the DBpedia Spotlight HTTP API
License: Other
This project forked from ubergrape/pyspotlight
A thin wrapper around the DBpedia Spotlight HTTP API
License: Other
Hello,
I tried pyspotlight. First I installed it:
sudo pip3 install pyspotlight
I also tried just using pip, not pip3.
Then I ran the example code. It says
ModuleNotFoundError: No module named 'spotlight'
Can you give me a hint whats wrong? I tried python 2.7 and python 3.7.
Dear @aolieman
ANy help to solve this issue please
File "/project/6008168/tamouze/Python_directory/pyspotlight/test.py", line 2, in <module>
annotations = spotlight.annotate('http://localhost/rest/annotate', 'Your test text', confidence=0.4, support=20)
File "/project/6008168/tamouze/Python_directory/pyspotlight/spotlight/__init__.py", line 192, in annotate
pydict = _post_request(address, payload, filters, headers)
File "/project/6008168/tamouze/Python_directory/pyspotlight/spotlight/__init__.py", line 48, in _post_request
response = requests.post(address, data=payload, headers=reqheaders)
File "/home/tamouze/.local/easybuild/software/2017/Core/miniconda2/4.3.27/lib/python2.7/site-packages/requests/api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "/home/tamouze/.local/easybuild/software/2017/Core/miniconda2/4.3.27/lib/python2.7/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/home/tamouze/.local/easybuild/software/2017/Core/miniconda2/4.3.27/lib/python2.7/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/home/tamouze/.local/easybuild/software/2017/Core/miniconda2/4.3.27/lib/python2.7/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/home/tamouze/.local/easybuild/software/2017/Core/miniconda2/4.3.27/lib/python2.7/site-packages/requests/adapters.py", line 508, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: /rest/annotate (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x2b70b3e99850>: Failed to establish a new connection: [Errno 111] Connection refused',))
hi, I came across a problem when using your tool.
I have to process a list of sentence. Every sentence have to be linked to the API. SO I don't want to the SpotlightException to interrupt the whole process.
is there any to ignore the SpotlightException?
here is my code:
with open('/home/tfang/data/corpus/mr.clean.txt', "r") as f:
for line in f.readlines():
doc_list.append(line.strip())
text = line.strip()
entity_current = []
annotations = spotlight.annotate('http://localhost:2222/rest/annotate', \
text, confidence=0.5, support=0)
if annotations !=None:
for resource_i in annotations:
entity_current.append(resource_i["URI"][28:])
print(entity_current)
entity_list.append(entity_current)
with open("/home/tfang/data/process/entity_mr", "wb") as f:
json.dump(entity_list, f)
here is the output in the console:
Traceback (most recent call last): File "entity_link.py", line 21, in <module> text, confidence=0.5, support=0) File "/home/tfang/anaconda3/envs/torch1.6/lib/python3.6/site-packages/spotlight/__init__.py", line 196, in annotate 'No Resources found in spotlight response: %s' % pydict spotlight.SpotlightException: No Resources found in spotlight response: {'@text': 'idiotic and ugly', '@confidence': '0.5', '@support': '0', '@types': '', '@sparql': '', '@policy': 'whitelist'}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.