Skip to content

Commit 7de3403

Browse files
committed
Py3-compatible 0.7 release
1 parent 6f8b5f3 commit 7de3403

File tree

3 files changed

+30
-41
lines changed

3 files changed

+30
-41
lines changed

README.rst

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@ pyspotlight
44

55
is a thin python wrapper around `DBpedia Spotlight`_'s `REST Interface`_.
66

7-
The currently supported DBpedia Spotlight versions are 0.5 and 0.6.5.
8-
However, as long as there are no major API overhauls, this wrapper might also
9-
work with future versions. If you encounter a bug with a newer DBpedia version,
10-
feel free to create an issue here on github.
11-
12-
Note that I'm trying to track DBpedia Spotlight release version numbers, so you can
13-
easily see which pyspotlight version has been tested with which Spotlight
14-
release. Therefore all pyspotlight 0.5 releases are tested against
15-
Spotlight 0.5.
7+
This repository contains a fork of the original `pyspotlight` that aims at providing compatibility
8+
with newer releases of DBpedia Spotlight. The orignal seems unmaintained; pull requests are not being
9+
reviewed and merged.
1610

1711
.. _`DBpedia Spotlight`: https://github.com/dbpedia-spotlight/dbpedia-spotlight#dbpedia-spotlight
1812
.. _`REST Interface`: https://github.com/dbpedia-spotlight/dbpedia-spotlight/wiki/Web-service
@@ -29,7 +23,7 @@ Therefore installation is as easy as::
2923
Requirements for installation from source/github
3024
================================================
3125

32-
This module has been tested with Python 2.6 and Python 2.7.
26+
This module has been tested with Python 2.7 and Python 3.5.
3327

3428
As long as you use the ``setup.py`` for the installation
3529
(``python setup.py install``), you'll be fine because Python takes care of the

setup.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,32 @@
1414
"Development Status :: 5 - Production/Stable",
1515
]
1616

17-
requires = ["requests=>2.10.0", ]
17+
requires = ["requests", ]
1818

1919
# This might not be the best idea.
2020
try:
2121
import json
2222
except ImportError:
23-
requires.append('simplejson>=2.0')
23+
requires.append('simplejson')
2424

2525

2626
# Python 2.6 does not ship with an OrderedDict implementation.
2727
# God save the cheeseshop!
2828
try:
2929
from collections import OrderedDict
3030
except ImportError:
31-
requires.append('ordereddict>=1.1')
31+
requires.append('ordereddict')
3232

3333

3434
setup(name='pyspotlight',
35-
version='0.6.5.2',
35+
version='0.7.0',
3636
license='BSD',
37-
url='https://github.com/newsgrape/pyspotlight',
37+
url='https://github.com/aolieman/pyspotlight',
3838
packages=find_packages(),
3939
description='Python interface to the DBPedia Spotlight REST API',
4040
long_description=open('README.rst').read(),
4141
keywords="dbpedia spotlight semantic",
4242
classifiers=classifiers,
4343
install_requires=requires,
44+
test_suite='nose2.collector.collector',
4445
)

spotlight/__init__.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,9 @@
44
55
This is just a simple interface to a Spotlight API.
66
7-
Tested with DBPedia Spotlight 0.5 and 0.6.5.
8-
9-
Note that I'm trying to track Spotlight release version numbers, so you can
10-
easily see which pyspotlight version has been tested with which Spotlight
11-
release.
12-
13-
I hope the code and the small documentation speaks for itself :-)
14-
15-
If you should encounter any problems, feel free to contact me on github
16-
(originell). I'm happy to help out with anything related to my code.
7+
Tested with DBPedia Spotlight 0.7.
178
"""
18-
__version_info__ = (0, 6, 5)
9+
__version_info__ = (0, 7, 0)
1910
__version__ = '.'.join(map(str, __version_info__))
2011

2112

@@ -42,7 +33,7 @@ def _convert_number(value):
4233
# Workaround for footnotes being put into Resources.surfaceForm and then
4334
# having them parsed by the JSON parser into a list. (issue #4)
4435
if isinstance(value, list):
45-
value = unicode(value)
36+
value = str(value)
4637

4738
try:
4839
return int(value)
@@ -61,7 +52,7 @@ def _dict_cleanup(dic, dict_type=dict):
6152
That way we can avoid stack fails.
6253
"""
6354
clean = dict_type()
64-
for key, value in dic.iteritems():
55+
for key, value in dic.items():
6556
if value is None:
6657
continue
6758

@@ -70,7 +61,7 @@ def _dict_cleanup(dic, dict_type=dict):
7061
try:
7162
# If this is a string or bool,
7263
# go straight to type conversion.
73-
if (isinstance(value, basestring) or
64+
if (hasattr(value, 'strip') or
7465
isinstance(value, bool)):
7566
raise AttributeError
7667
# Test for an iterable (list, tuple, set)
@@ -86,12 +77,7 @@ def _dict_cleanup(dic, dict_type=dict):
8677

8778

8879
# Main functions.
89-
#
90-
# I was inspired to go back to a function based approach after seeing this
91-
# awesome talk by Jack Diederich: Stop Writing Classes
92-
# http://pyvideo.org/video/880/stop-writing-classes
93-
# Most of the class-based approach had the problems he described.
94-
# Embarrassing!
80+
9581
def annotate(address, text, confidence=0.0, support=0,
9682
spotter='Default', disambiguator='Default',
9783
filters=None, headers=None):
@@ -157,9 +143,13 @@ def annotate(address, text, confidence=0.0, support=0,
157143
158144
:rtype: list of resources
159145
"""
160-
payload = {'confidence': confidence, 'support': support,
161-
'spotter': spotter, 'disambiguator': disambiguator,
162-
'text': text}
146+
payload = {
147+
'confidence': confidence,
148+
'support': support,
149+
'text': text,
150+
'spotter': spotter,
151+
'disambiguator': disambiguator
152+
}
163153

164154
filter_kwargs = {'policy': 'whitelist'}
165155
filter_kwargs.update(filters or {})
@@ -204,9 +194,13 @@ def candidates(address, text, confidence=0.0, support=0,
204194
205195
:rtype: list of surface forms
206196
"""
207-
payload = {'confidence': confidence, 'support': support,
208-
'spotter': spotter, 'disambiguator': disambiguator,
209-
'text': text}
197+
payload = {
198+
'confidence': confidence,
199+
'support': support,
200+
'text': text,
201+
'spotter': spotter,
202+
'disambiguator': disambiguator
203+
}
210204

211205
filter_kwargs = {'policy': 'whitelist'}
212206
filter_kwargs.update(filters or {})

0 commit comments

Comments
 (0)