getting resource name from text using pyspotlight tool - spotlight-dbpedia

I am trying to find resource name from the text using pyspotlight.suppose the text is "Barack Obama is tall" ,then the program should return Barack Obama as dbpedia resource.But the program showing "equests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://github.com/dbpedia-spotlight/dbpedia-spotlightrest/" error.How to solve it.
import spotlight
annotations = spotlight.annotate('http://spotlight.dbpedia.org/rest/','Barack Obama is tall',confidence=0.4, support=20)
print(annotations)
File "word.py", line 2, in
annotations = spotlight.annotate('http://spotlight.dbpedia.org/rest/','Barack Obama is tall',confidence=0.4, support=20)
File "/home/junlplab/.local/lib/python2.7/site-packages/spotlight/init.py", line 189, in annotate
pydict = _post_request(address, payload, filters, headers)
File "/home/junlplab/.local/lib/python2.7/site-packages/spotlight/init.py", line 51, in _post_request
response.raise_for_status()
File "/home/junlplab/.local/lib/python2.7/site-packages/requests/models.py", line 937, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://github.com/dbpedia-spotlight/dbpedia-spotlightrest/

decreasing confidence and support may gives requested answer,
try this:
annotations = spotlight.annotate('http://spotlight.dbpedia.org/rest/','Barack Obama is tall',confidence=0.0, support=0)

Related

I am getting this error: MermaidExtension.extendMarkdown() missing 1 required positional argument: 'md_globals'

This was working not too long ago (probably inadvertently upgraded a library somewhere.) All of my libraries are up to date.
Here is the stack trace:
File "C:\Users\jorda\Documents\projects\python\poolBoy\flaskApp.py", line 422, in about
html += markdown.markdown(text, extensions=['md_mermaid', 'fenced_code', 'tables'])
File "C:\Users\jorda\Documents\projects\python\poolBoy\venv\lib\site-packages\markdown\core.py", line 386, in markdown
md = Markdown(**kwargs)
File "C:\Users\jorda\Documents\projects\python\poolBoy\venv\lib\site-packages\markdown\core.py", line 96, in __init__
self.registerExtensions(extensions=kwargs.get('extensions', []),
File "C:\Users\jorda\Documents\projects\python\poolBoy\venv\lib\site-packages\markdown\core.py", line 125, in registerExtensions
ext.extendMarkdown(self)
TypeError: MermaidExtension.extendMarkdown() missing 1 required positional argument: 'md_globals'
Any suggestions would be most appreciated!
Must have upgraded Markdown inadvertently. I added the following to my requirements and it is working fine now:
Markdown<3.2

UnicodeDecodeError: invalid start byte in METADATA file at path:

I see that several Python-package related files have gibberish at their end.
Due to this, I am unable to do several pip operations (even basic ones like "pip list").
(Usually, I use conda by the way)
For example. When I pressed pip list. I get the following error.
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\shan_jaffry\Miniconda3\envs\SQL_version\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
status = self.run(options, args)
File "C:\Users\shan_jaffry\Miniconda3\envs\SQL_version\lib\site-packages\pip\_internal\commands\list.py", line 179, in run
self.output_package_listing(packages, options)
File "C:\Users\shan_jaffry\Miniconda3\envs\SQL_version\lib\site-packages\pip\_internal\commands\list.py", line 255, in output_package_listing
data, header = format_for_columns(packages, options)
File "C:\Users\shan_jaffry\Miniconda3\envs\SQL_version\lib\site-packages\pip\_internal\commands\list.py", line 307, in format_for_columns
row = [proj.raw_name, str(proj.version)]
File "C:\Users\shan_jaffry\Miniconda3\envs\SQL_version\lib\site-packages\pip\_internal\metadata\base.py", line 163, in raw_name
return self.metadata.get("Name", self.canonical_name)
File "C:\Users\shan_jaffry\Miniconda3\envs\SQL_version\lib\site-packages\pip\_internal\metadata\pkg_resources.py", line 96, in metadata
return get_metadata(self._dist)
File "C:\Users\shan_jaffry\Miniconda3\envs\SQL_version\lib\site-packages\pip\_internal\utils\packaging.py", line 48, in get_metadata
metadata = dist.get_metadata(metadata_name)
File "C:\Users\shan_jaffry\Miniconda3\envs\SQL_version\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1424, in get_metadata
return value.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfd in position 14097: invalid start byte in METADATA file at path: c:\users\shan_jaffry\miniconda3\envs\sql_version\lib\site-packages\hupper-1.10.2.dist-info\METADATA
I went into the file META and found the following gibberish at the end. This (I found) has been done in several other files i.e. end of files are appended with gibberish and the actual thin is removed. Any help?
> 0.1 (2016-10-21)
> ================
> -
> - Initial rele9ýl·øA
I found that the by manually going to the site-packages folder, and removing the two folders, :: hupper and hupper-1.10.2.dist-info and then installing hupper again using "pip install hupper", problem was solved.
The issue was that the hupper package (and hupper-1.10.2.dist-info) were corrupted. Hence uninstall and re-install helped.

Dataflow job fails with HttpError, NotImplementedError

I'm running a Dataflow job which I think should work, and is failing after 1.5 hrs with what looks like network errors. It works fine when run against a subset of the data.
The first trouble sign is a whole string of warnings like this:
Refusing to split <dataflow_worker.shuffle.GroupedShuffleRangeTracker object at 0x7f2bcb629950> at b'\xa4r\xa6\x85\x00\x01': proposed split position is out of range [b'\xa4^E\xd2\x00\x01', b'\xa4r\xa6\x85\x00\x01'). Position of last group processed was b'\xa4r\xa6\x84\x00\x01'.
Then there are four errors which seem to be about writing CSV files to GCS:
Error in _start_upload while inserting file gs://(redacted).csv: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/apache_beam/io/gcp/gcsio.py", line 565, in _start_upload self._client.objects.Insert(self._insert_request, upload=self._upload) File "/usr/local/lib/python3.7/site-packages/apache_beam/io/gcp/internal/clients/storage/storage_v1_client.py", line 1156, in Insert upload=upload, upload_config=upload_config) File "/usr/local/lib/python3.7/site-packages/apitools/base/py/base_api.py", line 731, in _RunMethod return self.ProcessHttpResponse(method_config, http_response, request) File "/usr/local/lib/python3.7/site-packages/apitools/base/py/base_api.py", line 737, in ProcessHttpResponse self.__ProcessHttpResponse(method_config, http_response, request)) File "/usr/local/lib/python3.7/site-packages/apitools/base/py/base_api.py", line 604, in __ProcessHttpResponse http_response, method_config=method_config, request=request) apitools.base.py.exceptions.HttpError: HttpError accessing <https://www.googleapis.com/resumable/upload/storage/v1/b/(redacted).csv&uploadType=resumable&upload_id=(redacted)>: response: <{'content-type': 'text/plain; charset=utf-8', 'x-guploader-uploadid': '(redacted)', 'content-length': '0', 'date': 'Wed, 08 Jul 2020 22:17:28 GMT', 'server': 'UploadServer', 'status': '503'}>, content <>
Error in _start_upload while inserting file gs://(redacted).csv: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/apache_beam/io/gcp/gcsio.py", line 565, in _start_upload self._client.objects.Insert(self._insert_request, upload=self._upload) File "/usr/local/lib/python3.7/site-packages/apache_beam/io/gcp/internal/clients/storage/storage_v1_client.py", line 1156, in Insert upload=upload, upload_config=upload_config) File "/usr/local/lib/python3.7/site-packages/apitools/base/py/base_api.py", line 715, in _RunMethod http_request, client=self.client) File "/usr/local/lib/python3.7/site-packages/apitools/base/py/transfer.py", line 908, in InitializeUpload return self.StreamInChunks() File "/usr/local/lib/python3.7/site-packages/apitools/base/py/transfer.py", line 1020, in StreamInChunks additional_headers=additional_headers) File "/usr/local/lib/python3.7/site-packages/apitools/base/py/transfer.py", line 971, in __StreamMedia self.RefreshResumableUploadState() File "/usr/local/lib/python3.7/site-packages/apitools/base/py/transfer.py", line 873, in RefreshResumableUploadState self.stream.seek(self.progress) File "/usr/local/lib/python3.7/site-packages/apache_beam/io/filesystemio.py", line 301, in seek offset, whence, self.position, self.last_block_position)) NotImplementedError: offset: 0, whence: 0, position: 411, last: 411
The Dataflow job ID is 2020-07-07_13_08_31-7649894576933400587 -- if anyone from Google Cloud Support is able to look at this I'd be very grateful. Thanks very much.
P.S I asked a similar question last year (Dataflow job fails at BigQuery write with backend errors), the resolution was to use --experiments=use_beam_bq_sink -- I am already doing this.
You can safely ignore "Refusing to split" errors. This just means that the split position Dataflow service provided probably was received by the worker after that position was already read by the worker. Hence the worker has to ignore the split request.
Error "Error in _start_upload while inserting" seems more problematic and seems to be similar to https://issues.apache.org/jira/browse/BEAM-7014. I suspect this to be a rare flake though so I'm not sure if this was the reason for your job failure (the job only fails of the same workitem failed four times).
Can you contact Google Cloud support so that they can look into your job ?
I will mention this in the JIRA.

stripe.error.APIConnectionError connected to openssl

I am dealing with the following error
Traceback (most recent call last):
File "once.py", line 1757, in <module>
once()
File "once.py", line 55, in once
stripe.Charge.all()
File "/Library/Python/2.7/site-packages/stripe/resource.py", line 438, in all
return cls.list(*args, **params)
File "/Library/Python/2.7/site-packages/stripe/resource.py", line 450, in list
response, api_key = requestor.request('get', url, params)
File "/Library/Python/2.7/site-packages/stripe/api_requestor.py", line 150, in request
method.lower(), url, params, headers)
File "/Library/Python/2.7/site-packages/stripe/api_requestor.py", line 281, in request_raw
method, abs_url, headers, post_data)
File "/Library/Python/2.7/site-packages/stripe/http_client.py", line 139, in request
self._handle_request_error(e)
File "/Library/Python/2.7/site-packages/stripe/http_client.py", line 159, in _handle_request_error
raise error.APIConnectionError(msg)
stripe.error.APIConnectionError: Unexpected error communicating with Stripe. If this problem persists,
let us know at support#stripe.com.
I get this error when running a simple test program which stripe suggested
import stripe
stripe.api_key = "blah bla"
stripe.api_base = "https://api-tls12.stripe.com"
print "stripe.VERSION = ", stripe.VERSION
if stripe.VERSION in ("1.13.0", "1.14.0", "1.14.1", "1.15.1", "1.16.0", "1.17.0", "1.18.0", "1.19.0"):
print "Bindings update required."
try:
stripe.Charge.all()
print "TLS 1.2 supported, no action required."
except stripe.error.APIConnectionError:
print "TLS 1.2 is not supported. You will need to upgrade your integration."
raise
I do not understand why I get this error, since my stripe version is high enough
stripe.VERSION = 1.55.2
and my openssl version does support TLS?
>>$ openssl version
OpenSSL 1.0.2k 26 Jan 2017
>>$ which openssl
/usr/bin/openssl
any ideas how to debug this further? I am lost...
ok I don't know what exactly caused the problem, but I got it working by changing the client
client = stripe.http_client.PycurlClient()
stripe.default_http_client = client
I think the requests package is the default. pycurl seems to work in my case...

Pinterest API search not working anymore

I was looking for pinterest API endpoints...
I've founded some URL..
https://api.pinterest.com/v3/domains/<domains>/search/pins/?query=<query>&access_token=<access_token>
I was able to generate the access_token..but every time I've tried a POST on that URL it gave me:
{
"status":"failure",
"code":12,
"host":"ngapi2-b2fc674c",
"generated_at":"Mon, 09 Feb 2015 17:45:29 +0000",
"message":"Something went wrong on our end. Sorry about that.",
"data":"path: /v3/domains/www.vtracker.com.br/search/pins/\nparams:
[('access_token', [u'blablahblahblah']), ('query',
[u'como'])]\nTraceback (most recent call last):\n File
\"/mnt/virtualenv/local/lib/python2.7/site-packages/flask/app.py\",
line 1504, in wsgi_app\n response =
self.full_dispatch_request()\n File
\"/mnt/virtualenv/local/lib/python2.7/site-packages/flask/app.py\",
line 1264, in full_dispatch_request\n rv =
self.handle_user_exception(e)\n File
\"/mnt/virtualenv/local/lib/python2.7/site-packages/flask/app.py\",
line 1262, in full_dispatch_request\n rv =
self.dispatch_request()\n File
\"/mnt/virtualenv/local/lib/python2.7/site-packages/flask/app.py\",
line 1248, in dispatch_request\n return
self.view_functions[rule.endpoint](**req.view_args)\n File
\"../api/pin_api.py\", line 715, in __call__\n
self._perform_auth()\n File \"../api/pin_api.py\", line 848, in
_perform_auth\n authorization.perform(dictified_values,
request.cookies, request.headers)\n File \"../api/pin_api.py\",
line 271, in perform\n params, cookies, headers)\n File
\"../api/pin_api.py\", line 121, in perform\n headers=headers)\n
File \"../api/decorators.py\", line 212, in
verify_user_authorization\n
core.Consumer.manager.get_scope_as_int(required_scope)):\n File
\"../core/managers/consumer_manager.py\", line 479, in
check_scope\n scope = migrate_legacy_scope(scope)\n File
\"../core/managers/consumer_manager.py\", line 475, in
migrate_legacy_scope\n if ~scope & old == 0:\nTypeError: bad
operand type for unary ~: 'NoneType'\n"
}
Is Pinterest API v3 closed or some other problem is going on?
Thks
You must first ensure that your app has been approved by Pinterest. You may need to reapply for approval (I had to reapply for my app). Once you are approved, you will see a link on your app page called "Visit API docs". This will link to the V3 documentation (https://developers.pinterest.com/docs/redoc/pinner_app). At least, this is the documentation I have been given access to. If you have a different type of app, maybe you will have access to other documentation.
After your app has been approved, the section of the documentation you will be interested in is "Search user pins" (https://developers.pinterest.com/docs/redoc/pinner_app/#tag/search).
The endpoint is: https://api.pinterest.com/v3/search/user_pins/{user}/
The documentation provides details about the query parameters that are allowed and the response data.

Resources