Skip to content

Commit 0ab6df0

Browse files
authored
Merge pull request #97 from rosette-api/WS-2589-remove-genre-from-entities-example
WS-2589: removing genre from doc & future print_function
2 parents f8d2f7a + 91b2e2b commit 0ab6df0

25 files changed

+29
-57
lines changed

examples/address_similarity.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get match score (similarity) of two addresses.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -36,4 +35,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
3635
if __name__ == '__main__':
3736
ARGS = PARSER.parse_args()
3837
RESULT = run(ARGS.key, ARGS.url)
39-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
38+
print(RESULT)

examples/categories.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
Example code to call Rosette API to get the category of a document (at a given URL).
55
"""
6-
from __future__ import print_function
76

87
import argparse
98
import json
@@ -48,4 +47,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4847
if __name__ == '__main__':
4948
ARGS = PARSER.parse_args()
5049
RESULT = run(ARGS.key, ARGS.url)
51-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
50+
print(RESULT)

examples/entities.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get entities from a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -27,7 +26,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
2726
entities_text_data = "The Securities and Exchange Commission today announced the leadership of the agency’s trial unit. Bridget Fitzpatrick has been named Chief Litigation Counsel of the SEC and David Gottesman will continue to serve as the agency’s Deputy Chief Litigation Counsel. Since December 2016, Ms. Fitzpatrick and Mr. Gottesman have served as Co-Acting Chief Litigation Counsel. In that role, they were jointly responsible for supervising the trial unit at the agency’s Washington D.C. headquarters as well as coordinating with litigators in the SEC’s 11 regional offices around the country."
2827
params = DocumentParameters()
2928
params["content"] = entities_text_data
30-
params["genre"] = "social-media"
29+
3130
try:
3231
return api.entities(params)
3332
except RosetteException as exception:
@@ -43,4 +42,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4342
if __name__ == '__main__':
4443
ARGS = PARSER.parse_args()
4544
RESULT = run(ARGS.key, ARGS.url)
46-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
45+
print(RESULT)

examples/info.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get information such as version and build
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -32,4 +31,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
3231
if __name__ == '__main__':
3332
ARGS = PARSER.parse_args()
3433
RESULT = run(ARGS.key, ARGS.url)
35-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
34+
print(RESULT)

examples/language.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to determine the language of a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -36,4 +35,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
3635
if __name__ == '__main__':
3736
ARGS = PARSER.parse_args()
3837
RESULT = run(ARGS.key, ARGS.url)
39-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
38+
print(RESULT)

examples/language_multilingual.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to determine the language of a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -38,4 +37,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
3837
if __name__ == '__main__':
3938
ARGS = PARSER.parse_args()
4039
RESULT = run(ARGS.key, ARGS.url)
41-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
40+
print(RESULT)

examples/morphology_complete.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get the complete morphological analysis of a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4241
if __name__ == '__main__':
4342
ARGS = PARSER.parse_args()
4443
RESULT = run(ARGS.key, ARGS.url)
45-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
44+
print(RESULT)

examples/morphology_compound-components.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get de-compounded words from a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4241
if __name__ == '__main__':
4342
ARGS = PARSER.parse_args()
4443
RESULT = run(ARGS.key, ARGS.url)
45-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
44+
print(RESULT)

examples/morphology_han-readings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get Chinese readings of words in a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -41,4 +40,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4140
if __name__ == '__main__':
4241
ARGS = PARSER.parse_args()
4342
RESULT = run(ARGS.key, ARGS.url)
44-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
43+
print(RESULT)

examples/morphology_lemmas.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get lemmas for words in a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4241
if __name__ == '__main__':
4342
ARGS = PARSER.parse_args()
4443
RESULT = run(ARGS.key, ARGS.url)
45-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
44+
print(RESULT)

examples/morphology_parts-of-speech.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get part-of-speech tags for words in a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4241
if __name__ == '__main__':
4342
ARGS = PARSER.parse_args()
4443
RESULT = run(ARGS.key, ARGS.url)
45-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
44+
print(RESULT)

examples/name_deduplication.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to deduplicate a list of names.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -37,4 +36,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
3736
if __name__ == '__main__':
3837
ARGS = PARSER.parse_args()
3938
RESULT = run(ARGS.key, ARGS.url)
40-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
39+
print(RESULT)

examples/name_similarity.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get match score (similarity) of two names.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -37,4 +36,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
3736
if __name__ == '__main__':
3837
ARGS = PARSER.parse_args()
3938
RESULT = run(ARGS.key, ARGS.url)
40-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
39+
print(RESULT)

examples/name_translation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to translate a name from one language to another.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -38,4 +37,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
3837
if __name__ == '__main__':
3938
ARGS = PARSER.parse_args()
4039
RESULT = run(ARGS.key, ARGS.url)
41-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
40+
print(RESULT)

examples/ping.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to send Rosette API a ping to check its reachability.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -32,4 +31,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
3231
if __name__ == '__main__':
3332
ARGS = PARSER.parse_args()
3433
RESULT = run(ARGS.key, ARGS.url)
35-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
34+
print(RESULT)

examples/relationships.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get entities's relationships from a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -34,4 +33,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
3433
if __name__ == '__main__':
3534
ARGS = PARSER.parse_args()
3635
RESULT = run(ARGS.key, ARGS.url)
37-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
36+
print(RESULT)

examples/semantic_vectors.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get text vectors from a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -42,5 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4241
if __name__ == '__main__':
4342
ARGS = PARSER.parse_args()
4443
RESULT = run(ARGS.key, ARGS.url)
45-
print(json.dumps(RESULT, indent=2, ensure_ascii=False,
46-
sort_keys=True).encode("utf8"))
44+
print(RESULT)

examples/sentences.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get sentences in a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -36,4 +35,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
3635
if __name__ == '__main__':
3736
ARGS = PARSER.parse_args()
3837
RESULT = run(ARGS.key, ARGS.url)
39-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
38+
print(RESULT)

examples/sentiment.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
Example code to call Rosette API to get the sentiment of a local file.
55
"""
6-
from __future__ import print_function
76

87
import argparse
98
import json
@@ -57,5 +56,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
5756
if __name__ == '__main__':
5857
ARGS = PARSER.parse_args()
5958
RESULT = run(ARGS.key, ARGS.url)
60-
print(json.dumps(RESULT, indent=2, ensure_ascii=False,
61-
sort_keys=True).encode("utf8"))
59+
print(RESULT)

examples/similar_terms.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get similar terms for an input.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -42,5 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4241
if __name__ == '__main__':
4342
ARGS = PARSER.parse_args()
4443
RESULT = run(ARGS.key, ARGS.url)
45-
print(json.dumps(RESULT, indent=2, ensure_ascii=False,
46-
sort_keys=True).encode("utf8"))
44+
print(RESULT)

examples/syntax_dependencies.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get the syntactic dependencies of a document (at a given URL).
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -34,5 +33,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
3433
if __name__ == '__main__':
3534
ARGS = PARSER.parse_args()
3635
RESULT = run(ARGS.key, ARGS.url)
37-
print(json.dumps(RESULT, indent=2, ensure_ascii=False,
38-
sort_keys=True).encode("utf8"))
36+
print(RESULT)

examples/tokens.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get the tokens (words) in a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4241
if __name__ == '__main__':
4342
ARGS = PARSER.parse_args()
4443
RESULT = run(ARGS.key, ARGS.url)
45-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
44+
print(RESULT)

examples/topics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to get the topics (key phrases and concepts) in a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -43,4 +42,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4342
if __name__ == '__main__':
4443
ARGS = PARSER.parse_args()
4544
RESULT = run(ARGS.key, ARGS.url)
46-
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
45+
print(RESULT)

examples/transliteration.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
Example code to call Rosette API to transliterate a piece of text.
44
"""
5-
from __future__ import print_function
65

76
import argparse
87
import json
@@ -44,5 +43,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
4443
if __name__ == '__main__':
4544
ARGS = PARSER.parse_args()
4645
RESULT = run(ARGS.key, ARGS.url)
47-
print(json.dumps(RESULT, indent=2, ensure_ascii=False,
48-
sort_keys=True).encode("utf8"))
46+
print(RESULT)

rosette/api.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,14 @@ class DocumentParameters(_DocumentParamSetBase):
153153
def __init__(self):
154154
"""Create a L{DocumentParameters} object."""
155155
_DocumentParamSetBase.__init__(
156-
self, ("content", "contentUri", "language", "genre", "profileId"))
156+
self, ("content", "contentUri", "genre", "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.")
162164
if self["content"] is None:
163165
if self["contentUri"] is None:
164166
raise RosetteException(
@@ -236,8 +238,7 @@ def __init__(self):
236238
"sourceLanguageOfUse",
237239
"sourceScript",
238240
"targetScript",
239-
"targetScheme",
240-
"genre"))
241+
"targetScheme"))
241242

242243
def validate(self):
243244
"""Internal. Do not use."""

0 commit comments

Comments
 (0)