Skip to content

Commit 7a3f8b5

Browse files
committed
Merge branch 'develop'
2 parents a456580 + 37c21ef commit 7a3f8b5

16 files changed

+191
-63
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
ehthumbs.db
88
Thumbs.db
99

10+
# VS Code
11+
.vscode
12+
1013
# Jetbrains
1114
**/.idea/*
1215
!**/.idea/runConfigurations/

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

CI.Jenkinsfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
3+
def versions = [3.7, 3.8, 3.9, 3.10, 3.11]
4+
5+
def runSonnarForPythonVersion(sourceDir, ver){
6+
mySonarOpts="-Dsonar.sources=/source -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}"
7+
if("${env.CHANGE_ID}" != "null"){
8+
mySonarOpts = "$mySonarOpts -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.BRANCH_NAME}"
9+
} else {
10+
mySonarOpts = "$mySonarOpts -Dsonar.branch.name=${env.BRANCH_NAME}"
11+
}
12+
if ("${env.CHANGE_BRANCH}" != "null") {
13+
mySonarOpts="$mySonarOpts -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}"
14+
}
15+
16+
// Only run Sonar once.
17+
if(ver == 3.11) {
18+
sonarExec="cd /root/ && \
19+
wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \
20+
unzip -q sonar-scanner-cli-4.8.0.2856-linux.zip && \
21+
cd /source && \
22+
/root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner ${mySonarOpts}"
23+
} else {
24+
sonarExec="echo Skipping Sonar for this version."
25+
}
26+
27+
sh "docker run \
28+
--pull always \
29+
--rm --volume ${sourceDir}:/source \
30+
python:${ver}-slim \
31+
bash -c \"apt-get update && \
32+
apt-get install -y wget unzip && \
33+
pip3 install tox && \
34+
cd /source && \
35+
tox && \
36+
${sonarExec}\""
37+
}
38+
39+
node ("docker-light") {
40+
def sourceDir = pwd()
41+
try {
42+
stage("Clean up") {
43+
step([$class: 'WsCleanup'])
44+
}
45+
stage("Checkout Code") {
46+
checkout scm
47+
}
48+
stage("Build & Test") {
49+
withSonarQubeEnv {
50+
51+
versions.each { ver ->
52+
runSonnarForPythonVersion(sourceDir, ver)
53+
}
54+
}
55+
}
56+
} catch (e) {
57+
currentBuild.result = "FAILED"
58+
throw e
59+
}
60+
}

DEVELOPER.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ To test changes you have made to the binding, you can use a pre-configured Docke
4747
git clone git@github.com:rosette-api/python.git
4848
cd python
4949
# Modify the binding...
50-
docker run -e API_KEY=$API_KEY -v $(pwd):/source rosetteapi/docker-python
50+
docker run -e API_KEY=$API_KEY -v $(pwd):/source rosette/docker-python
5151
```
5252

5353
Optional parameters for the `docker run` execution are:

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ node ("docker-light") {
1515
echo "${env.ALT_URL}"
1616
def useUrl = ("${env.ALT_URL}" == "null") ? "${env.BINDING_TEST_URL}" : "${env.ALT_URL}"
1717
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${useUrl}"]) {
18-
sh "docker pull rosetteapi/docker-python"
19-
sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source rosetteapi/docker-python"
18+
sh "docker pull rosette/docker-python"
19+
sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source rosette/docker-python"
2020
}
2121
}
2222
slack(true)

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
---
44

5-
[![Build Status](https://travis-ci.org/rosette-api/python.svg?branch=develop)](https://travis-ci.org/rosette-api/python)
65
[![PyPI version](https://badge.fury.io/py/rosette-api.svg)](https://badge.fury.io/py/rosette-api)
76
[![Python Versions](https://img.shields.io/pypi/pyversions/rosette-api.svg?color=dark%20green&label=Python%20Versions)](https://img.shields.io/pypi/pyversions/rosette-api.svg?color=dark%20green&label=Python%20Versions)
87

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
application:
2-
image: rosetteapi/docker-python
2+
image: rosette/docker-python
33
environment:
44
- API_KEY=$API_KEY
55
- HTTP_PROXY=http://squid:3128

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
# built documents.
5656
#
5757
# The short X.Y version.
58-
version = '1.24.0'
58+
version = '1.25.1'
5959
# The full version, including alpha/beta/rc tags.
60-
release = '1.24.0'
60+
release = '1.25.1'
6161

6262
# The language for content autogenerated by Sphinx. Refer to documentation
6363
# for a list of supported languages.

examples/address_similarity.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
1818
params = AddressSimilarityParameters()
1919
params["address1"] = {"houseNumber": "1600", "road": "Pennsylvania Ave NW", "city": "Washington", "state": "DC", "postCode": "20500"}
2020
params["address2"] = "160 Pennsilvana Avenue, Washington, D.C., 20500"
21+
#params["parameters"] = {"houseNumberAddressFieldWeight": "0.9"}
2122

2223
try:
2324
return api.address_similarity(params)

examples/name_similarity.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
2020
params = NameSimilarityParameters()
2121
params["name1"] = {"text": matched_name_data1, "language": "eng", "entityType": "PERSON"}
2222
params["name2"] = {"text": matched_name_data2, "entityType": "PERSON"}
23+
#params["parameters"] = {"conflictScore": "0.9", "deletionScore": "0.2"}
24+
2325
try:
2426
return api.name_similarity(params)
2527
except RosetteException as exception:

rosette/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
limitations under the License.
1313
"""
1414

15-
__version__ = '1.24.0'
15+
__version__ = '1.25.1'

rosette/api.py

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
_APPLICATION_JSON = 'application/json'
3232
_BINDING_LANGUAGE = 'python'
33-
_BINDING_VERSION = '1.24.0'
33+
_BINDING_VERSION = '1.25.1'
3434
_CONCURRENCY_HEADER = 'x-rosetteapi-concurrency'
3535
_CUSTOM_HEADER_PREFIX = 'X-RosetteAPI-'
3636
_CUSTOM_HEADER_PATTERN = re.compile('^' + _CUSTOM_HEADER_PREFIX)
@@ -113,7 +113,7 @@ def serialize(self, options):
113113
"""serialize keys with values"""
114114
self.validate()
115115
values = {}
116-
for (key, val) in self.__params.items():
116+
for key, val in self.__params.items():
117117
if val is None:
118118
continue
119119
else:
@@ -153,14 +153,12 @@ class DocumentParameters(_DocumentParamSetBase):
153153
def __init__(self):
154154
"""Create a L{DocumentParameters} object."""
155155
_DocumentParamSetBase.__init__(
156-
self, ("content", "contentUri", "genre", "language", "profileId"))
156+
self, ("content", "contentUri", "language", "profileId"))
157157
self.file_name = ""
158158
self.use_multipart = False
159159

160160
def validate(self):
161161
"""Internal. Do not use."""
162-
if self["genre"] is not None:
163-
warnings.warn("genre is deprecated and will be removed in the next release.")
164162
if self["content"] is None:
165163
if self["contentUri"] is None:
166164
raise RosetteException(
@@ -214,7 +212,7 @@ class NameTranslationParameters(_DocumentParamSetBase):
214212
215213
C{targetLangauge} The language into which the name is to be translated.
216214
217-
C{entityType} The entity type (TBD) of the name.
215+
C{entityType} The entity type of the name. PERSON (default), LOCATION, or ORGANIZATION
218216
219217
C{sourceLanguageOfOrigin} The language of origin of the name.
220218
@@ -242,7 +240,7 @@ def __init__(self):
242240

243241
def validate(self):
244242
"""Internal. Do not use."""
245-
for option in ("name", "targetLanguage"): # required
243+
for option in "name", "targetLanguage": # required
246244
if self[option] is None:
247245
raise RosetteException(
248246
"missingParameter",
@@ -252,23 +250,32 @@ def validate(self):
252250

253251
class AddressSimilarityParameters(_DocumentParamSetBase):
254252
"""Parameter object for C{address-similarity} endpoint.
255-
All are required.
253+
254+
C{address1} and C{address2} are required.
255+
256+
`parameters` is optional.
256257
257258
C{address1} The address to be matched, a C{address} object or address string.
258259
259260
C{address2} The address to be matched, a C{address} object or address string.
260261
261262
The C{address} object contains these optional fields:
262263
city, island, district, stateDistrict, state, countryRegion, country, worldRegion, postCode, poBox
264+
265+
`parameters` is a dictionary listing any parameter overrides to include. For example, `postCodeAddressFieldWeight`.
266+
Setting `parameters` is not cumulative. Define all overrides at once. If defined multiple times, only the
267+
final declaration is used.
268+
269+
See `examples/address_similarity.py`
263270
"""
264271

265272
def __init__(self):
266273
self.use_multipart = False
267-
_DocumentParamSetBase.__init__(self, ("address1", "address2"))
274+
_DocumentParamSetBase.__init__(self, ("address1", "address2", "parameters"))
268275

269276
def validate(self):
270277
"""Internal. Do not use."""
271-
for option in ("address1", "address2"): # required
278+
for option in "address1", "address2": # required
272279
if self[option] is None:
273280
raise RosetteException(
274281
"missingParameter",
@@ -278,30 +285,39 @@ def validate(self):
278285

279286
class NameSimilarityParameters(_DocumentParamSetBase):
280287
"""Parameter object for C{name-similarity} endpoint.
281-
All are required.
288+
289+
C{name1} and C{name2} are required.
290+
291+
`parameters` is optional.
282292
283293
C{name1} The name to be matched, a C{name} object.
284294
285295
C{name2} The name to be matched, a C{name} object.
286296
287297
The C{name} object contains these fields:
288298
289-
C{text} Text of the name, required.
299+
C{text} Text of the name, required.
300+
301+
C{language} Language of the name in ISO639 three-letter code, optional.
302+
303+
C{script} The ISO15924 code of the name, optional.
290304
291-
C{language} Language of the name in ISO639 three-letter code, optional.
305+
C{entityType} The entity type, can be "PERSON", "LOCATION" or "ORGANIZATION", optional.
292306
293-
C{script} The ISO15924 code of the name, optional.
307+
`parameters` is a dictionary listing any parameter overrides to include. For example, `deletionScore`.
308+
Setting `parameters` is not cumulative. Define all overrides at once. If defined multiple times, only the
309+
final declaration is used.
294310
295-
C{entityType} The entity type, can be "PERSON", "LOCATION" or "ORGANIZATION", optional.
311+
See `examples/name_similarity.py`
296312
"""
297313

298314
def __init__(self):
299315
self.use_multipart = False
300-
_DocumentParamSetBase.__init__(self, ("name1", "name2"))
316+
_DocumentParamSetBase.__init__(self, ("name1", "name2", "parameters"))
301317

302318
def validate(self):
303319
"""Internal. Do not use."""
304-
for option in ("name1", "name2"): # required
320+
for option in "name1", "name2": # required
305321
if self[option] is None:
306322
raise RosetteException(
307323
"missingParameter",
@@ -496,7 +512,7 @@ def call(self, parameters):
496512
_my_loads(rdata, response_headers), status)
497513
else:
498514
if self.debug:
499-
headers[_CUSTOM_HEADER_PREFIX + 'Devel'] = True
515+
headers[_CUSTOM_HEADER_PREFIX + 'Devel'] = 'true'
500516
self.logger.info('operate: ' + url)
501517
headers['Accept'] = _APPLICATION_JSON
502518
headers['Accept-Encoding'] = "gzip"

setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ def read(*filenames, **kwargs):
4949
'Natural Language :: English',
5050
'Operating System :: OS Independent',
5151
'Programming Language :: Python',
52-
'Programming Language :: Python :: 2.7',
53-
'Programming Language :: Python :: 3.5',
54-
'Programming Language :: Python :: 3.6',
5552
'Programming Language :: Python :: 3.7',
5653
'Programming Language :: Python :: 3.8',
5754
'Programming Language :: Python :: 3.9',
5855
'Programming Language :: Python :: 3.10',
56+
'Programming Language :: Python :: 3.11',
5957
'Topic :: Software Development :: Libraries :: Python Modules'
6058
]
6159
)

sonar-project.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
sonar.projectKey=rosette-api-python-binding
22
sonar.sources=rosette
3+
sonar.exclusions=**/tests/**,**/docs/**,**/examples/**
34
sonar.python.coverage.reportPaths=coverage.xml
45
#sonar.branch.name=RCB-596-pool-size

0 commit comments

Comments
 (0)