{ "info": { "author": "Alex Olieman", "author_email": "alex@olieman.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries" ], "description": "===========\npyspotlight\n===========\n\nis a thin python wrapper around `DBpedia Spotlight`_'s `REST Interface`_.\n\nThis package is tested against DBpedia Spotlight version 0.7.\nAs long as there are no major API overhauls, this wrapper might also\nwork with future versions. If you encounter a bug with a newer DBpedia Spotlight version,\nfeel free to create an issue here on github.\n\nNote that we're trying to track DBpedia Spotlight release version numbers, so you can\neasily see which pyspotlight version has been tested with which Spotlight\nrelease. For example, all pyspotlight 0.6.x releases are compatible with\nSpotlight 0.6.x, etc. While we aim for backwards-compatibility with older\nSpotlight releases, it is not guaranteed. If you're using an older Spotlight\nversion, you may need to use an older pyspotlight version as well.\n\n.. _`DBpedia Spotlight`: http://www.dbpedia-spotlight.org/faq\n.. _`REST Interface`: http://www.dbpedia-spotlight.org/api\n\nInstallation\n============\n\nThe newest stable release can be found on the `Python Package Index (PyPI) `__.\n\nTherefore installation is as easy as::\n\n pip install pyspotlight\n\nOlder releases can be installed by specifying a version::\n\n pip install pyspotlight~=0.6.1\n\nRequirements for installation from source/github\n================================================\n\nThis module has been tested with Python 2.7 and Python 3.5.\n\nAs long as you use the ``setup.py`` for the installation\n(``python setup.py install``), you'll be fine because Python takes care of the\ndependencies for you.\n\nIf you decide not to use the ``setup.py`` you will need the ``requests``\nlibrary.\n\nAll of these packages can be found on the `Python PackageIndex`_ and easily\ninstalled via either ``easy_install`` or, `the recommended`_, ``pip``.\n\nUsing ``pip`` it is especially easy because you can just do this::\n\n pip install -r requirements.txt\n\nand it will install all package dependencies listed in that file.\n\n.. _`Python PackageIndex`: http://pypi.python.org/\n.. _`the recommended`: http://stackoverflow.com/questions/3220404/why-use-pip-over-easy-install\n\nUsage\n=====\n\nUsage is simple and easy, just as the API is::\n\n >>> import spotlight\n >>> annotations = spotlight.annotate('http://localhost/rest/annotate',\n ... 'Your test text',\n ... confidence=0.4, support=20)\n\nThis should return a list of all resources found within the given text.\nAssuming we did this for the following text::\n\n President Obama on Monday will call for a new minimum tax rate for individuals making more than $1 million a year to ensure that they pay at least the same percentage of their earnings as other taxpayers, according to administration officials.\n\nWe might get this back::\n\n >>> spotlight.annotate('http://localhost/rest/annotate', sample_txt)\n [\n {\n 'URI': 'http://dbpedia.org/resource/Presidency_of_Barack_Obama',\n 'offset': 0,\n 'percentageOfSecondRank': -1.0,\n 'similarityScore': 0.10031112283468246,\n 'support': 134,\n 'surfaceForm': 'President Obama',\n 'types': 'DBpedia:OfficeHolder,DBpedia:Person,Schema:Person,Freebase:/book/book_subject,Freebase:/book,Freebase:/book/periodical_subject,Freebase:/media_common/quotation_subject,Freebase:/media_common'\n },\n \u2026(truncated remaining elements)\u2026\n ]\n\nAny additional filter parameters that are supported by the Spotlight API\ncan be passed to the ``filters`` argument in a dictionary.\n\nFor example::\n\n >>> only_person_filter = {\n ... 'policy': \"whitelist\",\n ... 'types': \"DBpedia:Person\",\n ... 'coreferenceResolution': False\n ... }\n\n >>> spotlight.annotate(\n ... \"http://localhost/rest/annotate\",\n ... \"Any collaboration between Shakira and Metallica seems highly unlikely.\",\n ... filters=only_person_filter\n ... )\n\n [{\n 'URI': 'http://dbpedia.org/resource/Shakira',\n 'offset': 26,\n 'percentageOfSecondRank': 1.511934771738109e-09,\n 'similarityScore': 0.9999999984880361,\n 'support': 2587,\n 'surfaceForm': 'Shakira',\n 'types': 'Schema:MusicGroup,DBpedia:Agent,Schema:Person,DBpedia:Person,DBpedia:Artist,DBpedia:MusicalArtist'\n }]\n\nThe same parameters apply to the ``spotlight.candidates`` function,\nwhich returns a list of all matching candidate entities rather than\nonly the top candidate.\n\nNote that the Spotlight API may support other interfaces that have not been\nimplemented in pyspotlight. Feel free to contribute :-)!\n\nRunning DBpedia Spotlight\n-----------------------------\nIf you just want to play around with Spotlight, there is an interactive demo\navailable at `demo.dbpedia-spotlight.org`_. To submit pyspotlight\nrequests to the demo servers, you may use the endpoints found in `sites.xml`_.\n\n.. _demo.dbpedia-spotlight.org : http://demo.dbpedia-spotlight.org/\n.. _sites.xml: http://demo.dbpedia-spotlight.org/config/sites.xml\n\nFor any significant Spotlight usage, it is strongly recommended to run\nyour own server. Please follow the `installation instructions`_.\n\n.. _installation instructions: http://www.dbpedia-spotlight.org/faq#i-want-to-install-the-tool-how-do-i-do\n\nExceptions\n----------\nThe following exceptions can occur:\n\n* ``ValueError`` when:\n\n - the JSON response could not be decoded.\n\n* ``SpotlightException`` when:\n\n - the JSON response did not contain any needed fields or was not formed as\n excepted.\n - You forgot to explicitly specify a protocol (http/https) in the API URL.\n\n Usually the exception's message tells you *exactly* what is wrong. If\n not, we might have forgotten some error handling. So just open up an issue on\n github if you encounter unexpected exceptions.\n\n* ``requests.exceptions.HTTPError``\n\n Is thrown when the response http status code was *not* ``200``. This could happen\n if you have a load balancer like nginx in front of your spotlight cluster and\n there is not a single server available, so nginx throws a ``502 Bad Gateway``.\n\nTips\n====\n\nWe highly recommend playing around with the *confidence* and *support* values.\nFurthermore it might be preferable to filter out more annotations by looking\nat their *similiarityScore* (read: contextual score).\n\nIf you want to change the default values, feel free to use ``itertools.partial``\nto create a little wrapper with simplified signature::\n\n >>> from spotlight import annotate\n >>> from functools import partial\n >>> api = partial(annotate, 'http://localhost/rest/annotate',\n ... confidence=0.4, support=20,\n ... spotter='SpotXmlParser')\n >>> api('This is your test text. This function uses a non-default\n ... confidence, support, and spotter. Furthermore all calls go\n ... directly to localhost/rest/annotate.')\n\nAs you can see this reduces the function's complexity greatly.\nPyspotlight provides an interface based on functions rather than classes,\nto avoid an unnecessary layer of indirection.\n\nTests\n=====\n\nIf you want to run the tests, you will have to install ``nose2`` (~0.6) from PyPI.\nThen you can simply run ``nose2`` from the command line in\nthis or the ``spotlight/`` directory.\n\nAll development and regular dependencies can be installed with a single command::\n\n pip install -r requirements-dev.txt\n\n\nBugs\n====\n\nIn case you spot a bug, please open an issue and attach the raw response you\nsent. Have a look at `ubergrape/pyspotlight#3`_ for an example on how to file a good bug report.\n\n.. _`ubergrape/pyspotlight#3`: https://github.com/ubergrape/pyspotlight/issues/3\n\n\nChangelog\n=========\n\nv0.7.2 (2017-12-02)\n-------------------\n\n- Updated README instructions and links. [Alex Olieman]\n\n- Ensure that ``candidates`` returns surface forms as strings. [Alex Olieman]\n\n- Ensure that surface forms are always strings (merge `PR #1`_). [ShomyLiu & Alex Olieman]\n\n.. _PR #1: https://github.com/aolieman/pyspotlight/pull/1\n\nv0.7.1 (2016-07-25)\n-------------------\n\n- Moved the shared request logic in ``annotate`` and ``candidates`` to a\n helper function. [Alex Olieman]\n\n- Updated setup/package files [Alex Olieman]\n\n- Updated README. [Luis Nell & Alex Olieman]\n\nv0.7.0 (2016-07-18)\n-------------------\n\nAPI Changes\n~~~~~~~~~~~\n\n- Changed default spotter to ``'Default'`` for 0.7 compatibility. [Alex\n Olieman]\n\n- Moved filter parameters into a ``filters`` argument. [Alex Olieman]\n\n * **Removed** the ``policy`` argument from ``annotate`` and ``candidates``.\n * Added a types parameter, which enables server-side filtering of resources.\n It also makes for a nice addition to the policy parameter.\n\nAdditions\n~~~~~~~~~\n\n- Python 3 compatibility. [Alex Olieman]\n\n- Moved to nose2 for tests. [Alex Olieman]\n\nFixes\n~~~~~\n\n- Updated required version of the requests package. [Alex Olieman]\n\n- Remove mutable default arguments. [Luis Nell]\n\nv0.6.5.2 (2013-08-27)\n---------------------\n\n- Add manifest so README is included on PyPI. [Luis Nell]\n\nv0.6.5.1 (2013-08-12)\n---------------------\n\n- Update README for PyPI release. [Luis Nell]\n\n- Upgrade to requests 1.2.3. [Luis Nell]\n\n- BSD License. [Luis Nell]\n\n- Workaround for footnotes in ``surfaceForm`` that get parsed as a list.\n [Luis Nell]\n\n- Do not assume in ``candidates`` that ``surfaceForm`` is always a list.\n [Luis Nell]\n\nv0.6.5 (2012-10-07)\n-------------------\n\nAPI Changes\n~~~~~~~~~~~\n\n- Have to explicitly provide a protocol in the URL. [Luis Nell]\n\nAdditions\n~~~~~~~~~\n\n- Added stuff for testing. [Luis Nell]\n\n- Add requirements.txt for pip. [Luis Nell]\n\n- Make use of requests builtin json decoding. [Luis Nell]\n\nFixes\n~~~~~\n\n- Some README updates. [Luis Nell]\n\n- Add ordereddict requirement for py2.6. [Luis Nell]\n\n- Tests: adapt to the requests raw handling. [Luis Nell]\n\n- Use requests 0.14.1 from now on. [Luis Nell]\n\n- Fixed typos, wrong link. [Pablo Mendes]\n\n * Minor: We spell it DBpedia, not DBPedia :)\n * Fix: Link pointed to OpenCalais, a commercial closed-source\n alternative to DBpedia Spotlight\n\nv0.5.3 (2012-08-01)\n-------------------\n\n- Update README to reflect the exception changes. [Luis Nell]\n\n- Raise requests.exceptions.HTTPError on response.status_code != 200.\n [Luis Nell]\n\n- Prefer simplejson to json. [Luis Nell]\n\n- Add tests for new exception handling. [Luis Nell]\n\n- Add Exception Handling. [Luis Nell]\n\nv0.5.2 (2012-04-06)\n-------------------\n\n- Fixes setup.py issues. v0.5.2. [Luis Nell]\n\nv0.5.1 (2012-03-21)\n-------------------\n\n- Fix setup.py - push 0.5.1. [Luis Nell]\n\nv0.5.0 (2012-03-20)\n-------------------\n\n- Init. [Luis Nell]\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/aolieman/pyspotlight", "keywords": "dbpedia spotlight,semantic annotation,entity linking", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "pyspotlight", "package_url": "https://pypi.org/project/pyspotlight/", "platform": "", "project_url": "https://pypi.org/project/pyspotlight/", "project_urls": { "Homepage": "https://github.com/aolieman/pyspotlight" }, "release_url": "https://pypi.org/project/pyspotlight/0.7.2/", "requires_dist": [ "requests (~=2.10)" ], "requires_python": "", "summary": "Python interface to the DBpedia Spotlight REST API", "version": "0.7.2" }, "last_serial": 3383166, "releases": { "0.6.5.1": [ { "comment_text": "", "digests": { "md5": "c39b1d38f5534ef9a327b1435b3d9db9", "sha256": "75bf4c401f8b7f42c2f3a009b414773572c19c22d7ae1dd3098d87b49c3b2a76" }, "downloads": -1, "filename": "pyspotlight-0.6.5.1.tar.gz", "has_sig": false, "md5_digest": "c39b1d38f5534ef9a327b1435b3d9db9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7676, "upload_time": "2013-08-12T18:26:13", "url": "https://files.pythonhosted.org/packages/7d/4c/f5c413d32e02cde7bd1275f7c66a40cb5876e38900bfcaf315a838210186/pyspotlight-0.6.5.1.tar.gz" } ], "0.6.5.2": [ { "comment_text": "", "digests": { "md5": "0106e0bf22591b64e61ee6de7d71f20d", "sha256": "7036ed2b6fd77562af0af0c6eee3ca57ea00e6662acc86378deeb465b19dd449" }, "downloads": -1, "filename": "pyspotlight-0.6.5.2.tar.gz", "has_sig": false, "md5_digest": "0106e0bf22591b64e61ee6de7d71f20d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8856, "upload_time": "2013-08-27T16:00:20", "url": "https://files.pythonhosted.org/packages/ae/fc/cd59914b5125ca7dad76ea76e58907ed1c38f81133b1bac486a8b3839ba6/pyspotlight-0.6.5.2.tar.gz" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "e995c11c6e86180caf202a19e16ce500", "sha256": "215a4f7e1698714784e900bf04b563589ba107c7eb88145aa532429abdfbc960" }, "downloads": -1, "filename": "pyspotlight-0.7.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "e995c11c6e86180caf202a19e16ce500", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14917, "upload_time": "2016-08-29T11:34:02", "url": "https://files.pythonhosted.org/packages/76/f4/0d24277b697c277d8877e0698591029d2fadd411c3771b25584797f807b6/pyspotlight-0.7.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1f836a2aca4a97f354514b99165f2f8f", "sha256": "accd71462597bfda72a39515fff280c9ca3a9945dad14b5b755b15eebeea4fbb" }, "downloads": -1, "filename": "pyspotlight-0.7.1.tar.gz", "has_sig": true, "md5_digest": "1f836a2aca4a97f354514b99165f2f8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14991, "upload_time": "2016-08-29T11:34:06", "url": "https://files.pythonhosted.org/packages/bc/89/291e388f6350bde808ae496bb1ec94ac7ecfbb666497b275f43b9037556d/pyspotlight-0.7.1.tar.gz" } ], "0.7.2": [ { "comment_text": "", "digests": { "md5": "1951649831067a3b3a6a29785f672bbe", "sha256": "4783ba08aad8eddbc9f2767b05dfc790bc2f888b4d552bb380c2eb0e3afe3dc0" }, "downloads": -1, "filename": "pyspotlight-0.7.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1951649831067a3b3a6a29785f672bbe", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15062, "upload_time": "2017-12-02T21:11:59", "url": "https://files.pythonhosted.org/packages/c5/4b/8d892815fb3b1dbc27531d4e9d5e98603acdbb4affa72ed933516d78cebe/pyspotlight-0.7.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "68080c975bcff7aa777702aad0adb438", "sha256": "9329f5ae8342dbda34dab7910a1c1ee82d409d34eabbfe307caa84b4ebe54ba7" }, "downloads": -1, "filename": "pyspotlight-0.7.2.tar.gz", "has_sig": false, "md5_digest": "68080c975bcff7aa777702aad0adb438", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11973, "upload_time": "2017-12-02T21:12:00", "url": "https://files.pythonhosted.org/packages/c8/22/0e42434445784fe951b2199354625dff4cf481cf87667ad18ac54200d224/pyspotlight-0.7.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1951649831067a3b3a6a29785f672bbe", "sha256": "4783ba08aad8eddbc9f2767b05dfc790bc2f888b4d552bb380c2eb0e3afe3dc0" }, "downloads": -1, "filename": "pyspotlight-0.7.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1951649831067a3b3a6a29785f672bbe", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15062, "upload_time": "2017-12-02T21:11:59", "url": "https://files.pythonhosted.org/packages/c5/4b/8d892815fb3b1dbc27531d4e9d5e98603acdbb4affa72ed933516d78cebe/pyspotlight-0.7.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "68080c975bcff7aa777702aad0adb438", "sha256": "9329f5ae8342dbda34dab7910a1c1ee82d409d34eabbfe307caa84b4ebe54ba7" }, "downloads": -1, "filename": "pyspotlight-0.7.2.tar.gz", "has_sig": false, "md5_digest": "68080c975bcff7aa777702aad0adb438", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11973, "upload_time": "2017-12-02T21:12:00", "url": "https://files.pythonhosted.org/packages/c8/22/0e42434445784fe951b2199354625dff4cf481cf87667ad18ac54200d224/pyspotlight-0.7.2.tar.gz" } ] }