From 7f8e2272d831b54a18ec572ba9f0351f516aa7fa Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Wed, 12 Jan 2022 16:02:12 -0600 Subject: [PATCH 001/106] RCB-596: Add sonar ignore and add some more Python version support. --- .gitignore | 1 + setup.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index b53e254..3996c93 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ htmlcov/ nosetests.xml coverage.xml *,cover +.scannerwork/ # Translations *.mo diff --git a/setup.py b/setup.py index 017af14..b581082 100755 --- a/setup.py +++ b/setup.py @@ -54,6 +54,8 @@ def read(*filenames, **kwargs): 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Topic :: Software Development :: Libraries :: Python Modules' ] ) From 85e14c37af42af9a4006b027657ad338378eca73 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Thu, 13 Jan 2022 12:45:27 -0600 Subject: [PATCH 002/106] NO-JIRA: Replace defunct website in categories example. --- examples/categories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/categories.py b/examples/categories.py index c02de34..0f92957 100644 --- a/examples/categories.py +++ b/examples/categories.py @@ -15,7 +15,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): """ Run the example """ - categories_url_data = "https://onlocationvacations.com/2018/02/06/downton-abbey-exhibition-extended-april-2-nyc/" + categories_url_data = "https://rosette.com/about" url = categories_url_data # Create an API instance api = API(user_key=key, service_url=alt_url) From d9888b5ca497b87df6b61baf4bea22d28f8ee649 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Wed, 9 Nov 2022 19:01:24 -0400 Subject: [PATCH 003/106] WS-2589: removing genre from doc & future print_function --- examples/address_similarity.py | 3 +-- examples/categories.py | 3 +-- examples/entities.py | 5 ++--- examples/info.py | 3 +-- examples/language.py | 3 +-- examples/language_multilingual.py | 3 +-- examples/morphology_complete.py | 3 +-- examples/morphology_compound-components.py | 3 +-- examples/morphology_han-readings.py | 3 +-- examples/morphology_lemmas.py | 3 +-- examples/morphology_parts-of-speech.py | 3 +-- examples/name_deduplication.py | 3 +-- examples/name_similarity.py | 1 - examples/name_translation.py | 3 +-- examples/ping.py | 3 +-- examples/relationships.py | 3 +-- examples/semantic_vectors.py | 4 +--- examples/sentences.py | 3 +-- examples/sentiment.py | 4 +--- examples/similar_terms.py | 4 +--- examples/syntax_dependencies.py | 4 +--- examples/tokens.py | 3 +-- examples/topics.py | 3 +-- examples/transliteration.py | 4 +--- 24 files changed, 24 insertions(+), 53 deletions(-) diff --git a/examples/address_similarity.py b/examples/address_similarity.py index 9ffe3a6..a245636 100644 --- a/examples/address_similarity.py +++ b/examples/address_similarity.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get match score (similarity) of two addresses. """ -from __future__ import print_function import argparse import json @@ -36,4 +35,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/categories.py b/examples/categories.py index 774488a..b032488 100644 --- a/examples/categories.py +++ b/examples/categories.py @@ -3,7 +3,6 @@ """ Example code to call Rosette API to get the category of a document (at a given URL). """ -from __future__ import print_function import argparse import json @@ -48,4 +47,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/entities.py b/examples/entities.py index e8191e2..e6e2a50 100644 --- a/examples/entities.py +++ b/examples/entities.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get entities from a piece of text. """ -from __future__ import print_function import argparse import json @@ -27,7 +26,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): 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." params = DocumentParameters() params["content"] = entities_text_data - params["genre"] = "social-media" + try: return api.entities(params) except RosetteException as exception: @@ -43,4 +42,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/info.py b/examples/info.py index ab7159f..9684088 100644 --- a/examples/info.py +++ b/examples/info.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get information such as version and build """ -from __future__ import print_function import argparse import json @@ -32,4 +31,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/language.py b/examples/language.py index c8d82d0..fbfc936 100644 --- a/examples/language.py +++ b/examples/language.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to determine the language of a piece of text. """ -from __future__ import print_function import argparse import json @@ -36,4 +35,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/language_multilingual.py b/examples/language_multilingual.py index 84f5933..c442b76 100644 --- a/examples/language_multilingual.py +++ b/examples/language_multilingual.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to determine the language of a piece of text. """ -from __future__ import print_function import argparse import json @@ -38,4 +37,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/morphology_complete.py b/examples/morphology_complete.py index b1781d3..b1c0880 100644 --- a/examples/morphology_complete.py +++ b/examples/morphology_complete.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get the complete morphological analysis of a piece of text. """ -from __future__ import print_function import argparse import json @@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/morphology_compound-components.py b/examples/morphology_compound-components.py index 3020e60..3332e71 100644 --- a/examples/morphology_compound-components.py +++ b/examples/morphology_compound-components.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get de-compounded words from a piece of text. """ -from __future__ import print_function import argparse import json @@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/morphology_han-readings.py b/examples/morphology_han-readings.py index bc1c9ea..b140969 100644 --- a/examples/morphology_han-readings.py +++ b/examples/morphology_han-readings.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get Chinese readings of words in a piece of text. """ -from __future__ import print_function import argparse import json @@ -41,4 +40,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/morphology_lemmas.py b/examples/morphology_lemmas.py index ae6fe57..20921cb 100644 --- a/examples/morphology_lemmas.py +++ b/examples/morphology_lemmas.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get lemmas for words in a piece of text. """ -from __future__ import print_function import argparse import json @@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/morphology_parts-of-speech.py b/examples/morphology_parts-of-speech.py index 011b37a..48e3a07 100644 --- a/examples/morphology_parts-of-speech.py +++ b/examples/morphology_parts-of-speech.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get part-of-speech tags for words in a piece of text. """ -from __future__ import print_function import argparse import json @@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/name_deduplication.py b/examples/name_deduplication.py index 0392898..3c56fa9 100644 --- a/examples/name_deduplication.py +++ b/examples/name_deduplication.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to deduplicate a list of names. """ -from __future__ import print_function import argparse import json @@ -37,4 +36,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/name_similarity.py b/examples/name_similarity.py index 0020fae..9f5cd79 100644 --- a/examples/name_similarity.py +++ b/examples/name_similarity.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get match score (similarity) of two names. """ -from __future__ import print_function import argparse import json diff --git a/examples/name_translation.py b/examples/name_translation.py index 7f7372d..fd9a753 100644 --- a/examples/name_translation.py +++ b/examples/name_translation.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to translate a name from one language to another. """ -from __future__ import print_function import argparse import json @@ -38,4 +37,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/ping.py b/examples/ping.py index 75aa02b..89d0925 100644 --- a/examples/ping.py +++ b/examples/ping.py @@ -2,7 +2,6 @@ """ Example code to send Rosette API a ping to check its reachability. """ -from __future__ import print_function import argparse import json @@ -32,4 +31,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/relationships.py b/examples/relationships.py index c59861d..a04651c 100644 --- a/examples/relationships.py +++ b/examples/relationships.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get entities's relationships from a piece of text. """ -from __future__ import print_function import argparse import json @@ -34,4 +33,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/semantic_vectors.py b/examples/semantic_vectors.py index 066d920..c67e326 100644 --- a/examples/semantic_vectors.py +++ b/examples/semantic_vectors.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get text vectors from a piece of text. """ -from __future__ import print_function import argparse import json @@ -42,5 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, - sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/sentences.py b/examples/sentences.py index 44ea8eb..747db2e 100644 --- a/examples/sentences.py +++ b/examples/sentences.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get sentences in a piece of text. """ -from __future__ import print_function import argparse import json @@ -36,4 +35,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/sentiment.py b/examples/sentiment.py index 0b6da36..dd5b52e 100644 --- a/examples/sentiment.py +++ b/examples/sentiment.py @@ -3,7 +3,6 @@ """ Example code to call Rosette API to get the sentiment of a local file. """ -from __future__ import print_function import argparse import json @@ -57,5 +56,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, - sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/similar_terms.py b/examples/similar_terms.py index 9695aa7..88f2940 100644 --- a/examples/similar_terms.py +++ b/examples/similar_terms.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get similar terms for an input. """ -from __future__ import print_function import argparse import json @@ -42,5 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, - sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/syntax_dependencies.py b/examples/syntax_dependencies.py index 1790729..38a86b0 100644 --- a/examples/syntax_dependencies.py +++ b/examples/syntax_dependencies.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get the syntactic dependencies of a document (at a given URL). """ -from __future__ import print_function import argparse import json @@ -34,5 +33,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, - sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/tokens.py b/examples/tokens.py index a1fedd3..a7f47a6 100644 --- a/examples/tokens.py +++ b/examples/tokens.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get the tokens (words) in a piece of text. """ -from __future__ import print_function import argparse import json @@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/topics.py b/examples/topics.py index 25d768a..55fa627 100644 --- a/examples/topics.py +++ b/examples/topics.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to get the topics (key phrases and concepts) in a piece of text. """ -from __future__ import print_function import argparse import json @@ -43,4 +42,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) diff --git a/examples/transliteration.py b/examples/transliteration.py index 9fdab66..be9aa82 100644 --- a/examples/transliteration.py +++ b/examples/transliteration.py @@ -2,7 +2,6 @@ """ Example code to call Rosette API to transliterate a piece of text. """ -from __future__ import print_function import argparse import json @@ -44,5 +43,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, - sort_keys=True).encode("utf8")) + print(RESULT) From 6f680a84d0097af1a75de95db66f497b203f1d94 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Tue, 15 Nov 2022 12:35:37 -0400 Subject: [PATCH 004/106] WS-2589: fix print for name_similarity.py --- examples/name_similarity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/name_similarity.py b/examples/name_similarity.py index 9f5cd79..1e81ba8 100644 --- a/examples/name_similarity.py +++ b/examples/name_similarity.py @@ -36,4 +36,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): if __name__ == '__main__': ARGS = PARSER.parse_args() RESULT = run(ARGS.key, ARGS.url) - print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8")) + print(RESULT) From 1c7f34cc893350b7952e0429e49783e26f96978a Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Tue, 15 Nov 2022 18:01:54 -0400 Subject: [PATCH 005/106] WS-2589: removing the genre field --- rosette/api.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rosette/api.py b/rosette/api.py index a85a49f..88bf653 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -153,7 +153,7 @@ class DocumentParameters(_DocumentParamSetBase): def __init__(self): """Create a L{DocumentParameters} object.""" _DocumentParamSetBase.__init__( - self, ("content", "contentUri", "language", "genre", "profileId")) + self, ("content", "contentUri", "language", "profileId")) self.file_name = "" self.use_multipart = False @@ -236,8 +236,7 @@ def __init__(self): "sourceLanguageOfUse", "sourceScript", "targetScript", - "targetScheme", - "genre")) + "targetScheme")) def validate(self): """Internal. Do not use.""" From 91b2e2b418981369b375fd396057531abe7e9449 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Wed, 16 Nov 2022 22:10:39 -0400 Subject: [PATCH 006/106] WS-2589: log warning if genre is present --- rosette/api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rosette/api.py b/rosette/api.py index 88bf653..e729624 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -153,12 +153,14 @@ class DocumentParameters(_DocumentParamSetBase): def __init__(self): """Create a L{DocumentParameters} object.""" _DocumentParamSetBase.__init__( - self, ("content", "contentUri", "language", "profileId")) + self, ("content", "contentUri", "genre", "language", "profileId")) self.file_name = "" self.use_multipart = False def validate(self): """Internal. Do not use.""" + if self["genre"] is not None: + warnings.warn("genre is deprecated and will be removed in the next release.") if self["content"] is None: if self["contentUri"] is None: raise RosetteException( From 9cb45c5a4ec11b718f7653adf672ea1ce7d400e1 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Fri, 13 Jan 2023 14:14:04 -0400 Subject: [PATCH 007/106] RCB-616: removing travis badge --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index a15f1e3..bf603fa 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ --- -[![Build Status](https://travis-ci.org/rosette-api/python.svg?branch=develop)](https://travis-ci.org/rosette-api/python) [![PyPI version](https://badge.fury.io/py/rosette-api.svg)](https://badge.fury.io/py/rosette-api) [![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) From 72a5d015676958d94fbb38dac8997e159f690b42 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Fri, 13 Jan 2023 14:15:22 -0400 Subject: [PATCH 008/106] RCB-616: removing travis file --- .travis.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7128c50..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: python -dist: xenial -# Reflect version changes in setup.py classifiers -# 2.7 EOL - January 2020 -# 3.4 EOL - March 2019 -python: - - "2.7" - - "3.5" - - "3.6" - - "3.7" - - "3.8" -install: - - pip install tox -script: - - tox - -notifications: - slack: - rooms: - - secure: 4FRaTAAiYyeUvgw2RhmblgbNiJO4wmd34OBgWcwURjP9oVmFfSwR9r1LNCdUGxrPOghexSY2DjXIuvIrfTfi/xYbhHb3Kw7PEAyB8IuBMlKtY4NSFou62S2VhYpxyg58T+C7P2zi0eDnDE06pwTCoGPaimxMZQY91yQ0yPYDPVXbwe5SjEgamzlwGBxlS/0A6w1iCPHg27/iO2hXtdW3oLS2I0F/Q8Q95RBkX9hpg6yqHlTV7jRbSqvQ9OFBqk/tXMHQvhoPDGgCgQDuykJuaAYx7g9d0YL0eEYYOh9B/TJ/kNOwdRFBu5kuQ2/nFS5Z0S3Y3UIhdYjUmm9gSMnwIbYnrW22EqDJLoT9Zi3Gv7Prg/8/fSkWsof7BJTMSuXUqO1AxDGKIxFv9uSF1daZoY+AC1ooU1xDu1nNvWVYPlkwEdDxxmHpFkGT3ESTZYccPovQl8Z5K0I1BBAVdJKDzm07lE6VHbxkKcvK6gG0TN3uLxnSlQtjkfJ+aVMq1kxeVsB9lEsKs9oezsKzzbftMm525aXPg+OAv+31CUFWxvT/p4ps8Q+AV6aZpoPHkpK8VryyNirUeZ/m4m4ebDHhD9vcN+JqE9gzshT+0U3g19SvLiUMQtbuZ2BUvrq2hh2LEGs03AFZaNg9AEUVA1PQRhV5NILyoS/lbiBYJPT39Sg= - on_success: always - on_failure: always - From 2ad3f69c52d2395ebd607ac6ca34a1f33fe0e540 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Tue, 24 Jan 2023 09:40:36 -0400 Subject: [PATCH 009/106] RCB-616: adding CI.Jenkinsfile --- CI.Jenkinsfile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 CI.Jenkinsfile diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile new file mode 100644 index 0000000..c68d9a7 --- /dev/null +++ b/CI.Jenkinsfile @@ -0,0 +1,48 @@ +node ("docker-light") { + def sourceDir = pwd() + try { + stage("Clean up") { + step([$class: 'WsCleanup']) + } + stage("Checkout Code") { + checkout scm + } + stage("Build & Test") { + withSonarQubeEnv { + sh "docker run -it --env PATH=\"/root/sonar-scanner/bin:${PATH}\" --volume /Users/yaison/work/basis/git/rosette-api/python/rosette:/source python:3.6-slim bash -c \"apt-get update && \ + apt-get install -y python3-pip && \ + apt-get install -y wget unzip && \ + cd / && \ + wget https://download.java.net/java/GA/jdk19.0.2/fdb695a9d9064ad6b064dc6df578380c/7/GPL/openjdk-19.0.2_linux-x64_bin.tar.gz && \ + tar -xvf openjdk-19.0.2_linux-x64_bin.tar.gz && \ + export JAVA_HOME=/jdk-19.0.2 && \ + export PATH=\"/jdk-19.0.2/bin:$PATH\" && \ + pip3 install tox && \ + cd /root/ && \ + wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ + unzip sonar-scanner-cli-4.8.0.2856-linux.zip && \ + rm sonar-scanner-cli-4.8.0.2856-linux.zip && \ + ln -s sonar-scanner-4.8.0.2856/ sonar-scanner && \ + apt-get purge -y --auto-remove unzip && \ + rm -rf /var/lib/apt/lists/* && \ + echo \"------finish setup------\" && \ + /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ + -Dsonar.sources=/source \ + -Dsonar.host.url=${sonar_host} \ + -Dsonar.login=${sonar_token}\"" + } + } + slack(true) + } catch (e) { + currentBuild.result = "FAILED" + slack(false) + throw e + } +} + +def slack(boolean success) { + def color = success ? "#00FF00" : "#FF0000" + def status = success ? "SUCCESSFUL" : "FAILED" + def message = status + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})" + slackSend(color: color, channel: "#p-n-c_jenkins", message: message) +} \ No newline at end of file From dfdf72d41547dd663c50703801af421c4e77aac7 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Tue, 24 Jan 2023 14:46:36 -0400 Subject: [PATCH 010/106] RCB-616: fix source param --- CI.Jenkinsfile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index c68d9a7..4213541 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -9,14 +9,9 @@ node ("docker-light") { } stage("Build & Test") { withSonarQubeEnv { - sh "docker run -it --env PATH=\"/root/sonar-scanner/bin:${PATH}\" --volume /Users/yaison/work/basis/git/rosette-api/python/rosette:/source python:3.6-slim bash -c \"apt-get update && \ + sh "docker run -it --env PATH=\"/root/sonar-scanner/bin:${PATH}\" --volume ${sourceDir}:/source python:3.6-slim bash -c \"apt-get update && \ apt-get install -y python3-pip && \ apt-get install -y wget unzip && \ - cd / && \ - wget https://download.java.net/java/GA/jdk19.0.2/fdb695a9d9064ad6b064dc6df578380c/7/GPL/openjdk-19.0.2_linux-x64_bin.tar.gz && \ - tar -xvf openjdk-19.0.2_linux-x64_bin.tar.gz && \ - export JAVA_HOME=/jdk-19.0.2 && \ - export PATH=\"/jdk-19.0.2/bin:$PATH\" && \ pip3 install tox && \ cd /root/ && \ wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ From fbef54fe54cdd0a097b0adc40d9b3a46070f8184 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Tue, 24 Jan 2023 14:52:08 -0400 Subject: [PATCH 011/106] RCB-616: fix env variable --- CI.Jenkinsfile | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 4213541..cb8bbc0 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -23,21 +23,12 @@ node ("docker-light") { echo \"------finish setup------\" && \ /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ -Dsonar.sources=/source \ - -Dsonar.host.url=${sonar_host} \ - -Dsonar.login=${sonar_token}\"" + -Dsonar.host.url=${env.SONAR_HOST_URL} \ + -Dsonar.login=${env.SONAR_AUTH_TOKEN}\"" } } - slack(true) } catch (e) { currentBuild.result = "FAILED" - slack(false) throw e } -} - -def slack(boolean success) { - def color = success ? "#00FF00" : "#FF0000" - def status = success ? "SUCCESSFUL" : "FAILED" - def message = status + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})" - slackSend(color: color, channel: "#p-n-c_jenkins", message: message) } \ No newline at end of file From ab0f3f0a07375346357f8c3049d65bf6f1dade57 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Wed, 25 Jan 2023 11:36:22 -0400 Subject: [PATCH 012/106] RCB-616: simpler command --- .vscode/launch.json | 16 ++++++++++++++++ CI.Jenkinsfile | 7 +++---- 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2b2502c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Current File", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "justMyCode": false + } + ] +} \ No newline at end of file diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index cb8bbc0..3bcdd2a 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -16,10 +16,9 @@ node ("docker-light") { cd /root/ && \ wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ unzip sonar-scanner-cli-4.8.0.2856-linux.zip && \ - rm sonar-scanner-cli-4.8.0.2856-linux.zip && \ - ln -s sonar-scanner-4.8.0.2856/ sonar-scanner && \ - apt-get purge -y --auto-remove unzip && \ - rm -rf /var/lib/apt/lists/* && \ + echo \"------about to build------\" && \ + cd /source && \ + tox && \ echo \"------finish setup------\" && \ /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ -Dsonar.sources=/source \ From 60e4653538fafdc03677c7230ef7888c84c2562b Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Wed, 25 Jan 2023 18:23:40 -0400 Subject: [PATCH 013/106] RCB-616: simpler commands --- CI.Jenkinsfile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 3bcdd2a..ac5f4d0 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -9,7 +9,7 @@ node ("docker-light") { } stage("Build & Test") { withSonarQubeEnv { - sh "docker run -it --env PATH=\"/root/sonar-scanner/bin:${PATH}\" --volume ${sourceDir}:/source python:3.6-slim bash -c \"apt-get update && \ + sh "docker run -it --volume ${sourceDir}:/source python:3.6-slim bash -c \"apt-get update && \ apt-get install -y python3-pip && \ apt-get install -y wget unzip && \ pip3 install tox && \ @@ -19,11 +19,7 @@ node ("docker-light") { echo \"------about to build------\" && \ cd /source && \ tox && \ - echo \"------finish setup------\" && \ - /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ - -Dsonar.sources=/source \ - -Dsonar.host.url=${env.SONAR_HOST_URL} \ - -Dsonar.login=${env.SONAR_AUTH_TOKEN}\"" + echo \"------finish setup------\"" } } } catch (e) { From 81927fa9ee44a09db291dbc9d9f8321b8d21aed0 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Wed, 25 Jan 2023 19:53:58 -0400 Subject: [PATCH 014/106] RCB-616: smaller build. --- CI.Jenkinsfile | 7 +------ tox.ini | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index ac5f4d0..2b0ef0b 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -13,13 +13,8 @@ node ("docker-light") { apt-get install -y python3-pip && \ apt-get install -y wget unzip && \ pip3 install tox && \ - cd /root/ && \ - wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ - unzip sonar-scanner-cli-4.8.0.2856-linux.zip && \ - echo \"------about to build------\" && \ cd /source && \ - tox && \ - echo \"------finish setup------\"" + tox\"" } } } catch (e) { diff --git a/tox.ini b/tox.ini index 23301ee..3f4f612 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ [tox] skipsdist = True -envlist = py2, py3 +envlist = py3 [testenv] commands = From 33e2845e21ca39f76acf60efbf2bc0fc373f6492 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Wed, 25 Jan 2023 19:55:34 -0400 Subject: [PATCH 015/106] RCB-616: minimal script --- CI.Jenkinsfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 2b0ef0b..d8267c4 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -9,10 +9,11 @@ node ("docker-light") { } stage("Build & Test") { withSonarQubeEnv { - sh "docker run -it --volume ${sourceDir}:/source python:3.6-slim bash -c \"apt-get update && \ - apt-get install -y python3-pip && \ - apt-get install -y wget unzip && \ - pip3 install tox && \ + sh "docker run \ + --pull always \ + --rm --volume ${sourceDir}:/source \ + python:3.6-slim \ + bash -c \"pip3 install tox && \ cd /source && \ tox\"" } From 2485ccba75f6b03633e46602b06bd305023a0a4b Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Wed, 25 Jan 2023 20:06:32 -0400 Subject: [PATCH 016/106] RCB-616: working script --- CI.Jenkinsfile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index d8267c4..d687db3 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -13,9 +13,18 @@ node ("docker-light") { --pull always \ --rm --volume ${sourceDir}:/source \ python:3.6-slim \ - bash -c \"pip3 install tox && \ + bash -c \"apt-get update && \ + apt-get install -y wget unzip && \ + pip3 install tox && \ + cd /root/ && \ + wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ + unzip sonar-scanner-cli-4.8.0.2856-linux.zip && \ cd /source && \ - tox\"" + tox && \ + /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ + -Dsonar.sources=/source \ + -Dsonar.host.url=${env.SONAR_HOST_URL} \ + -Dsonar.login=${env.SONAR_AUTH_TOKEN}\"" } } } catch (e) { From b93552e14fd5046a634a13e0cfa8ec99210a455a Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Thu, 26 Jan 2023 11:36:01 -0400 Subject: [PATCH 017/106] RCB-616: loop python versions --- CI.Jenkinsfile | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index d687db3..ca34507 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -1,3 +1,26 @@ + + +def versions = [3.11, 3.10, 3.9, 3.8, 3.7] + +def runSonnarForPythonVersion(ver){ + sh "docker run \ + --pull always \ + --rm --volume ${sourceDir}:/source \ + python:${ver}-slim \ + bash -c \"apt-get update && \ + apt-get install -y wget unzip && \ + pip3 install tox && \ + cd /root/ && \ + wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ + unzip sonar-scanner-cli-4.8.0.2856-linux.zip && \ + cd /source && \ + tox && \ + /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ + -Dsonar.sources=/source \ + -Dsonar.host.url=${env.SONAR_HOST_URL} \ + -Dsonar.login=${env.SONAR_AUTH_TOKEN}\"" +} + node ("docker-light") { def sourceDir = pwd() try { @@ -9,22 +32,10 @@ node ("docker-light") { } stage("Build & Test") { withSonarQubeEnv { - sh "docker run \ - --pull always \ - --rm --volume ${sourceDir}:/source \ - python:3.6-slim \ - bash -c \"apt-get update && \ - apt-get install -y wget unzip && \ - pip3 install tox && \ - cd /root/ && \ - wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ - unzip sonar-scanner-cli-4.8.0.2856-linux.zip && \ - cd /source && \ - tox && \ - /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ - -Dsonar.sources=/source \ - -Dsonar.host.url=${env.SONAR_HOST_URL} \ - -Dsonar.login=${env.SONAR_AUTH_TOKEN}\"" + + versions.each { ver -> + runSonnarForPythonVersion(ver) + } } } } catch (e) { From ff078d1d5f331467bb233fb40c7c447ca7e382f5 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Thu, 26 Jan 2023 11:46:56 -0400 Subject: [PATCH 018/106] RCB-616: fix syntax --- CI.Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index ca34507..e4830ef 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -2,7 +2,7 @@ def versions = [3.11, 3.10, 3.9, 3.8, 3.7] -def runSonnarForPythonVersion(ver){ +def runSonnarForPythonVersion(sourceDir, ver){ sh "docker run \ --pull always \ --rm --volume ${sourceDir}:/source \ @@ -34,7 +34,7 @@ node ("docker-light") { withSonarQubeEnv { versions.each { ver -> - runSonnarForPythonVersion(ver) + runSonnarForPythonVersion(sourceDir, ver) } } } From fbf350072c071133596aec96aff2420e88445429 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Fri, 27 Jan 2023 11:45:36 -0400 Subject: [PATCH 019/106] RCB-616: adding extra sonnar config --- CI.Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index e4830ef..cb681b5 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -17,6 +17,9 @@ def runSonnarForPythonVersion(sourceDir, ver){ tox && \ /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ -Dsonar.sources=/source \ + -Dsonar.pullrequest.key=${env.CHANGE_ID} \ + -Dsonar.pullrequest.base=${env.CHANGE_TARGET} \ + -Dsonar.pullrequest.branch=${env.BRANCH_NAME} \ -Dsonar.host.url=${env.SONAR_HOST_URL} \ -Dsonar.login=${env.SONAR_AUTH_TOKEN}\"" } From 9fffeb9afee86a75791150eac2112839b524a9b1 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Mon, 30 Jan 2023 12:33:57 -0400 Subject: [PATCH 020/106] RCB-616: adding sonar opts --- CI.Jenkinsfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index cb681b5..70ef23c 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -3,6 +3,12 @@ def versions = [3.11, 3.10, 3.9, 3.8, 3.7] def runSonnarForPythonVersion(sourceDir, ver){ + mySonarOpts="-Dsonar.sources=/source -Dsonar.pullrequest.branch=${env.BRANCH_NAME} -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}" + if ("${env.CHANGE_BRANCH}" != "null") { + mySonarOpts="$mySonarOpts -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}" + }else{ + mySonarOpts="$mySonarOpts -Dsonar.pullrequest.branch=${env.BRANCH_NAME}" + } sh "docker run \ --pull always \ --rm --volume ${sourceDir}:/source \ @@ -16,12 +22,7 @@ def runSonnarForPythonVersion(sourceDir, ver){ cd /source && \ tox && \ /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ - -Dsonar.sources=/source \ - -Dsonar.pullrequest.key=${env.CHANGE_ID} \ - -Dsonar.pullrequest.base=${env.CHANGE_TARGET} \ - -Dsonar.pullrequest.branch=${env.BRANCH_NAME} \ - -Dsonar.host.url=${env.SONAR_HOST_URL} \ - -Dsonar.login=${env.SONAR_AUTH_TOKEN}\"" + ${mySonarOpts}\"" } node ("docker-light") { From 9426cc00afdaa36ebe3cccb8f4f4d62467c18646 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Mon, 30 Jan 2023 13:48:30 -0400 Subject: [PATCH 021/106] RCB-616: adding pull request key --- CI.Jenkinsfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 70ef23c..d5ac399 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -3,11 +3,9 @@ def versions = [3.11, 3.10, 3.9, 3.8, 3.7] def runSonnarForPythonVersion(sourceDir, ver){ - mySonarOpts="-Dsonar.sources=/source -Dsonar.pullrequest.branch=${env.BRANCH_NAME} -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}" + mySonarOpts="-Dsonar.sources=/source -Dsonar.pullrequest.branch=${env.BRANCH_NAME} -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN} -Dsonar.pullrequest.key=${env.CHANGE_ID}" if ("${env.CHANGE_BRANCH}" != "null") { - mySonarOpts="$mySonarOpts -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}" - }else{ - mySonarOpts="$mySonarOpts -Dsonar.pullrequest.branch=${env.BRANCH_NAME}" + mySonarOpts="$mySonarOpts -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}" } sh "docker run \ --pull always \ From de4e3c5dee79f28818b56639ad0f94281eabcd1c Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Tue, 31 Jan 2023 12:06:08 -0400 Subject: [PATCH 022/106] CB-616: adding NO-PR --- CI.Jenkinsfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index d5ac399..440ffb3 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -3,7 +3,12 @@ def versions = [3.11, 3.10, 3.9, 3.8, 3.7] def runSonnarForPythonVersion(sourceDir, ver){ - mySonarOpts="-Dsonar.sources=/source -Dsonar.pullrequest.branch=${env.BRANCH_NAME} -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN} -Dsonar.pullrequest.key=${env.CHANGE_ID}" + mySonarOpts="-Dsonar.sources=/source -Dsonar.pullrequest.branch=${env.BRANCH_NAME} -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN} " + if ("${env.CHANGE_ID}" != "null"){ + mySonarOpts = "$mySonarOpts -Dsonar.pullrequest.key=${env.CHANGE_ID}" + } else { + mySonarOpts = "$mySonarOpts -Dsonar.pullrequest.key=NO-PR" + } if ("${env.CHANGE_BRANCH}" != "null") { mySonarOpts="$mySonarOpts -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}" } From ee73556ec739994fb269b3315c4cc95118302b09 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Tue, 31 Jan 2023 12:26:29 -0400 Subject: [PATCH 023/106] RCB-616: moving branch name param --- CI.Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 440ffb3..7d3de48 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -3,12 +3,12 @@ def versions = [3.11, 3.10, 3.9, 3.8, 3.7] def runSonnarForPythonVersion(sourceDir, ver){ - mySonarOpts="-Dsonar.sources=/source -Dsonar.pullrequest.branch=${env.BRANCH_NAME} -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN} " - if ("${env.CHANGE_ID}" != "null"){ - mySonarOpts = "$mySonarOpts -Dsonar.pullrequest.key=${env.CHANGE_ID}" + mySonarOpts="-Dsonar.sources=/source -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}" + if("${env.CHANGE_ID}" != "null"){ + mySonarOpts = "$mySonarOpts -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.BRANCH_NAME}" } else { - mySonarOpts = "$mySonarOpts -Dsonar.pullrequest.key=NO-PR" - } + mySonarOpts = "$mySonarOpts -Dsonar.branch.name=${env.BRANCH_NAME}" + } if ("${env.CHANGE_BRANCH}" != "null") { mySonarOpts="$mySonarOpts -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}" } @@ -20,8 +20,8 @@ def runSonnarForPythonVersion(sourceDir, ver){ apt-get install -y wget unzip && \ pip3 install tox && \ cd /root/ && \ - wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ - unzip sonar-scanner-cli-4.8.0.2856-linux.zip && \ + wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ + unzip -q sonar-scanner-cli-4.8.0.2856-linux.zip && \ cd /source && \ tox && \ /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ From f742863d5adadcdc5d64a3c217df3c67c3450f06 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Thu, 2 Feb 2023 00:55:35 +0000 Subject: [PATCH 024/106] Version 1.24.0 --- docs/source/conf.py | 4 ++-- rosette/__init__.py | 2 +- rosette/api.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 0846005..59b477c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -55,9 +55,9 @@ # built documents. # # The short X.Y version. -version = '1.20.0' +version = '1.24.0' # The full version, including alpha/beta/rc tags. -release = '1.20.0' +release = '1.24.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/rosette/__init__.py b/rosette/__init__.py index bbeb61e..ae2c643 100644 --- a/rosette/__init__.py +++ b/rosette/__init__.py @@ -12,4 +12,4 @@ limitations under the License. """ -__version__ = '1.20.0' +__version__ = '1.24.0' diff --git a/rosette/api.py b/rosette/api.py index e729624..3bdede0 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -30,7 +30,7 @@ _APPLICATION_JSON = 'application/json' _BINDING_LANGUAGE = 'python' -_BINDING_VERSION = '1.20.0' +_BINDING_VERSION = '1.24.0' _CONCURRENCY_HEADER = 'x-rosetteapi-concurrency' _CUSTOM_HEADER_PREFIX = 'X-RosetteAPI-' _CUSTOM_HEADER_PATTERN = re.compile('^' + _CUSTOM_HEADER_PREFIX) From d9ef6a701216e050beef608afaeb2a57567b8306 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Thu, 2 Feb 2023 15:44:59 -0400 Subject: [PATCH 025/106] RCB-616: reverting categories_url_data --- examples/categories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/categories.py b/examples/categories.py index b032488..88fbb37 100644 --- a/examples/categories.py +++ b/examples/categories.py @@ -14,7 +14,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): """ Run the example """ - categories_url_data = "https://www.rosette.com/about/" + categories_url_data = "https://rosette.com/about" url = categories_url_data # Create an API instance api = API(user_key=key, service_url=alt_url) From 57b6ed39a7b6eacf401b8b745150edd920e08f75 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Thu, 2 Feb 2023 16:52:34 -0400 Subject: [PATCH 026/106] RCB-616: conflict fix --- examples/categories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/categories.py b/examples/categories.py index b032488..88fbb37 100644 --- a/examples/categories.py +++ b/examples/categories.py @@ -14,7 +14,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): """ Run the example """ - categories_url_data = "https://www.rosette.com/about/" + categories_url_data = "https://rosette.com/about" url = categories_url_data # Create an API instance api = API(user_key=key, service_url=alt_url) From df87f734702107d4c62aafd86f8e2facfecb5f9f Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Mon, 6 Feb 2023 10:50:48 -0400 Subject: [PATCH 027/106] RCB-616: updating docker pull images name --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 42eec0f..58a6d77 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,8 +15,8 @@ node ("docker-light") { echo "${env.ALT_URL}" def useUrl = ("${env.ALT_URL}" == "null") ? "${env.BINDING_TEST_URL}" : "${env.ALT_URL}" withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${useUrl}"]) { - sh "docker pull rosetteapi/docker-python" - sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source rosetteapi/docker-python" + sh "docker pull rosette/docker-python" + sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source rosette/docker-python" } } slack(true) From 0016068eee393f041772377a807ee17a5c365aaa Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Fri, 10 Feb 2023 15:20:49 -0400 Subject: [PATCH 028/106] RCB-616: removing VS Code dir --- .gitignore | 3 +++ .vscode/launch.json | 16 ---------------- 2 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.gitignore b/.gitignore index d08202e..be7f8d9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ ehthumbs.db Thumbs.db +# VS Code +.vscode + # Jetbrains **/.idea/* !**/.idea/runConfigurations/ diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 2b2502c..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python: Current File", - "type": "python", - "request": "launch", - "program": "${file}", - "console": "integratedTerminal", - "justMyCode": false - } - ] -} \ No newline at end of file From 747f14c52a5f926e283a0f411627e561076d80d1 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Fri, 10 Feb 2023 15:38:36 -0400 Subject: [PATCH 029/106] RCB-616: adding TODO comment. --- CI.Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 7d3de48..526663b 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -1,5 +1,6 @@ +// TODO: find a way to skip the Sonar scan for all this version, but one (maybe the latest?). def versions = [3.11, 3.10, 3.9, 3.8, 3.7] def runSonnarForPythonVersion(sourceDir, ver){ From f56e007765f6576d34f55583e7c18f1f983fd00f Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Fri, 10 Feb 2023 15:54:15 -0400 Subject: [PATCH 030/106] RCB-616: moved TODO comment --- CI.Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 526663b..660a300 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -1,6 +1,5 @@ -// TODO: find a way to skip the Sonar scan for all this version, but one (maybe the latest?). def versions = [3.11, 3.10, 3.9, 3.8, 3.7] def runSonnarForPythonVersion(sourceDir, ver){ @@ -13,6 +12,8 @@ def runSonnarForPythonVersion(sourceDir, ver){ if ("${env.CHANGE_BRANCH}" != "null") { mySonarOpts="$mySonarOpts -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}" } + + // TODO: find a way to skip the Sonar scan for all those version, but one (maybe the latest?). sh "docker run \ --pull always \ --rm --volume ${sourceDir}:/source \ From 2340b7c0d02236a072ba69b0bee64381e3d766f7 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Fri, 10 Feb 2023 16:03:23 -0400 Subject: [PATCH 031/106] RCB-616: updated supported python versions --- setup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.py b/setup.py index b581082..b266ac2 100755 --- a/setup.py +++ b/setup.py @@ -49,13 +49,11 @@ def read(*filenames, **kwargs): 'Natural Language :: English', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'Topic :: Software Development :: Libraries :: Python Modules' ] ) From f6514610270985f7bc90bfdec1aba8f23118bfb4 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Fri, 10 Feb 2023 19:21:38 -0400 Subject: [PATCH 032/106] RCB-616: removing all genre references. --- rosette/api.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rosette/api.py b/rosette/api.py index e729624..88bf653 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -153,14 +153,12 @@ class DocumentParameters(_DocumentParamSetBase): def __init__(self): """Create a L{DocumentParameters} object.""" _DocumentParamSetBase.__init__( - self, ("content", "contentUri", "genre", "language", "profileId")) + self, ("content", "contentUri", "language", "profileId")) self.file_name = "" self.use_multipart = False def validate(self): """Internal. Do not use.""" - if self["genre"] is not None: - warnings.warn("genre is deprecated and will be removed in the next release.") if self["content"] is None: if self["contentUri"] is None: raise RosetteException( From fed6935a72b684f45b1d62a123001a09ef824c6c Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Fri, 31 Mar 2023 16:37:43 -0400 Subject: [PATCH 033/106] WS-2705: updating dockerhub ref --- DEVELOPER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVELOPER.md b/DEVELOPER.md index 43d2168..54afffa 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -47,7 +47,7 @@ To test changes you have made to the binding, you can use a pre-configured Docke git clone git@github.com:rosette-api/python.git cd python # Modify the binding... -docker run -e API_KEY=$API_KEY -v $(pwd):/source rosetteapi/docker-python +docker run -e API_KEY=$API_KEY -v $(pwd):/source rosette/docker-python ``` Optional parameters for the `docker run` execution are: From 63ca14a9297253156ba18887d0e2eed2040f6eca Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Fri, 31 Mar 2023 16:48:08 -0400 Subject: [PATCH 034/106] WS-2705: updating docker compose --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3cc15a6..1ca7e96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ application: - image: rosetteapi/docker-python + image: rosette/docker-python environment: - API_KEY=$API_KEY - HTTP_PROXY=http://squid:3128 From f8bba262e63899ba339f54ed45d808bdc9cfcf51 Mon Sep 17 00:00:00 2001 From: Yaison <> Date: Wed, 5 Apr 2023 09:23:55 -0400 Subject: [PATCH 035/106] RCB-619: using str instead of boolean --- rosette/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosette/api.py b/rosette/api.py index 6e925a2..b35701c 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -494,7 +494,7 @@ def call(self, parameters): _my_loads(rdata, response_headers), status) else: if self.debug: - headers[_CUSTOM_HEADER_PREFIX + 'Devel'] = True + headers[_CUSTOM_HEADER_PREFIX + 'Devel'] = 'true' self.logger.info('operate: ' + url) headers['Accept'] = _APPLICATION_JSON headers['Accept-Encoding'] = "gzip" From 02899c0289d563614211da546a358d050dca3fbd Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Mon, 8 May 2023 17:11:16 -0500 Subject: [PATCH 036/106] RCB-620: Name and Address match parameter overrides. --- examples/address_similarity.py | 1 + examples/name_similarity.py | 2 + rosette/api.py | 34 ++++++++++++---- tests/test_rosette_api.py | 71 +++++++++++++++++++++++++++++++++- 4 files changed, 99 insertions(+), 9 deletions(-) diff --git a/examples/address_similarity.py b/examples/address_similarity.py index a245636..f69e4e1 100644 --- a/examples/address_similarity.py +++ b/examples/address_similarity.py @@ -18,6 +18,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): params = AddressSimilarityParameters() params["address1"] = {"houseNumber": "1600", "road": "Pennsylvania Ave NW", "city": "Washington", "state": "DC", "postCode": "20500"} params["address2"] = "160 Pennsilvana Avenue, Washington, D.C., 20500" + #params["parameters"] = {"houseNumberAddressFieldWeight": "0.9"} try: return api.address_similarity(params) diff --git a/examples/name_similarity.py b/examples/name_similarity.py index 1e81ba8..d700789 100644 --- a/examples/name_similarity.py +++ b/examples/name_similarity.py @@ -20,6 +20,8 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): params = NameSimilarityParameters() params["name1"] = {"text": matched_name_data1, "language": "eng", "entityType": "PERSON"} params["name2"] = {"text": matched_name_data2, "entityType": "PERSON"} + #params["parameters"] = {"conflictScore": "0.9", "deletionScore": "0.2"} + try: return api.name_similarity(params) except RosetteException as exception: diff --git a/rosette/api.py b/rosette/api.py index b35701c..030702f 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -250,7 +250,10 @@ def validate(self): class AddressSimilarityParameters(_DocumentParamSetBase): """Parameter object for C{address-similarity} endpoint. - All are required. + + C{address1} and C{address2} are required. + + `parameters` is optional. C{address1} The address to be matched, a C{address} object or address string. @@ -258,11 +261,17 @@ class AddressSimilarityParameters(_DocumentParamSetBase): The C{address} object contains these optional fields: city, island, district, stateDistrict, state, countryRegion, country, worldRegion, postCode, poBox + + `parameters` is a dictionary listing any parameter overrides to include. For example, `postCodeAddressFieldWeight`. + Setting `parameters` is not cumulative. Define all overrides at once. If defined multiple times, only the + final declaration is used. + + See `examples/address_similarity.py` """ def __init__(self): self.use_multipart = False - _DocumentParamSetBase.__init__(self, ("address1", "address2")) + _DocumentParamSetBase.__init__(self, ("address1", "address2", "parameters")) def validate(self): """Internal. Do not use.""" @@ -276,7 +285,10 @@ def validate(self): class NameSimilarityParameters(_DocumentParamSetBase): """Parameter object for C{name-similarity} endpoint. - All are required. + + C{name1} and C{name2} are required. + + `parameters` is optional. C{name1} The name to be matched, a C{name} object. @@ -284,18 +296,24 @@ class NameSimilarityParameters(_DocumentParamSetBase): The C{name} object contains these fields: - C{text} Text of the name, required. + C{text} Text of the name, required. + + C{language} Language of the name in ISO639 three-letter code, optional. + + C{script} The ISO15924 code of the name, optional. - C{language} Language of the name in ISO639 three-letter code, optional. + C{entityType} The entity type, can be "PERSON", "LOCATION" or "ORGANIZATION", optional. - C{script} The ISO15924 code of the name, optional. + `parameters` is a dictionary listing any parameter overrides to include. For example, `deletionScore`. + Setting `parameters` is not cumulative. Define all overrides at once. If defined multiple times, only the + final declaration is used. - C{entityType} The entity type, can be "PERSON", "LOCATION" or "ORGANIZATION", optional. + See `examples/name_similarity.py` """ def __init__(self): self.use_multipart = False - _DocumentParamSetBase.__init__(self, ("name1", "name2")) + _DocumentParamSetBase.__init__(self, ("name1", "name2", "parameters")) def validate(self): """Internal. Do not use.""" diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index 0770bec..dd193b0 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -427,6 +427,48 @@ def test_the_name_translation_endpoint(api, json_response): # Test the name similarity endpoint +def test_the_name_similarity_single_parameters(api, json_response): + """Test the name similarity parameters""" + httpretty.enable() + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + body=json_response, status=200, content_type="application/json") + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", + body=json_response, status=200, content_type="application/json") + + matched_name_data1 = "John Mike Smith" + matched_name_data2 = "John Joe Smith" + params = NameSimilarityParameters() + params["name1"] = {"text": matched_name_data1} + params["name2"] = {"text": matched_name_data2} + params["parameters"] = {"conflictScore": "0.9"} + + result = api.name_similarity(params) + assert result["name"] == "Rosette" + httpretty.disable() + httpretty.reset() + + +def test_the_name_similarity_multiple_parameters(api, json_response): + """Test the name similarity parameters""" + httpretty.enable() + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + body=json_response, status=200, content_type="application/json") + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", + body=json_response, status=200, content_type="application/json") + + matched_name_data1 = "John Mike Smith" + matched_name_data2 = "John Joe Smith" + params = NameSimilarityParameters() + params["name1"] = {"text": matched_name_data1} + params["name2"] = {"text": matched_name_data2} + params["parameters"] = {"conflictScore": "0.9", "deletionScore": "0.5"} + + result = api.name_similarity(params) + assert result["name"] == "Rosette" + httpretty.disable() + httpretty.reset() + + def test_the_name_similarity_endpoint(api, json_response): """Test the name similarity endpoint""" httpretty.enable() @@ -449,10 +491,11 @@ def test_the_name_similarity_endpoint(api, json_response): httpretty.disable() httpretty.reset() + # Test the name deduplication endpoint -def test_name_deduplicatation_parameters(api, json_response): +def test_name_deduplication_parameters(api, json_response): """Test the Name Deduplication Parameters""" httpretty.enable() httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", @@ -612,6 +655,32 @@ def test_for_address_similarity_required_parameters(api, json_response): httpretty.reset() +def test_for_address_similarity_optional_parameters(api, json_response): + """Test address similarity parameters""" + httpretty.enable() + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + body=json_response, status=200, content_type="application/json") + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/address-similarity", + body=json_response, status=200, content_type="application/json") + + params = AddressSimilarityParameters() + + params["address1"] = {"houseNumber": "1600", + "road": "Pennsylvania Ave NW", + "city": "Washington", + "state": "DC", + "postCode": "20500"} + + params["address2"] = {"text": "160 Pennsilvana Avenue, Washington, D.C., 20500"} + + params["parameters"] = {"houseNumberAddressFieldWeight": "0.9"} + + result = api.address_similarity(params) + assert result["name"] == "Rosette" + httpretty.disable() + httpretty.reset() + + # Test for required Name Similarity parameters From 106832d0d9673c6bfed3a89078ad76b184f80fd7 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Tue, 9 May 2023 12:19:55 -0500 Subject: [PATCH 037/106] RCB-620: Update source and test directories for Sonar reporting. --- sonar-project.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sonar-project.properties b/sonar-project.properties index fb71b92..a81bdc1 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,4 +1,6 @@ sonar.projectKey=rosette-api-python-binding sonar.sources=rosette sonar.python.coverage.reportPaths=coverage.xml +sonar.sources=rosette +sonar.tests=tests #sonar.branch.name=RCB-596-pool-size From 8d150cd56cc757c037c7e9fa0aaef6a1bd37e6eb Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Tue, 9 May 2023 12:46:25 -0500 Subject: [PATCH 038/106] RCB-620: More Sonar filtering. Try to run the scan just once. --- CI.Jenkinsfile | 18 ++++++++++++------ sonar-project.properties | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 660a300..b7a1e51 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -13,7 +13,17 @@ def runSonnarForPythonVersion(sourceDir, ver){ mySonarOpts="$mySonarOpts -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}" } - // TODO: find a way to skip the Sonar scan for all those version, but one (maybe the latest?). + // Only run Sonar once. + if($ver == 3.11) { + sonarExec="cd /root/ && \ + wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ + unzip -q sonar-scanner-cli-4.8.0.2856-linux.zip && \ + cd /source && \ + /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner ${mySonarOpts}" + } else { + sonarExec="" + } + sh "docker run \ --pull always \ --rm --volume ${sourceDir}:/source \ @@ -21,13 +31,9 @@ def runSonnarForPythonVersion(sourceDir, ver){ bash -c \"apt-get update && \ apt-get install -y wget unzip && \ pip3 install tox && \ - cd /root/ && \ - wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ - unzip -q sonar-scanner-cli-4.8.0.2856-linux.zip && \ cd /source && \ tox && \ - /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ - ${mySonarOpts}\"" + ${sonarExec}\"" } node ("docker-light") { diff --git a/sonar-project.properties b/sonar-project.properties index a81bdc1..cf62eb3 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,5 +2,5 @@ sonar.projectKey=rosette-api-python-binding sonar.sources=rosette sonar.python.coverage.reportPaths=coverage.xml sonar.sources=rosette -sonar.tests=tests +sonar.tests=tests/*.py #sonar.branch.name=RCB-596-pool-size From f81510731801c7399efedc84f2b8c5dd34b1dc64 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Tue, 9 May 2023 13:37:15 -0500 Subject: [PATCH 039/106] RCB-620: Fix CI and only give sonar a directory name. --- CI.Jenkinsfile | 2 +- sonar-project.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index b7a1e51..4328983 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -14,7 +14,7 @@ def runSonnarForPythonVersion(sourceDir, ver){ } // Only run Sonar once. - if($ver == 3.11) { + if(ver == 3.11) { sonarExec="cd /root/ && \ wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ unzip -q sonar-scanner-cli-4.8.0.2856-linux.zip && \ diff --git a/sonar-project.properties b/sonar-project.properties index cf62eb3..a81bdc1 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,5 +2,5 @@ sonar.projectKey=rosette-api-python-binding sonar.sources=rosette sonar.python.coverage.reportPaths=coverage.xml sonar.sources=rosette -sonar.tests=tests/*.py +sonar.tests=tests #sonar.branch.name=RCB-596-pool-size From 28005f24c0bd7ad59a59b36595d841811804de1c Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Tue, 9 May 2023 14:22:12 -0500 Subject: [PATCH 040/106] RCB-620: Do not call setup.py. Generate coverage data. Use Sonar recommended relative files setting. --- sonar-project.properties | 2 -- tox.ini | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index a81bdc1..fb71b92 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,4 @@ sonar.projectKey=rosette-api-python-binding sonar.sources=rosette sonar.python.coverage.reportPaths=coverage.xml -sonar.sources=rosette -sonar.tests=tests #sonar.branch.name=RCB-596-pool-size diff --git a/tox.ini b/tox.ini index 3f4f612..808daa0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,19 +1,21 @@ -# Tox (http://tox.testrun.org/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. To use it, "pip install tox" -# and then run "tox" from this directory. - [tox] -skipsdist = True envlist = py3 +skipsdist = True [testenv] -commands = - {envpython} setup.py install - {envbindir}/py.test deps = pytest pep8 httpretty epydoc requests + coverage + build + +commands = + python -m build + coverage run -m pytest + coverage xml + +[coverage:run] +relative_files = True From 54e5a136e182f7807de86f01ba9a4d69cbfb19e6 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Tue, 9 May 2023 14:50:44 -0500 Subject: [PATCH 041/106] RCB-620: Need to have sonarExec default to something. Run Python version tests in the other order. --- CI.Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 4328983..457d077 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -1,6 +1,6 @@ -def versions = [3.11, 3.10, 3.9, 3.8, 3.7] +def versions = [3.7, 3.8, 3.9, 3.10, 3.11] def runSonnarForPythonVersion(sourceDir, ver){ mySonarOpts="-Dsonar.sources=/source -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}" @@ -21,7 +21,7 @@ def runSonnarForPythonVersion(sourceDir, ver){ cd /source && \ /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner ${mySonarOpts}" } else { - sonarExec="" + sonarExec="echo Skipping Sonar for this version." } sh "docker run \ From 9697f06dcd52f6dd0df1cbd906491f7642e13d87 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Tue, 9 May 2023 15:02:47 -0500 Subject: [PATCH 042/106] RCB-602: Sonar cleanup. --- rosette/api.py | 8 ++++---- sonar-project.properties | 1 + tests/test_rosette_api.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rosette/api.py b/rosette/api.py index 030702f..744c479 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -113,7 +113,7 @@ def serialize(self, options): """serialize keys with values""" self.validate() values = {} - for (key, val) in self.__params.items(): + for key, val in self.__params.items(): if val is None: continue else: @@ -240,7 +240,7 @@ def __init__(self): def validate(self): """Internal. Do not use.""" - for option in ("name", "targetLanguage"): # required + for option in "name", "targetLanguage": # required if self[option] is None: raise RosetteException( "missingParameter", @@ -275,7 +275,7 @@ def __init__(self): def validate(self): """Internal. Do not use.""" - for option in ("address1", "address2"): # required + for option in "address1", "address2": # required if self[option] is None: raise RosetteException( "missingParameter", @@ -317,7 +317,7 @@ def __init__(self): def validate(self): """Internal. Do not use.""" - for option in ("name1", "name2"): # required + for option in "name1", "name2": # required if self[option] is None: raise RosetteException( "missingParameter", diff --git a/sonar-project.properties b/sonar-project.properties index fb71b92..2bdb883 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,4 +1,5 @@ sonar.projectKey=rosette-api-python-binding sonar.sources=rosette +sonar.exclusions=**/tests/**,**/docs/**,**/examples/** sonar.python.coverage.reportPaths=coverage.xml #sonar.branch.name=RCB-596-pool-size diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index dd193b0..456a1af 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -589,7 +589,7 @@ def test_for_content_and_contentUri(api, json_response, doc_params): httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/entities", body=json_response, status=200, content_type="application/json") - doc_params['contentUri'] = 'http://google.com' + doc_params['contentUri'] = 'https://example.com' with pytest.raises(RosetteException) as e_rosette: api.entities(doc_params) From 86b295257cf17cadfd750433153597c60c9d980b Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Thu, 11 May 2023 13:35:53 -0500 Subject: [PATCH 043/106] RCB-620: Update a placeholder in a docstring. --- rosette/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosette/api.py b/rosette/api.py index 744c479..169bfe0 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -212,7 +212,7 @@ class NameTranslationParameters(_DocumentParamSetBase): C{targetLangauge} The language into which the name is to be translated. - C{entityType} The entity type (TBD) of the name. + C{entityType} The entity type of the name. PERSON (default), LOCATION, or ORGANIZATION C{sourceLanguageOfOrigin} The language of origin of the name. From 37c21ef82de49774ec9a6cba0b6d50db1b0b35c9 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Thu, 11 May 2023 19:44:10 +0000 Subject: [PATCH 044/106] Version 1.25.1 --- docs/source/conf.py | 4 ++-- rosette/__init__.py | 2 +- rosette/api.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 59b477c..06117be 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -55,9 +55,9 @@ # built documents. # # The short X.Y version. -version = '1.24.0' +version = '1.25.1' # The full version, including alpha/beta/rc tags. -release = '1.24.0' +release = '1.25.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/rosette/__init__.py b/rosette/__init__.py index ae2c643..c583524 100644 --- a/rosette/__init__.py +++ b/rosette/__init__.py @@ -12,4 +12,4 @@ limitations under the License. """ -__version__ = '1.24.0' +__version__ = '1.25.1' diff --git a/rosette/api.py b/rosette/api.py index 169bfe0..cfe5633 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -30,7 +30,7 @@ _APPLICATION_JSON = 'application/json' _BINDING_LANGUAGE = 'python' -_BINDING_VERSION = '1.24.0' +_BINDING_VERSION = '1.25.1' _CONCURRENCY_HEADER = 'x-rosetteapi-concurrency' _CUSTOM_HEADER_PREFIX = 'X-RosetteAPI-' _CUSTOM_HEADER_PATTERN = re.compile('^' + _CUSTOM_HEADER_PREFIX) From a940bdc4bb10b9468211afd43e9cc749f3f08847 Mon Sep 17 00:00:00 2001 From: seth-mg Date: Fri, 23 Jun 2023 12:44:10 -0500 Subject: [PATCH 045/106] Post to Teams instead of Slack --- Jenkinsfile.examples | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile.examples b/Jenkinsfile.examples index 652bea6..887147a 100644 --- a/Jenkinsfile.examples +++ b/Jenkinsfile.examples @@ -21,17 +21,18 @@ node { sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source ${TEST_CONTAINER}" } } - slack(true) + postToTeams(true) } catch (e) { currentBuild.result = "FAILED" - slack(false) + postToTeams(false) throw e } } -def slack(boolean success) { +def postToTeams(boolean success) { + def webhookUrl = "${env.TEAMS_PNC_JENKINS_WEBHOOK_URL}" def color = success ? "#00FF00" : "#FF0000" def status = success ? "SUCCESSFUL" : "FAILED" - def message = status + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})" - slackSend(color: color, channel: "#rapid", message: message) -} \ No newline at end of file + def message = "*" + status + ":* '${env.JOB_NAME}' - [${env.BUILD_NUMBER}] - ${env.BUILD_URL}" + office365ConnectorSend(webhookUrl: webhookUrl, color: color, message: message, status: status) +} From b87fa075b08dc750b96d3ab6b3a8eac43efa4691 Mon Sep 17 00:00:00 2001 From: Ervin Papp Date: Tue, 27 Jun 2023 12:00:36 +0200 Subject: [PATCH 046/106] RCB-601 new: events endpoint --- rosette/api.py | 11 ++++++++++- tests/test_rosette_api.py | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/rosette/api.py b/rosette/api.py index cfe5633..ead6e04 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -589,7 +589,8 @@ def __init__( 'TEXT_EMBEDDING': 'semantics/vector', 'TOKENS': 'tokens', 'TOPICS': 'topics', - 'TRANSLITERATION': 'transliteration' + 'TRANSLITERATION': 'transliteration', + 'EVENTS': 'events' } def __del__(self): @@ -1010,3 +1011,11 @@ def similar_terms(self, parameters): :return: A python dictionary containing the similar terms and their similarity """ return EndpointCaller(self, self.endpoints['SIMILAR_TERMS']).call(parameters) + + def events(self, parameters): + """ + Topics returns events related to the provided content + :param parameters: DocumentParameters + :return: A python dictionary containing the results + """ + return EndpointCaller(self, self.endpoints['EVENTS']).call(parameters) diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index 456a1af..1f9a169 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -882,3 +882,19 @@ def test_the_deprecated_endpoints(api, json_response, doc_params): httpretty.disable() httpretty.reset() + +# Test the events endpoint + + +def test_the_events_endpoint(api, json_response, doc_params): + """Test the events endpoint""" + httpretty.enable() + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + body=json_response, status=200, content_type="application/json") + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/events", + body=json_response, status=200, content_type="application/json") + + result = api.events(doc_params) + assert result["name"] == "Rosette" + httpretty.disable() + httpretty.reset() \ No newline at end of file From 8a510bbda347790d180937d953c7ae096b5c4fc0 Mon Sep 17 00:00:00 2001 From: Ervin Papp Date: Tue, 27 Jun 2023 12:13:48 +0200 Subject: [PATCH 047/106] RCB-601 new: events example --- examples/events.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 examples/events.py diff --git a/examples/events.py b/examples/events.py new file mode 100644 index 0000000..c900977 --- /dev/null +++ b/examples/events.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +""" +Example code to call Rosette API to get entities from a piece of text. +""" + +import argparse +import json +import os + +from rosette.api import API, DocumentParameters, RosetteException + + +def run(key, alt_url='https://api.rosette.com/rest/v1/'): + """ Run the example """ + # Create an API instance + api = API(user_key=key, service_url=alt_url) + + # Set selected API options. + # For more information on the functionality of these + # and other available options, see Rosette Features & Functions + # https://developer.rosette.com/features-and-functions#entity-extraction-and-linking + + # api.set_option('calculateSalience','true') + # api.set_option('linkEntities','false') + + events_text_data = "James wanted to test this awesome document." + params = DocumentParameters() + params["content"] = events_text_data + + try: + return api.events(params) + except RosetteException as exception: + print(exception) + +PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, + description='Calls the ' + + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') +PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-u', '--url', help="Alternative API URL", + default='https://api.rosette.com/rest/v1/') + +if __name__ == '__main__': + ARGS = PARSER.parse_args() + RESULT = run(ARGS.key, ARGS.url) + print(RESULT) From fbf0c657308d3b0f2fe33db1d2163bb844471e7d Mon Sep 17 00:00:00 2001 From: Ervin Papp Date: Wed, 26 Jul 2023 10:43:37 +0200 Subject: [PATCH 048/106] RCB-601 fixed: events API description --- rosette/api.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rosette/api.py b/rosette/api.py index ead6e04..41004e4 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -1014,8 +1014,10 @@ def similar_terms(self, parameters): def events(self, parameters): """ - Topics returns events related to the provided content - :param parameters: DocumentParameters - :return: A python dictionary containing the results + Create an L{EndpointCaller} to identify events found in the texts. + @param parameters: An object specifying the data, + and possible metadata, to be processed by the 'events' identifier. + @type parameters: L{DocumentParameters} or L{str} + @return: A python dictionary containing the results of event extraction. """ return EndpointCaller(self, self.endpoints['EVENTS']).call(parameters) From 4a35e54b3dcfabe392d6cce9c00a7a44e313e490 Mon Sep 17 00:00:00 2001 From: seth-mg Date: Mon, 21 Aug 2023 10:24:19 -0500 Subject: [PATCH 049/106] RCB-601: Test data update. --- examples/events.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/examples/events.py b/examples/events.py index c900977..7e5147a 100644 --- a/examples/events.py +++ b/examples/events.py @@ -15,15 +15,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): # Create an API instance api = API(user_key=key, service_url=alt_url) - # Set selected API options. - # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#entity-extraction-and-linking - - # api.set_option('calculateSalience','true') - # api.set_option('linkEntities','false') - - events_text_data = "James wanted to test this awesome document." + events_text_data = "I am looking for flights to Super Bowl 2022 in Inglewood, LA." params = DocumentParameters() params["content"] = events_text_data From d4f0770b82db0e768878c457c20bf6faab9292ff Mon Sep 17 00:00:00 2001 From: Jonathan Ju Date: Tue, 22 Aug 2023 16:25:07 -0400 Subject: [PATCH 050/106] TEJ-2055: added test file for event negation --- examples/events_negation.py | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 examples/events_negation.py diff --git a/examples/events_negation.py b/examples/events_negation.py new file mode 100644 index 0000000..880420f --- /dev/null +++ b/examples/events_negation.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +""" +Example code to call Rosette API to get events, based on a set negation option, from a piece of text. +""" + +import argparse +import json +import os + +from rosette.api import API, DocumentParameters, RosetteException + + +def run(key, alt_url='https://api.rosette.com/rest/v1/'): + """ Run the example """ + # Create an API instance + api = API(user_key=key, service_url=alt_url) + + # Double negative, meaning that the event should be skipped with "IGNORE" or "ONLY_NEGATIVE" + # and recognized under "BOTH" or "ONLY_POSITIVE" + events_text_data = "Sam didn't not take a flight to Boston." + params = DocumentParameters() + params["content"] = events_text_data + api.set_option('negation', 'ONLY_POSITIVE') + + + try: + return api.events(params) + except RosetteException as exception: + print(exception) + +PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, + description='Calls the ' + + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') +PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-u', '--url', help="Alternative API URL", + default='https://api.rosette.com/rest/v1/') + +if __name__ == '__main__': + ARGS = PARSER.parse_args() + RESULT = run(ARGS.key, ARGS.url) + print(RESULT) From 87557f6ea2724dca4d57fa826e5ff27b937b9799 Mon Sep 17 00:00:00 2001 From: machine-user-rosette Date: Tue, 10 Oct 2023 12:20:06 -0500 Subject: [PATCH 051/106] Update CI.Jenkinsfile Switch from Sonar hosted binaries to Github hosted. --- CI.Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 457d077..6c7d5f9 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -16,10 +16,10 @@ def runSonnarForPythonVersion(sourceDir, ver){ // Only run Sonar once. if(ver == 3.11) { sonarExec="cd /root/ && \ - wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip && \ - unzip -q sonar-scanner-cli-4.8.0.2856-linux.zip && \ + wget -q https://github.com/SonarSource/sonar-scanner-cli/archive/refs/tags/4.8.1.3023.zip && \ + unzip -q 4.8.1.3023.zip && \ cd /source && \ - /root/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner ${mySonarOpts}" + /root/sonar-scanner-4.8.1.3023/bin/sonar-scanner ${mySonarOpts}" } else { sonarExec="echo Skipping Sonar for this version." } @@ -57,4 +57,4 @@ node ("docker-light") { currentBuild.result = "FAILED" throw e } -} \ No newline at end of file +} From 7bb55cebbe0d37e2aaa09b739afc6ca6290a5dd6 Mon Sep 17 00:00:00 2001 From: machine-user-rosette Date: Tue, 10 Oct 2023 12:27:34 -0500 Subject: [PATCH 052/106] Update CI.Jenkinsfile Switch back to sonarsource binaries --- CI.Jenkinsfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 6c7d5f9..e4c7eb1 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -14,12 +14,13 @@ def runSonnarForPythonVersion(sourceDir, ver){ } // Only run Sonar once. + // Check for new versions at https://binaries.sonarsource.com/?prefix=Distribution/sonar-scanner-cli/ if(ver == 3.11) { sonarExec="cd /root/ && \ - wget -q https://github.com/SonarSource/sonar-scanner-cli/archive/refs/tags/4.8.1.3023.zip && \ - unzip -q 4.8.1.3023.zip && \ + wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.1.3023-linux.zip && \ + unzip -q sonar-scanner-cli-4.8.1.3023-linux.zip && \ cd /source && \ - /root/sonar-scanner-4.8.1.3023/bin/sonar-scanner ${mySonarOpts}" + /root/sonar-scanner-cli-4.8.1.3023-linux/bin/sonar-scanner ${mySonarOpts}" } else { sonarExec="echo Skipping Sonar for this version." } From c05749270b3cd59495ef80b3b49c8e7ae585cd92 Mon Sep 17 00:00:00 2001 From: machine-user-rosette Date: Tue, 10 Oct 2023 12:37:09 -0500 Subject: [PATCH 053/106] Update CI.Jenkinsfile More sonar scanner tweaks --- CI.Jenkinsfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index e4c7eb1..9b10517 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -17,10 +17,11 @@ def runSonnarForPythonVersion(sourceDir, ver){ // Check for new versions at https://binaries.sonarsource.com/?prefix=Distribution/sonar-scanner-cli/ if(ver == 3.11) { sonarExec="cd /root/ && \ - wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.1.3023-linux.zip && \ - unzip -q sonar-scanner-cli-4.8.1.3023-linux.zip && \ + sonar_version=4.8.1.3023 && \ + wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${sonar_version}-linux.zip && \ + unzip -q sonar-scanner-cli-${sonar_version}-linux.zip && \ cd /source && \ - /root/sonar-scanner-cli-4.8.1.3023-linux/bin/sonar-scanner ${mySonarOpts}" + /root/sonar-scanner-${sonar_version}-linux/bin/sonar-scanner ${mySonarOpts}" } else { sonarExec="echo Skipping Sonar for this version." } From c06b6ec3ef4c86210e25ef6886d5735343b93297 Mon Sep 17 00:00:00 2001 From: machine-user-rosette Date: Tue, 10 Oct 2023 12:45:03 -0500 Subject: [PATCH 054/106] Update CI.Jenkinsfile --- CI.Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 9b10517..04a50d6 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -18,10 +18,10 @@ def runSonnarForPythonVersion(sourceDir, ver){ if(ver == 3.11) { sonarExec="cd /root/ && \ sonar_version=4.8.1.3023 && \ - wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${sonar_version}-linux.zip && \ - unzip -q sonar-scanner-cli-${sonar_version}-linux.zip && \ + wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${sonar_version}-linux.zip && \ + unzip -q sonar-scanner-cli-\${sonar_version}-linux.zip && \ cd /source && \ - /root/sonar-scanner-${sonar_version}-linux/bin/sonar-scanner ${mySonarOpts}" + /root/sonar-scanner-\${sonar_version}-linux/bin/sonar-scanner ${mySonarOpts}" } else { sonarExec="echo Skipping Sonar for this version." } From 2580cf12dcd53b2dd6f6f184b0ac3630527009b6 Mon Sep 17 00:00:00 2001 From: machine-user-rosette Date: Tue, 10 Oct 2023 12:51:01 -0500 Subject: [PATCH 055/106] Update CI.Jenkinsfile --- CI.Jenkinsfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 04a50d6..25cf41a 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -17,11 +17,10 @@ def runSonnarForPythonVersion(sourceDir, ver){ // Check for new versions at https://binaries.sonarsource.com/?prefix=Distribution/sonar-scanner-cli/ if(ver == 3.11) { sonarExec="cd /root/ && \ - sonar_version=4.8.1.3023 && \ - wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${sonar_version}-linux.zip && \ - unzip -q sonar-scanner-cli-\${sonar_version}-linux.zip && \ + wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.1.3023-linux.zip && \ + unzip -q sonar-scanner-cli-4.8.1.3023-linux.zip && \ cd /source && \ - /root/sonar-scanner-\${sonar_version}-linux/bin/sonar-scanner ${mySonarOpts}" + /root/sonar-scanner-4.8.1.3023-linux/bin/sonar-scanner ${mySonarOpts}" } else { sonarExec="echo Skipping Sonar for this version." } From b774ec5e5b89857d0693932137d3d48c08571bce Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 4 Dec 2023 14:56:51 +0100 Subject: [PATCH 056/106] WS_3053: replace rosette.com --- examples/categories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/categories.py b/examples/categories.py index 88fbb37..4f8a7d7 100644 --- a/examples/categories.py +++ b/examples/categories.py @@ -14,7 +14,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): """ Run the example """ - categories_url_data = "https://rosette.com/about" + categories_url_data = "https://www.babelstreet.com/rosette/" url = categories_url_data # Create an API instance api = API(user_key=key, service_url=alt_url) From 29603863cd3b4c8d99bacbd4f721dcd6f75793dd Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Tue, 5 Dec 2023 09:05:00 +0100 Subject: [PATCH 057/106] WS_3053: update readme and change categories example to text --- README.md | 3 +-- examples/categories.py | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bf603fa..fc7daf3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - + --- @@ -13,7 +13,6 @@ comparing the similarity of names, categorizing and adding linguistic tags to te ## Rosette API Access - Rosette Cloud [Sign Up](https://developer.rosette.com/signup) -- Rosette Enterprise [Evaluation](https://www.rosette.com/product-eval/) ## Quick Start diff --git a/examples/categories.py b/examples/categories.py index 4f8a7d7..e4041aa 100644 --- a/examples/categories.py +++ b/examples/categories.py @@ -12,10 +12,9 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='http://localhost:8181/rest/v1/'): """ Run the example """ - categories_url_data = "https://www.babelstreet.com/rosette/" - url = categories_url_data + categories_text_data = "If you are a fan of the British television series Downton Abbey and you are planning to be in New York anytime before April 2nd, there is a perfect stop for you while in town." # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -29,8 +28,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): params = DocumentParameters() - # Use a URL to input data instead of a string - params["contentUri"] = url + params["content"] = categories_text_data try: return api.categories(params) except RosetteException as exception: From 97bf901906e13402292972f5a9ee1163e31a2597 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Tue, 5 Dec 2023 11:33:50 +0100 Subject: [PATCH 058/106] WS_3053: revert url --- examples/categories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/categories.py b/examples/categories.py index e4041aa..1c3e122 100644 --- a/examples/categories.py +++ b/examples/categories.py @@ -12,7 +12,7 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='http://localhost:8181/rest/v1/'): +def run(key, alt_url='https://api.rosette.com/rest/v1/'): """ Run the example """ categories_text_data = "If you are a fan of the British television series Downton Abbey and you are planning to be in New York anytime before April 2nd, there is a perfect stop for you while in town." # Create an API instance From e589766abafed7029d88a463581ef0f542f86063 Mon Sep 17 00:00:00 2001 From: Katsuya Tomioka Date: Tue, 12 Dec 2023 15:33:53 +0000 Subject: [PATCH 059/106] RCB-622: add type check for non-doc requests; add tests --- rosette/api.py | 64 ++++++++++++++++---------------- tests/test_rosette_api.py | 77 +++++++++++++++++++++++++++++++++++---- 2 files changed, 102 insertions(+), 39 deletions(-) diff --git a/rosette/api.py b/rosette/api.py index 41004e4..747f257 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -86,7 +86,7 @@ def __str__(self): return sst + ": " + self.message + ":\n " + self.response_message -class _DocumentParamSetBase(object): +class _RequestParametersBase(object): def __init__(self, repertoire): self.__params = {} @@ -135,7 +135,7 @@ def _byteify(value): # py 3 only return byte_array -class DocumentParameters(_DocumentParamSetBase): +class DocumentParameters(_RequestParametersBase): """Parameter object for all operations requiring input other than translated_name. Two fields, C{content} and C{inputUri}, are set via @@ -152,7 +152,7 @@ class DocumentParameters(_DocumentParamSetBase): def __init__(self): """Create a L{DocumentParameters} object.""" - _DocumentParamSetBase.__init__( + _RequestParametersBase.__init__( self, ("content", "contentUri", "language", "profileId")) self.file_name = "" self.use_multipart = False @@ -199,7 +199,7 @@ def load_document_string(self, content_as_string): self["content"] = content_as_string -class NameTranslationParameters(_DocumentParamSetBase): +class NameTranslationParameters(_RequestParametersBase): """Parameter object for C{name-translation} endpoint. The following values may be set by the indexing (i.e.,C{ parms["name"]}) operator. The values are all strings (when not C{None}). @@ -227,7 +227,7 @@ class NameTranslationParameters(_DocumentParamSetBase): def __init__(self): self.use_multipart = False - _DocumentParamSetBase.__init__( + _RequestParametersBase.__init__( self, ("name", "targetLanguage", @@ -248,7 +248,7 @@ def validate(self): repr(option)) -class AddressSimilarityParameters(_DocumentParamSetBase): +class AddressSimilarityParameters(_RequestParametersBase): """Parameter object for C{address-similarity} endpoint. C{address1} and C{address2} are required. @@ -271,7 +271,7 @@ class AddressSimilarityParameters(_DocumentParamSetBase): def __init__(self): self.use_multipart = False - _DocumentParamSetBase.__init__(self, ("address1", "address2", "parameters")) + _RequestParametersBase.__init__(self, ("address1", "address2", "parameters")) def validate(self): """Internal. Do not use.""" @@ -283,7 +283,7 @@ def validate(self): repr(option)) -class NameSimilarityParameters(_DocumentParamSetBase): +class NameSimilarityParameters(_RequestParametersBase): """Parameter object for C{name-similarity} endpoint. C{name1} and C{name2} are required. @@ -313,7 +313,7 @@ class NameSimilarityParameters(_DocumentParamSetBase): def __init__(self): self.use_multipart = False - _DocumentParamSetBase.__init__(self, ("name1", "name2", "parameters")) + _RequestParametersBase.__init__(self, ("name1", "name2", "parameters")) def validate(self): """Internal. Do not use.""" @@ -325,7 +325,7 @@ def validate(self): repr(option)) -class NameDeduplicationParameters(_DocumentParamSetBase): +class NameDeduplicationParameters(_RequestParametersBase): """Parameter object for C{name-deduplication} endpoint. Required: C{names} A list of C{name} objects @@ -334,7 +334,7 @@ class NameDeduplicationParameters(_DocumentParamSetBase): def __init__(self): self.use_multipart = False - _DocumentParamSetBase.__init__(self, ("names", "threshold")) + _RequestParametersBase.__init__(self, ("names", "threshold")) def validate(self): """Internal. Do not use.""" @@ -438,7 +438,7 @@ def ping(self): response = self.api.get_http(url, headers=headers) return self.__finish_result(response, "ping") - def call(self, parameters): + def call(self, parameters, paramtype=None): """Invokes the endpoint to which this L{EndpointCaller} is bound. Passes data and metadata specified by C{parameters} to the server endpoint to which this L{EndpointCaller} object is bound. For all @@ -455,24 +455,26 @@ def call(self, parameters): @param parameters: An object specifying the data, and possible metadata, to be processed by the endpoint. See the details for those object types. - @type parameters: For C{name-translation}, L{NameTranslationParameters}, - otherwise L{DocumentParameters} or L{str} + @type parameters: Parameters types or L{str} for document request. + @param paramtype: Required parameters type. @return: A python dictionary expressing the result of the invocation. """ + if paramtype and not isinstance(parameters, paramtype): + raise RosetteException( + "incompatible", + "The parameters must be " + str(paramtype), + self) - if not isinstance(parameters, _DocumentParamSetBase): - if self.suburl != self.api.endpoints['NAME_SIMILARITY'] \ - and self.suburl != self.api.self.api.endpoints['NAME_TRANSLATION'] \ - and self.suburl != self.api.self.api.endpoints['NAME_DEDUPLICATION'] \ - and self.suburl != self.api.self.api.endpoints['ADDRESS_SIMILARITY']: - text = parameters - parameters = DocumentParameters() - parameters['content'] = text - else: - raise RosetteException( - "incompatible", - "Text-only input only works for DocumentParameter endpoints", - self.suburl) + if type(parameters) == str: + text = parameters + parameters = DocumentParameters() + parameters['content'] = text + + if not isinstance(parameters, _RequestParametersBase): + raise RosetteException( + "incompatible", + "The parameters must be string or DocumentParameters", + self.suburl) self.use_multipart = parameters.use_multipart url = self.service_url + self.suburl @@ -915,7 +917,7 @@ def address_similarity(self, parameters): and possible metadata, to be processed by the name matcher. @type parameters: L{AddressSimilarityParameters} @return: A python dictionary containing the results of name matching.""" - return EndpointCaller(self, self.endpoints['ADDRESS_SIMILARITY']).call(parameters) + return EndpointCaller(self, self.endpoints['ADDRESS_SIMILARITY']).call(parameters, AddressSimilarityParameters) def name_translation(self, parameters): """ @@ -925,7 +927,7 @@ def name_translation(self, parameters): and possible metadata, to be processed by the name translator. @type parameters: L{NameTranslationParameters} @return: A python dictionary containing the results of name translation.""" - return EndpointCaller(self, self.endpoints['NAME_TRANSLATION']).call(parameters) + return EndpointCaller(self, self.endpoints['NAME_TRANSLATION']).call(parameters, NameTranslationParameters) def translated_name(self, parameters): """ deprecated @@ -944,7 +946,7 @@ def name_similarity(self, parameters): and possible metadata, to be processed by the name matcher. @type parameters: L{NameSimilarityParameters} @return: A python dictionary containing the results of name matching.""" - return EndpointCaller(self, self.endpoints['NAME_SIMILARITY']).call(parameters) + return EndpointCaller(self, self.endpoints['NAME_SIMILARITY']).call(parameters, NameSimilarityParameters) def matched_name(self, parameters): """ deprecated @@ -962,7 +964,7 @@ def name_deduplication(self, parameters): as a threshold @type parameters: L{NameDeduplicationParameters} @return: A python dictionary containing the results of de-duplication""" - return EndpointCaller(self, self.endpoints['NAME_DEDUPLICATION']).call(parameters) + return EndpointCaller(self, self.endpoints['NAME_DEDUPLICATION']).call(parameters, NameDeduplicationParameters) def text_embedding(self, parameters): """ deprecated diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index 1f9a169..7d316f6 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -65,6 +65,12 @@ def doc_params(): params['content'] = 'Sample test string' return params +@pytest.fixture +def doc_map(): + """ fixture for a simple map of doc request """ + return {'content': 'Simple test string'} + + # Of Note: httpretty provides a short hand decorator, @httpretty.activate, that wraps the decorated # function with httpretty.enable() and ends it with httpretty.disable(). However, when combined # with pytest fixtures, the passed in fixture arguments are ignored, resulting in a TypeError. @@ -211,32 +217,40 @@ def test_the_max_pool_size(json_response, doc_params): # Test the language endpoint -def test_the_language_endpoint(api, json_response, doc_params): +def test_the_language_endpoint(api, json_response, doc_params, doc_map): """Test language endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/language", body=json_response, status=200, content_type="application/json") result = api.language(doc_params) assert result["name"] == "Rosette" + + with pytest.raises(RosetteException) as e_rosette: + result = api.language(doc_map) + assert e_rosette.value.status == 'incompatible' + httpretty.disable() httpretty.reset() # Test the sentences endpoint -def test_the_sentences_endpoint(api, json_response, doc_params): +def test_the_sentences_endpoint(api, json_response, doc_params, doc_map): """Test the sentences endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/sentences", body=json_response, status=200, content_type="application/json") result = api.sentences(doc_params) assert result["name"] == "Rosette" + + with pytest.raises(RosetteException) as e_rosette: + result = api.sentences(doc_map) + + assert e_rosette.value.status == 'incompatible' + + httpretty.disable() httpretty.reset() @@ -246,8 +260,6 @@ def test_the_sentences_endpoint(api, json_response, doc_params): def test_the_tokens_endpoint(api, json_response, doc_params): """Test the tokens endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/tokens", body=json_response, status=200, content_type="application/json") @@ -426,6 +438,55 @@ def test_the_name_translation_endpoint(api, json_response): # Test the name similarity endpoint +def test_the_name_requests_with_text(api, json_response): + """Test the name similarity with text""" + httpretty.enable() + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + body=json_response, status=200, content_type="application/json") + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", + body=json_response, status=200, content_type="application/json") + with pytest.raises(RosetteException) as e_rosette: + result = api.name_similarity("should fail") + assert e_rosette.value.status == 'incompatible' + + with pytest.raises(RosetteException) as e_rosette: + result = api.name_translation("should fail") + assert e_rosette.value.status == 'incompatible' + + with pytest.raises(RosetteException) as e_rosette: + result = api.name_deduplication("should fail") + assert e_rosette.value.status == 'incompatible' + + with pytest.raises(RosetteException) as e_rosette: + result = api.address_similarity("should fail") + assert e_rosette.value.status == 'incompatible' + + httpretty.disable() + httpretty.reset() + + + +def test_the_name_similarity_single_parameters(api, json_response): + """Test the name similarity parameters""" + httpretty.enable() + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + body=json_response, status=200, content_type="application/json") + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", + body=json_response, status=200, content_type="application/json") + + matched_name_data1 = "John Mike Smith" + matched_name_data2 = "John Joe Smith" + params = NameSimilarityParameters() + params["name1"] = {"text": matched_name_data1} + params["name2"] = {"text": matched_name_data2} + params["parameters"] = {"conflictScore": "0.9"} + + result = api.name_similarity(params) + assert result["name"] == "Rosette" + httpretty.disable() + httpretty.reset() + + def test_the_name_similarity_single_parameters(api, json_response): """Test the name similarity parameters""" From 2df306d2c06057aa9ab1548bbe91010d549e4cdb Mon Sep 17 00:00:00 2001 From: Katsuya Tomioka Date: Wed, 13 Dec 2023 16:35:12 +0000 Subject: [PATCH 060/106] RCB-622: fix typecheck and tests --- rosette/api.py | 4 ++-- tests/test_rosette_api.py | 46 +++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/rosette/api.py b/rosette/api.py index 747f257..03fd991 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -463,14 +463,14 @@ def call(self, parameters, paramtype=None): raise RosetteException( "incompatible", "The parameters must be " + str(paramtype), - self) + self.suburl) if type(parameters) == str: text = parameters parameters = DocumentParameters() parameters['content'] = text - if not isinstance(parameters, _RequestParametersBase): + if not paramtype and not isinstance(parameters, DocumentParameters): raise RosetteException( "incompatible", "The parameters must be string or DocumentParameters", diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index 7d316f6..c05ea05 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -415,6 +415,29 @@ def test_the_multipart_operation(api, json_response, doc_params, tmpdir): httpretty.disable() httpretty.reset() + +def test_incompatible_type(api, json_response): + """Test the name translation endpoint""" + httpretty.enable() + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + body=json_response, status=200, content_type="application/json") + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/sentences", + body=json_response, status=200, content_type="application/json") + + params = NameTranslationParameters() + params["name"] = "some data to translate" + params["entityType"] = "PERSON" + params["targetLanguage"] = "eng" + params["targetScript"] = "Latn" + + # oops, called sentences + with pytest.raises(RosetteException) as e_rosette: + api.sentences(params) + + httpretty.disable() + httpretty.reset() + + # Test the name translation endpoint @@ -465,29 +488,6 @@ def test_the_name_requests_with_text(api, json_response): httpretty.reset() - -def test_the_name_similarity_single_parameters(api, json_response): - """Test the name similarity parameters""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", - body=json_response, status=200, content_type="application/json") - - matched_name_data1 = "John Mike Smith" - matched_name_data2 = "John Joe Smith" - params = NameSimilarityParameters() - params["name1"] = {"text": matched_name_data1} - params["name2"] = {"text": matched_name_data2} - params["parameters"] = {"conflictScore": "0.9"} - - result = api.name_similarity(params) - assert result["name"] == "Rosette" - httpretty.disable() - httpretty.reset() - - - def test_the_name_similarity_single_parameters(api, json_response): """Test the name similarity parameters""" httpretty.enable() From 9643b8accf3d0669c0dd8834b20afbd98139fddf Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Thu, 11 Jan 2024 11:51:51 -0600 Subject: [PATCH 061/106] DEVOPS-306: Add 3.12 and 3.13. Remove 3.7. --- CI.Jenkinsfile | 4 ++-- setup.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 25cf41a..fc44d1c 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -1,6 +1,6 @@ -def versions = [3.7, 3.8, 3.9, 3.10, 3.11] +def versions = [3.8, 3.9, 3.10, 3.11, 3.12, 3.13] def runSonnarForPythonVersion(sourceDir, ver){ mySonarOpts="-Dsonar.sources=/source -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}" @@ -15,7 +15,7 @@ def runSonnarForPythonVersion(sourceDir, ver){ // Only run Sonar once. // Check for new versions at https://binaries.sonarsource.com/?prefix=Distribution/sonar-scanner-cli/ - if(ver == 3.11) { + if(ver == 3.13) { sonarExec="cd /root/ && \ wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.1.3023-linux.zip && \ unzip -q sonar-scanner-cli-4.8.1.3023-linux.zip && \ diff --git a/setup.py b/setup.py index b266ac2..fe2ad46 100755 --- a/setup.py +++ b/setup.py @@ -49,11 +49,12 @@ def read(*filenames, **kwargs): 'Natural Language :: English', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', 'Topic :: Software Development :: Libraries :: Python Modules' ] ) From 84b6cf101fd3f2650d7537d627a5a0a11e66842c Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Thu, 11 Jan 2024 12:06:35 -0600 Subject: [PATCH 062/106] DEVOPS-306: 3.13 is still in pre-release. --- CI.Jenkinsfile | 4 ++-- setup.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index fc44d1c..f6aaf1e 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -1,6 +1,6 @@ -def versions = [3.8, 3.9, 3.10, 3.11, 3.12, 3.13] +def versions = [3.8, 3.9, 3.10, 3.11, 3.12] def runSonnarForPythonVersion(sourceDir, ver){ mySonarOpts="-Dsonar.sources=/source -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}" @@ -15,7 +15,7 @@ def runSonnarForPythonVersion(sourceDir, ver){ // Only run Sonar once. // Check for new versions at https://binaries.sonarsource.com/?prefix=Distribution/sonar-scanner-cli/ - if(ver == 3.13) { + if(ver == 3.12) { sonarExec="cd /root/ && \ wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.1.3023-linux.zip && \ unzip -q sonar-scanner-cli-4.8.1.3023-linux.zip && \ diff --git a/setup.py b/setup.py index fe2ad46..551de4f 100755 --- a/setup.py +++ b/setup.py @@ -54,7 +54,6 @@ def read(*filenames, **kwargs): 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', - 'Programming Language :: Python :: 3.13', 'Topic :: Software Development :: Libraries :: Python Modules' ] ) From 3ce3a6e731a292c674b9b324c82e76923b78965a Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Thu, 11 Jan 2024 18:21:18 +0000 Subject: [PATCH 063/106] Version 1.28.0 --- docs/source/conf.py | 4 ++-- rosette/__init__.py | 2 +- rosette/api.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 06117be..c95582f 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -55,9 +55,9 @@ # built documents. # # The short X.Y version. -version = '1.25.1' +version = '1.28.0' # The full version, including alpha/beta/rc tags. -release = '1.25.1' +release = '1.28.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/rosette/__init__.py b/rosette/__init__.py index c583524..72eac6f 100644 --- a/rosette/__init__.py +++ b/rosette/__init__.py @@ -12,4 +12,4 @@ limitations under the License. """ -__version__ = '1.25.1' +__version__ = '1.28.0' diff --git a/rosette/api.py b/rosette/api.py index 03fd991..f3fec57 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -30,7 +30,7 @@ _APPLICATION_JSON = 'application/json' _BINDING_LANGUAGE = 'python' -_BINDING_VERSION = '1.25.1' +_BINDING_VERSION = '1.28.0' _CONCURRENCY_HEADER = 'x-rosetteapi-concurrency' _CUSTOM_HEADER_PREFIX = 'X-RosetteAPI-' _CUSTOM_HEADER_PATTERN = re.compile('^' + _CUSTOM_HEADER_PREFIX) From bbfa6bac9ed5cf9cced91f78f0df376987ae7ac8 Mon Sep 17 00:00:00 2001 From: seth-mg Date: Tue, 16 Jan 2024 15:49:41 -0600 Subject: [PATCH 064/106] Update CI.Jenkinsfile Re-permission files for Jenkins cleanup. Not comprehensive but good enough for now. --- CI.Jenkinsfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index f6aaf1e..28697c2 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -34,7 +34,10 @@ def runSonnarForPythonVersion(sourceDir, ver){ pip3 install tox && \ cd /source && \ tox && \ - ${sonarExec}\"" + ${sonarExec} && \ + echo && \ + echo [INFO] Re-permission files for cleanup. && \ + chown -R jenkins:jenkins /source\"" } node ("docker-light") { From 5bccc8c63dd0458e56e6ac1461fb83690ef5257e Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Fri, 5 Apr 2024 17:12:37 +0200 Subject: [PATCH 065/106] WS-3151: fix description --- examples/events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/events.py b/examples/events.py index 7e5147a..828dd45 100644 --- a/examples/events.py +++ b/examples/events.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get entities from a piece of text. +Example code to call Rosette API to get events from a piece of text. """ import argparse From 0c93c5b2c7c3f4c0decdc0e1a6d17468538d086c Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Fri, 5 Apr 2024 17:14:02 +0200 Subject: [PATCH 066/106] WS-3151: add coref option example --- examples/entities.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/entities.py b/examples/entities.py index e6e2a50..30a2ea5 100644 --- a/examples/entities.py +++ b/examples/entities.py @@ -22,6 +22,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): # api.set_option('calculateSalience','true') # api.set_option('linkEntities','false') + # api.set_option('useIndocServer', True) 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." params = DocumentParameters() From c9c01338f3f233b45acb093e6274d429b1c8b1ef Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Fri, 5 Apr 2024 17:15:26 +0200 Subject: [PATCH 067/106] WS-3151: add record similarity top level object and example --- examples/record_similarity.py | 112 ++++++++++++++++++++++++++++++++++ rosette/api.py | 33 +++++++++- 2 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 examples/record_similarity.py diff --git a/examples/record_similarity.py b/examples/record_similarity.py new file mode 100644 index 0000000..454aacd --- /dev/null +++ b/examples/record_similarity.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +""" +Example code to call Rosette API to get similarity score between a list of records +""" + +import argparse +import json +import os + +from rosette.api import API, RecordSimilarityParameters, RosetteException + + +def run(key, alt_url='https://api.rosette.com/rest/v1/'): + """ Run the example """ + # Create an API instance + api = API(user_key=key, service_url=alt_url) + + fields = { + "primaryName": { + "type": "rni_name", + "weight": 0.5 + }, + "dob": { + "type": "rni_date", + "weight": 0.2 + }, + "addr": { + "type": "rni_address", + "weight": 0.5 + }, + "dob2": { + "type": "rni_date", + "weight": 0.1 + } + } + properties = { + "threshold": 0.1, + "includeExplainInfo": False + } + records = { + "left": [ + { + "primaryName": { + "text": "Ethan R", + "entityType": "PERSON", + "language": "eng", + "languageOfOrigin": "eng", + "script": "Latn" + }, + "dob": "1993-04-16", + "addr": "123 Roadlane Ave", + "dob2": { + "date": "1993/04/16" + } + }, + { + "dob": { + "date": "1993-04-16" + }, + "primaryName": { + "text": "Evan R" + } + } + ], + "right": [ + { + "dob": { + "date": "1993-04-16" + }, + "primaryName": { + "text": "Seth R", + "language": "eng" + } + }, + { + "primaryName": "Ivan R", + "dob": { + "date": "1993-04-16" + }, + "addr": { + "address": "123 Roadlane Ave" + }, + "dob2": { + "date": "1993/04/16" + } + } + ] + } + params = RecordSimilarityParameters() + params["fields"] = fields + params["properties"] = properties + params["records"] = records + + #params["parameters"] = {"conflictScore": "0.9", "deletionScore": "0.2"} + + try: + return api.record_similarity(params) + except RosetteException as exception: + print(exception) + + +PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, + description='Calls the ' + + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') +PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-u', '--url', help="Alternative API URL", + default='https://api.rosette.com/rest/v1/') + +if __name__ == '__main__': + # ARGS = PARSER.parse_args() + RESULT = run("key", "http://localhost:8181/rest/v1/") + print(RESULT) diff --git a/rosette/api.py b/rosette/api.py index f3fec57..cb98445 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -344,6 +344,27 @@ def validate(self): "Required Name De-Duplication parameter is missing: names", repr("names")) +class RecordSimilarityParameters(_RequestParametersBase): + """Parameter object for C{record-similarity} endpoint. + Required: + C{records} A list of C{record} objects + C{properties} A C{property} object + C{fields} A dictionary of C{field} objects + """ + + def __init__(self): + self.use_multipart = False + _RequestParametersBase.__init__(self, ("fields", "properties", "records")) + + def validate(self): + """Internal. Do not use.""" + for option in "fields", "properties", "records": # required + if self[option] is None: + raise RosetteException( + "missingParameter", + "Required Name Similarity parameter is missing: " + option, + repr(option)) + class EndpointCaller(object): """L{EndpointCaller} objects are invoked via their instance methods to obtain results @@ -592,7 +613,8 @@ def __init__( 'TOKENS': 'tokens', 'TOPICS': 'topics', 'TRANSLITERATION': 'transliteration', - 'EVENTS': 'events' + 'EVENTS': 'events', + 'RECORD_SIMILARITY': 'record-similarity' } def __del__(self): @@ -966,6 +988,15 @@ def name_deduplication(self, parameters): @return: A python dictionary containing the results of de-duplication""" return EndpointCaller(self, self.endpoints['NAME_DEDUPLICATION']).call(parameters, NameDeduplicationParameters) + def record_similarity(self, parameters): + """ + Create an L{EndpointCaller} to get similarity core between a list of records and call it. + @param parameters: An object specifying the data, + and possible metadata, to be processed by the record matcher. + @type parameters: L{RecordSimilarityParameters} + @return: A python dictionary containing the results of record matching.""" + return EndpointCaller(self, self.endpoints['RECORD_SIMILARITY']).call(parameters, RecordSimilarityParameters) + def text_embedding(self, parameters): """ deprecated Create an L{EndpointCaller} to identify text vectors found in the texts From b1f50fb9f7c14609900b71e02e4346e3b7f4a034 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 8 Apr 2024 11:55:50 +0200 Subject: [PATCH 068/106] WS-3151: unit tests --- examples/record_similarity.py | 4 +-- rosette/api.py | 3 +- tests/test_rosette_api.py | 62 +++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/examples/record_similarity.py b/examples/record_similarity.py index 454aacd..42d59ea 100644 --- a/examples/record_similarity.py +++ b/examples/record_similarity.py @@ -34,8 +34,8 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): } } properties = { - "threshold": 0.1, - "includeExplainInfo": False + "threshold": 0.7, + "includeExplainInfo": True } records = { "left": [ diff --git a/rosette/api.py b/rosette/api.py index cb98445..32e8c99 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -344,6 +344,7 @@ def validate(self): "Required Name De-Duplication parameter is missing: names", repr("names")) + class RecordSimilarityParameters(_RequestParametersBase): """Parameter object for C{record-similarity} endpoint. Required: @@ -362,7 +363,7 @@ def validate(self): if self[option] is None: raise RosetteException( "missingParameter", - "Required Name Similarity parameter is missing: " + option, + "Required Record Similarity parameter is missing: " + option, repr(option)) diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index c05ea05..9b75d20 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -29,6 +29,7 @@ NameTranslationParameters, NameSimilarityParameters, NameDeduplicationParameters, + RecordSimilarityParameters, RosetteException) _ISPY3 = sys.version_info[0] == 3 @@ -484,6 +485,10 @@ def test_the_name_requests_with_text(api, json_response): result = api.address_similarity("should fail") assert e_rosette.value.status == 'incompatible' + with pytest.raises(RosetteException) as e_rosette: + result = api.record_similarity("should fail") + assert e_rosette.value.status == 'incompatible' + httpretty.disable() httpretty.reset() @@ -958,4 +963,61 @@ def test_the_events_endpoint(api, json_response, doc_params): result = api.events(doc_params) assert result["name"] == "Rosette" httpretty.disable() + httpretty.reset() + +# Test the record similarity endpoint + + +def test_the_record_similarity_endpoint(api, json_response): + """Test the record similarity endpoint""" + httpretty.enable() + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/record-similarity", + body=json_response, status=200, content_type="application/json") + + params = RecordSimilarityParameters() + params["fields"] = {} + params["properties"] = {} + params["records"] = [] + result = api.record_similarity(params) + assert result["name"] == "Rosette" + httpretty.disable() + httpretty.reset() + + +# Tests for required record-similarities parameters +def test_for_record_similarity_required_parameters(api, json_response): + """Test record similarity parameters""" + httpretty.enable() + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/record-similarity", + body=json_response, status=200, content_type="application/json") + + params = RecordSimilarityParameters() + + with pytest.raises(RosetteException) as e_rosette: + api.record_similarity(params) + + assert e_rosette.value.status == 'missingParameter' + assert e_rosette.value.message == 'Required Record Similarity parameter is missing: fields' + + params["fields"] = {} + + with pytest.raises(RosetteException) as e_rosette: + api.record_similarity(params) + + assert e_rosette.value.status == 'missingParameter' + assert e_rosette.value.message == 'Required Record Similarity parameter is missing: properties' + + params["properties"] = {} + + with pytest.raises(RosetteException) as e_rosette: + api.record_similarity(params) + + assert e_rosette.value.status == 'missingParameter' + assert e_rosette.value.message == 'Required Record Similarity parameter is missing: records' + + params["records"] = [] + + result = api.record_similarity(params) + assert result["name"] == "Rosette" + httpretty.disable() httpretty.reset() \ No newline at end of file From f7c6b75aa4b8729431fadb567561b7908782aa82 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 8 Apr 2024 12:23:09 +0200 Subject: [PATCH 069/106] WS-3151: copyright years and version number --- docs/source/conf.py | 6 +++--- rosette/__init__.py | 2 +- rosette/api.py | 4 ++-- tests/test_rosette_api.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index c95582f..2ec8928 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -47,7 +47,7 @@ # General information about the project. project = '' -copyright = '2022, Basis Technology' +copyright = '2024, Basis Technology' author = 'Basis Technology' # The version info for the project you're documenting, acts as replacement for @@ -55,9 +55,9 @@ # built documents. # # The short X.Y version. -version = '1.28.0' +version = '1.29.0' # The full version, including alpha/beta/rc tags. -release = '1.28.0' +release = '1.29.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/rosette/__init__.py b/rosette/__init__.py index 72eac6f..8944820 100644 --- a/rosette/__init__.py +++ b/rosette/__init__.py @@ -12,4 +12,4 @@ limitations under the License. """ -__version__ = '1.28.0' +__version__ = '1.29.0' diff --git a/rosette/api.py b/rosette/api.py index 32e8c99..199e405 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -3,7 +3,7 @@ """ Python client for the Rosette API. -Copyright (c) 2014-2022 Basis Technology Corporation. +Copyright (c) 2014-2024 Basis Technology Corporation. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ _APPLICATION_JSON = 'application/json' _BINDING_LANGUAGE = 'python' -_BINDING_VERSION = '1.28.0' +_BINDING_VERSION = '1.29.0' _CONCURRENCY_HEADER = 'x-rosetteapi-concurrency' _CUSTOM_HEADER_PREFIX = 'X-RosetteAPI-' _CUSTOM_HEADER_PATTERN = re.compile('^' + _CUSTOM_HEADER_PREFIX) diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index 9b75d20..88e58a2 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ -Copyright (c) 2014-2022 Basis Technology Corporation. +Copyright (c) 2014-2024 Basis Technology Corporation. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From df50abcdde2388d1fd03fc130a641528f146031d Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 8 Apr 2024 14:48:27 +0200 Subject: [PATCH 070/106] WS-3151: change jenkins cleanup to uid guid --- CI.Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 28697c2..811c36a 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -37,7 +37,7 @@ def runSonnarForPythonVersion(sourceDir, ver){ ${sonarExec} && \ echo && \ echo [INFO] Re-permission files for cleanup. && \ - chown -R jenkins:jenkins /source\"" + chown -R 9960:9960 /source\"" } node ("docker-light") { From 35bb8bb4db5bf7920ff1dc7c71cba84db2666528 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Thu, 11 Apr 2024 17:09:43 +0200 Subject: [PATCH 071/106] WS-3151: fix description, fix example --- examples/record_similarity.py | 6 ++---- rosette/api.py | 7 ++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/record_similarity.py b/examples/record_similarity.py index 42d59ea..2ae4c1e 100644 --- a/examples/record_similarity.py +++ b/examples/record_similarity.py @@ -91,8 +91,6 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): params["properties"] = properties params["records"] = records - #params["parameters"] = {"conflictScore": "0.9", "deletionScore": "0.2"} - try: return api.record_similarity(params) except RosetteException as exception: @@ -107,6 +105,6 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): default='https://api.rosette.com/rest/v1/') if __name__ == '__main__': - # ARGS = PARSER.parse_args() - RESULT = run("key", "http://localhost:8181/rest/v1/") + ARGS = PARSER.parse_args() + RESULT = run(ARGS.key, ARGS.url) print(RESULT) diff --git a/rosette/api.py b/rosette/api.py index 199e405..39f3467 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -348,9 +348,10 @@ def validate(self): class RecordSimilarityParameters(_RequestParametersBase): """Parameter object for C{record-similarity} endpoint. Required: - C{records} A list of C{record} objects - C{properties} A C{property} object - C{fields} A dictionary of C{field} objects + C{records} The records to be compared; where each left record is compared to the associated right record. + C{properties} Parameters used in the call + C{fields} The definition of the fields used in the comparison. There must be a minimum of 1 field and + can have a maximum of 5 fields. """ def __init__(self): From e62c1c261843ad570d85021ee40488976425fded Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Wed, 17 Apr 2024 17:52:47 -0500 Subject: [PATCH 072/106] WS-3151: README/branding updates. Events example string. --- README.md | 18 ++++++------------ examples/events.py | 2 +- setup.py | 4 ++-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index fc7daf3..ceb1212 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,10 @@ - - ---- + +# Rosette by Babel Street [![PyPI version](https://badge.fury.io/py/rosette-api.svg)](https://badge.fury.io/py/rosette-api) [![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) -## Rosette API -The Rosette Text Analytics Platform uses natural language processing, statistical modeling, and machine learning to -analyze unstructured and semi-structured text across 364 language-encoding-script combinations, revealing valuable -information and actionable data. Rosette provides endpoints for extracting entities and relationships, translating and -comparing the similarity of names, categorizing and adding linguistic tags to text and more. +Rosette uses natural language processing, statistical modeling, and machine learning to analyze unstructured and semi-structured text across hundreds of language-script combinations, revealing valuable information and actionable data. Rosette provides endpoints for extracting entities and relationships, translating and comparing the similarity of names, categorizing and adding linguistic tags to text and more. Rosette Server is the on-premises installation of Rosette, with access to Rosette's functions as RESTful web service endpoints. This solves cloud security worries and allows customization (models/indexes) as needed for your business. ## Rosette API Access - Rosette Cloud [Sign Up](https://developer.rosette.com/signup) @@ -25,11 +20,10 @@ in the [examples](https://github.com/rosette-api/python/tree/develop/examples) d #### Documentation & Support - [Binding API](https://rosette-api.github.io/python/) -- [Rosette Platform API](https://developer.rosette.com/features-and-functions) +- [Rosette Platform API](https://docs.babelstreet.com/API/en/index-en.html) - [Binding Release Notes](https://github.com/rosette-api/python/wiki/Release-Notes) -- [Rosette Platform Release Notes](https://support.rosette.com/hc/en-us/articles/360018354971-Release-Notes) -- [Binding/Rosette Platform Compatibility](https://developer.rosette.com/features-and-functions?python#) -- [Support](https://support.rosette.com) +- [Rosette Platform Release Notes](https://babelstreet.my.site.com/support/s/article/Rosette-Cloud-Release-Notes) +- [Support](https://babelstreet.my.site.com/support/s/) - [Binding License: Apache 2.0](https://github.com/rosette-api/python/blob/develop/LICENSE.txt) ## Binding Developer Information diff --git a/examples/events.py b/examples/events.py index 828dd45..832f6e3 100644 --- a/examples/events.py +++ b/examples/events.py @@ -15,7 +15,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): # Create an API instance api = API(user_key=key, service_url=alt_url) - events_text_data = "I am looking for flights to Super Bowl 2022 in Inglewood, LA." + events_text_data = "Alice has a flight to Budapest. She has not booked a hotel." params = DocumentParameters() params["content"] = events_text_data diff --git a/setup.py b/setup.py index 551de4f..309ec07 100755 --- a/setup.py +++ b/setup.py @@ -7,8 +7,8 @@ NAME = "rosette_api" DESCRIPTION = "Rosette API Python client SDK" -AUTHOR = "Basis Technology Corp." -AUTHOR_EMAIL = "support@rosette.com" +AUTHOR = "Rosette by Babel Street" +AUTHOR_EMAIL = "helpdesk@babelstreet.com" HOMEPAGE = "https://github.com/rosette-api/python" VERSION = rosette.__version__ From a5121cb388d9e7f97439ed98754a5fba38128cb4 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Fri, 19 Apr 2024 11:24:51 -0500 Subject: [PATCH 073/106] WS-3151: Revert example payhload. There is a separate negation example. --- examples/events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/events.py b/examples/events.py index 832f6e3..828dd45 100644 --- a/examples/events.py +++ b/examples/events.py @@ -15,7 +15,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): # Create an API instance api = API(user_key=key, service_url=alt_url) - events_text_data = "Alice has a flight to Budapest. She has not booked a hotel." + events_text_data = "I am looking for flights to Super Bowl 2022 in Inglewood, LA." params = DocumentParameters() params["content"] = events_text_data From 37de35a3e4de8969c531fa950e2b39f9e9f13e3a Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Fri, 19 Apr 2024 11:25:14 -0500 Subject: [PATCH 074/106] WS-3151: Use a supported Python in the examples. --- examples/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/README.md b/examples/README.md index 5928376..e52b2cb 100644 --- a/examples/README.md +++ b/examples/README.md @@ -32,7 +32,7 @@ python ping.py -k $API_KEY ``` git clone git@github.com:rosette-api/python.git cd python/examples -docker run -it -v $(pwd):/source --entrypoint bash python:3.6-slim +docker run -it -v $(pwd):/source --entrypoint bash python:3.12-slim cd /source pip install rosette_api python ping.py -k $API_KEY @@ -42,7 +42,7 @@ python ping.py -k $API_KEY ``` git clone git@github.com:rosette-api/python.git cd python -docker run -it -v $(pwd):/source --entrypoint bash python:3.6-slim +docker run -it -v $(pwd):/source --entrypoint bash python:3.12-slim cd /source python setup.py install cd examples From b579e0a711f461b4ed1b646be30579b4b9d5f2b5 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Fri, 19 Apr 2024 11:43:31 -0500 Subject: [PATCH 075/106] WS-3151: change records param in unit test from array to dict. --- tests/test_rosette_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index 88e58a2..a0e2b3d 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -977,7 +977,7 @@ def test_the_record_similarity_endpoint(api, json_response): params = RecordSimilarityParameters() params["fields"] = {} params["properties"] = {} - params["records"] = [] + params["records"] = {} result = api.record_similarity(params) assert result["name"] == "Rosette" httpretty.disable() @@ -1015,9 +1015,9 @@ def test_for_record_similarity_required_parameters(api, json_response): assert e_rosette.value.status == 'missingParameter' assert e_rosette.value.message == 'Required Record Similarity parameter is missing: records' - params["records"] = [] + params["records"] = {} result = api.record_similarity(params) assert result["name"] == "Rosette" httpretty.disable() - httpretty.reset() \ No newline at end of file + httpretty.reset() From c04b05b1505b76f35a907fde351881107b26db93 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Fri, 28 Jun 2024 15:01:32 +0200 Subject: [PATCH 076/106] WS-3224: fix requests compatibility issue --- rosette/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rosette/api.py b/rosette/api.py index 39f3467..5bdb038 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -528,7 +528,7 @@ def call(self, parameters, paramtype=None): request = requests.Request( 'POST', url, files=files, headers=headers, params=payload) prepared_request = self.api.session.prepare_request(request) - settings = self.api.session.merge_environment_settings(prepared_request.url, {}, {}, None, {}) + settings = self.api.session.merge_environment_settings(prepared_request.url, {}, {}, None, None) response = self.api.session.send(prepared_request, **settings) rdata = response.content response_headers = {"responseHeaders": dict(response.headers)} @@ -671,7 +671,7 @@ def _make_request(self, operation, url, data, headers): operation, url, data=data, headers=headers, params=payload) prepared_request = self.session.prepare_request(request) # Take into account environment settings, e.g. HTTP_PROXY and HTTPS_PROXY - settings = self.session.merge_environment_settings(prepared_request.url, {}, {}, None, {}) + settings = self.session.merge_environment_settings(prepared_request.url, {}, {}, None, None) try: response = self.session.send(prepared_request, **settings) From bd0a9a19b94c495c7add249805acae260a0bd8ba Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 1 Jul 2024 10:42:46 +0200 Subject: [PATCH 077/106] WS-3224: synchronize validation with java binding --- rosette/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosette/api.py b/rosette/api.py index 5bdb038..fe45eb5 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -360,7 +360,7 @@ def __init__(self): def validate(self): """Internal. Do not use.""" - for option in "fields", "properties", "records": # required + for option in "records": # required if self[option] is None: raise RosetteException( "missingParameter", From 3a7b86aee28dea70823caa27e6a94c105734d831 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 1 Jul 2024 10:46:01 +0200 Subject: [PATCH 078/106] WS-3224: supdate example --- examples/record_similarity.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/record_similarity.py b/examples/record_similarity.py index 2ae4c1e..f39b548 100644 --- a/examples/record_similarity.py +++ b/examples/record_similarity.py @@ -50,7 +50,8 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): "dob": "1993-04-16", "addr": "123 Roadlane Ave", "dob2": { - "date": "1993/04/16" + "date": "04161993", + "format": "MMddyyyy" } }, { @@ -78,7 +79,8 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): "date": "1993-04-16" }, "addr": { - "address": "123 Roadlane Ave" + "houseNumber": "123", + "road": "Roadlane Ave" }, "dob2": { "date": "1993/04/16" From 31e9afb35d7073db2c8febc823aa5c924f5aa45b Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 1 Jul 2024 11:09:02 +0200 Subject: [PATCH 079/106] WS-3224: remove record-similarity validation tests --- tests/test_rosette_api.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index a0e2b3d..a635025 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -993,22 +993,6 @@ def test_for_record_similarity_required_parameters(api, json_response): params = RecordSimilarityParameters() - with pytest.raises(RosetteException) as e_rosette: - api.record_similarity(params) - - assert e_rosette.value.status == 'missingParameter' - assert e_rosette.value.message == 'Required Record Similarity parameter is missing: fields' - - params["fields"] = {} - - with pytest.raises(RosetteException) as e_rosette: - api.record_similarity(params) - - assert e_rosette.value.status == 'missingParameter' - assert e_rosette.value.message == 'Required Record Similarity parameter is missing: properties' - - params["properties"] = {} - with pytest.raises(RosetteException) as e_rosette: api.record_similarity(params) From 7b110e845835f6185bf9bcd641e2ec9f606e54e6 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 1 Jul 2024 11:18:47 +0200 Subject: [PATCH 080/106] WS-3224: fix record-similarity validation --- rosette/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosette/api.py b/rosette/api.py index fe45eb5..182c239 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -360,7 +360,7 @@ def __init__(self): def validate(self): """Internal. Do not use.""" - for option in "records": # required + for option in ["records"]: # required if self[option] is None: raise RosetteException( "missingParameter", From de457c7ce36f66fdb5fc841af9577d13e3794cf3 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Wed, 10 Jul 2024 09:35:52 +0000 Subject: [PATCH 081/106] Version 1.30.0 --- docs/source/conf.py | 4 ++-- rosette/__init__.py | 2 +- rosette/api.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 2ec8928..ec6a33a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -55,9 +55,9 @@ # built documents. # # The short X.Y version. -version = '1.29.0' +version = '1.30.0' # The full version, including alpha/beta/rc tags. -release = '1.29.0' +release = '1.30.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/rosette/__init__.py b/rosette/__init__.py index 8944820..200c03e 100644 --- a/rosette/__init__.py +++ b/rosette/__init__.py @@ -12,4 +12,4 @@ limitations under the License. """ -__version__ = '1.29.0' +__version__ = '1.30.0' diff --git a/rosette/api.py b/rosette/api.py index 182c239..6114554 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -30,7 +30,7 @@ _APPLICATION_JSON = 'application/json' _BINDING_LANGUAGE = 'python' -_BINDING_VERSION = '1.29.0' +_BINDING_VERSION = '1.30.0' _CONCURRENCY_HEADER = 'x-rosetteapi-concurrency' _CUSTOM_HEADER_PREFIX = 'X-RosetteAPI-' _CUSTOM_HEADER_PATTERN = re.compile('^' + _CUSTOM_HEADER_PREFIX) From 6a6ebdfe38e1963bdbd70cdb0d0433bf648f3a5c Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Thu, 24 Oct 2024 16:49:37 -0500 Subject: [PATCH 082/106] WS-3314: Switch to png files. Add a favicon. --- docs/source/conf.py | 3 ++- docs/source/favicon-16x16.png | Bin 0 -> 1423 bytes docs/source/logo-400x113.png | Bin 0 -> 13239 bytes docs/source/rosette-logo.svg | 35 ---------------------------------- 4 files changed, 2 insertions(+), 36 deletions(-) create mode 100644 docs/source/favicon-16x16.png create mode 100644 docs/source/logo-400x113.png delete mode 100644 docs/source/rosette-logo.svg diff --git a/docs/source/conf.py b/docs/source/conf.py index ec6a33a..39446dd 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -95,7 +95,8 @@ # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] -html_logo = 'rosette-logo.svg' +html_logo = 'logo-400x113.png' +html_favicon = 'favicon-16x16.png' # Custom sidebar templates, must be a dictionary that maps document names # to template names. diff --git a/docs/source/favicon-16x16.png b/docs/source/favicon-16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..2750b933b5f2a9c894496d3ca4f5c7ed9ee349dc GIT binary patch literal 1423 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6-E$sR$z z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBDAAG{;hE;^%b*2hb1<+n z3NbJPS&Tr)z$nE4G7ZRL@M4sPvx68lplX;H7}_%#SfFa6fHa7y10vuw^8!YMi3^zE zss$D>BiJB)3wv^I0V&P`kH}&M20djEW~^9hU&g?|bSg6>q9nrC$0|8LS1&OoKPgqO zBDVmfi@~PC3dqb&ElE_U$j!+swyLmI0;{kBvO&W7N(x{lCE2!05xxNm&iO^D3TAo+ zdIm~%TnY*bHbp6ERzWUqQ0+jTtx`rwNr9EVetCJhUb(Seeo?xG?WUP)qwZeFo6#1NP{E~&-IMVSR9nfZANAafIw@=Hr>m6Sjh!2!gbC7EdmoAQdG z-U511A0(r1sAr&$ON8HhHpzaZAxfDE&W3`#A|&nX2t%g)%qzy@puiYUT? z5FH2&p?R4lc1BPwXu{~aA`tRO_8^O*>+mniOa%rd*ky)LOOVBo)PwwI6_8nxniJuY znVXtd4DyYknT-m&{c!2iNs|Mk_1$vjXo&0kzyZ` zw7{akv}MO-qYqD~c3k#NJ0Alx$b3&1#}Es_*2#|AE`cJ)pBrwLP!$VK60>7ST%6+? zbjnFFs4U5G(^F;*ZfkFCv!H2ZVq#)#Q%!Do_!^l_7BV{a_4oeD?`8KF|9SoWT;=mS z)%SNkzbC##NitcgK>DCV!zwR9|I<}mAF`k9kL_{fI_8oi@+`^m{n2xrPZWAG)$eo9 zzrcLkfJya5Q~8DP{R>Xa3EIKY&%-!%7fX=fsRF^H{2$&wMxS4ulHr)-oTJs zaPEL6OHho)_ydvNrL!Q)s z$$EZ!ZY$O0Pnf(iCYq}~*;qc|Xt=BVf{*|84$PR+w^i~@T(syP@2npEwQ_PvqYy&weXoKCxk&aJInvRVwGrgTe~DWM4fRoBIh literal 0 HcmV?d00001 diff --git a/docs/source/logo-400x113.png b/docs/source/logo-400x113.png new file mode 100644 index 0000000000000000000000000000000000000000..b411943a005e194bd5694ea8bdb379c5b40efe44 GIT binary patch literal 13239 zcmdU$g+Mkx&Bwpb}nXXCVCR_F?kM=(T`yRg)G2 zRE`txz3zlr=*U_sDgx+VWgq|!3JU=9N9FYmfFcCI{gnX#IVht4%4$%w|LQ;k01z+$ z_Fo;n*Yc0Z_-FIq5+)Doe?8_w|3@1tArIz1GQjzdoeDsi`L#fFlF@Yq0GO%%e4xAv zg*{$f>4G(M+;kKb_{|*cnN7?cO)Z$c?4ABt0R+AHUqyQhHxqI%dpieLelHN^Uk(0O z`A;=xTA{&IX5#aGb^PK5;-}!po_UBznX;9zvi!dAWCaDHz$4; z7Ee!4W={@gM;9v=HaQJ0siV6ah?4S8p#Q%9X{Q_5@_!>axc=L%*ABA$`G$p!nU&?gzF$oR|J3p;yMQfT zBmeO)#3uMx^Z%;*H;y37pWy#TWB%#s-`dx%3Ly!y{5NevNCbu(2mk<^m8^uQh8NV4 zKXQ_RX8N}Ga;aRQAtL&xQdnSqsYpTnM|e^DHrQ0Ec&?zXk6?GeUX7|%-=4#wLu!W} zPAVsdt^R({mKrIje#O3E(wc`G?S~;TtcD!nBGOwrF{os@cet{p^vN14zN8oazPYX^ z6}}Uon=GHz(no=>zT-dR15cigI$i=_9>Dmfuu!5R7#Ohs?-p@Xu;p8{RUb9~X=gB; zNEd9Zir1+@3^_Rv2ptkcu7V9Ea5>fKZL56Cto*N5zbN@(1q<5MyMo13Q4QvTgM|gx zrajBbIaLPVC;D%%R)36IQkS{gy;7iR>(A#H&);JDFr77eC+Vf};+5UBf1iRpB z)MB~RC{^%Hc)oG399wbXDG_Wner0fzOl>u$l>N25$%TW4?#-Vp=5=D~v_OaTm>HAL z*P0x>SD1LH0qYU@E6181;S&+@LN9zZxVu9A_C@JW)`OFyyX1&_#4^~Lpf;u&^LN;n zYIC_1%?eI@r70v-u%17)@;17v8NhxYuE_l8^4g*jS6HnK0AiTf9Qb7aF3IA(Fel27 zYyVtVa$A%&9)%GBY05>ELX z;JQuqI(K4wxA_d-vcJ^SmKA+5e6`po2`=6INM`tH0bi4Oi@=uTiUAE=XYw!axJ7lKVu3rYwM zttrAG?ejD4vR_?p`#QDqFcD$#ji3jnr_cJ!Cw8H2e#RfHs4V!Mn~&0gbl8xTkEnty zL!sWu6!q_d^(Zl4^YmNH_$w^10k)~4>_O@WPbIsbD=|v02N&u#5397pFO>Ojzyb{- z`Y;5721G^J3$h$XcQsQaAWFa_g;Ydk zK+q;~gs7)G2$q_1XSH+}+43eplo316>EI;-uA$0Zuo3dT?OlZZQsl77G6uOn2DuHd zt!M$J>EFD}AVbT)6>;-)zQYm9^SQ$*UHyH@qlFKwS*GJE$Q$A>pRP+j8gIHtp^TDIm zYupGnT%q-zSKQ=BJK_P6fUh4?y#5T>*~qSQqy#705zY+U=1d+QqTUs6E~rir^zk#W zEksi|^>#c*S2g4Nb&RMU3XxjmIN?Stx6Xml5fNQUI%n^fivL%I+1PO47!H_ zZiXM#W4!~e#}eAo2D$`?qN6u9-@4USj=aRmf*$BnR&-8{@|plFG4GF9J+r>Tk<+~W z#|sy5CKZ5a9FD_R8Ygh}1ZF*j_uDyLiNVz#w4@+Iku|xwQTQ52%lX@tqAsNHp=+OM z!Zrl2?>$=o-)Ws32n(Dk1Z)ID_E8wojJ~>7#-Mma8TW>3FE?weg(cuE3degudQ|vQ z4L7|jt9Va5D@EUB{him#FoRoh$icx85j`ALv^+f^a{MXTF=&^ zA5e`H5ys&#pQZxKShH2VOOjJKk6mM=D{8aMGSlP*GLj2f$LbhE(OWfpg@<4CkMP>` zw=*imnqM2~Mv);ch0s#1#Zt*+ZtuWyMC3bfBK4bI13hc1!5msbbMBM!>YUGL#;U1K z3Njb)yxNXU#2Qizwjy40N253~v#E+6c4%(*cJM|QQw8{TZRkq`(!14w^^;~{+d`#Z zhvi;7E!Ao3_zz`Q!7|0)Y;pMKkq-uO4GW(hq@|?d;Co_FI6r6^7}Nx_9_-sM_E!YHF7m}<_HvEKz4q{5?q`f_#!~cA`thA1Mo&tnp`c7z zUs}R_`c2YXzftDBwCsG@kj?vvLOw<=Owrt&UwNT@X`kD%JIl;`Fvton{4V-D6pmVJ zz%Gry{UltQ(hRZseUrrq|4v#*`fpOnV*I(wl`Jmj%XMVlG+LYx`V;e_L@;9n>gw?D zJE6|$NnXMsS8vD3g~TTok|24F7KS$L)^Xlk#WgWDGoF2HZ5#s+w7v(`ojGZZy|Wfl;O^ zt`%Cf{WMBw<0e6FL8bRCLd(8a;)PEl5*l78ke%C0eNq^XU=T;!)HRt6TU>y>`CDWu zU(_BD>pW8Lz=mqV7=Fu3=s~E!#Uji-XR*DgDR_LMi*s+B zY%VxNm8{&6b1^<({#&KRPwteZ3wp3AE@tXn#PVJQ!(og+3oM$_%5_<)fQ=sYmSUs( zH44StAZYDnJ8|j|ZPJqRws-`A1+%DDfA=f<3Z`hX^t>3Qv)yXo;5^ehU8zBex7P1{ z{5b=UfmVgzG?k>OaF*!=l?{Qt5p@#_-(I{OP-!PV4fig7y3V!paS*20VwhGI?e#*A z2v#|{^t5=^IKk$TCqCxAnyJ{T>hy{1JbMGlE=oS`!W~24A@3BgYiHbl)C~^VaZh4o;>?ry$f)}e?MbPp>cU_XM~Lx(I} z$i#TQ!gS<- zy*g{n%qBov1#OOD97IV)YL`S;cmr%@XOiAoknFh7vdhc&_&b6!De$P_(w@1Ft?_AE zQX~(dwR}N~=jkUm?c{@n$ik1-XfxUV8%20Od*Yyx63 z5Ks;f_BcNmhi}^kz=De3-<+Jp@AFLsDw>H^00l805^AJ>$0M#AurxEK{R|WPIOK;z zIR6%H_0bKZ@yjE0X*Wy=q#OSY5#|$H+$nk$vL!ykp34H}D9s&s8c_}4S3AC_K7M#k ze1c$HJ|^dMJ7C4maV!o&J0h6pyk|e6`PSI)$jS^a_d?)((!icR0;0J=T6W~7tkNE* zKb&i2niyM`mBcM%2hd z@arAp(t6#khbF@Xc}v>w)g#C43+yqj_`patk<2;rYMO`EenB5LEn zE(mR+WGVTyF{zap@Olx?E|bC;vC8)Q;a|k%j}_ss`4o5hzPcxQrkn*IuSoSG>b~Ld zO#=hEs&rotr~d>0pj)P9c3BGoDhchN>vcSc>=>+`mz1ErKl!+{M3dHGe& z6qz-7_jZqt3_MaLINgq7{d1?&NVLP)ccOa=m4lH@@rRx{zvju4sYw(>Il|k# z-;$+uX0j6TE_hwc_w%i>)|LMSPm_E0UF=X|wt&eSB*=7i;Ym3WryskJBm|EwB4AfN z`V>Dt7#sY9<#{8y_=zQLPduZJG@?idhH){dUsWSk{&kTi#32w>&cPNT9)z-W@EDr# zRC@A@InDYkpK02B~ar*^i^lDur0o)6WS0KgAWk zSSTr!S0Y=W-DBGkNun9Y$GoYUj=SXJ8F_x32?+I$<)q!}#n34)+WJJ*W*Bo>51YbZ z5R^dYRYBC&^s~sFkA6|r+PA*UM&(x;HurnMk(bn=j!@z@P0mty9U%nw8BqP+1Ywas zx?YcL%0Yqjae4ri+KHZ3Ucg#}Ts_GO*0mntIs|na#6KjLSuzEr=YXJH4l;@D(lG(c z+P>pX#Vr`>82Eqc)xjWlEil5OV!?uu4II5Xyy4d2z|OJfO5?lCQ81sl%&=c;K{*S+ zJkl^Aj3|cb{%P!ENVY2ybQvtt7-l}J9nq_j^-yh3@B;Vag60=Vsw*qd$OOmi-T2XV z4XD-jNdyO`64=~@H%jzF=0X68q1VgWk1Pzr-{9i~e@zi;CZu4t#7&gpjz+jRrY~WP zf;Nr5Qd(%Vqgk=Y&zE-vXlKyRzB*{~5UKbaF(PD-O^g!id5D6VPZNkLgcLxK;?9~l zu`&V$eZH&A_BB#DrnxGrzl(KH7Jk8 zw5ba-TFxlgs{JkF6|>cv-ypK9o+e&f@+x&x;|qqSD6MKL7N`ulZ7`iVV!`GMyQX4{ zso3~*)B8leG}oQqDd?V)Ggg=!d7pF@T2G`dq(U!AW>s&V&{kMAbAVDGkz%8ej?BbQ zw7fdS(6z&HX97t$l>h{p_Z+7nbm#}qn)?H14F}vxPF1>9_g2YP=GC9dO!J8?gybQqrCYd3QU8d+E6jxd(h=vlE0OdA#!7_4U)Y0UV^~$-)cbID1R6R%Uw5 zW}8OhKdW|FSF#h?rX%^@B!57F-R=014VH~Gd6y1XLqM9tCgAIWu}W^`pw0P^ep2ci z$k|(NG{%q0NO2vk_jw5#7Kd{^m3M&cSXEh6Z9f$_u zua0Z;=??x`x=K6XKII!>@(Bet@xHQ*>=d*H8huM=>Eq%S==(I_#2Zq?PIrq-9 z`re1yD)P#=9m_uvS?#KVzF%=DTRZ+t z`-leIlU_&H#_WxWMI}ZombJPotwP5MV-`1N4Vw1inDh!995{}TkGK4$szCpwg00?h zt`__T>Eq}5{dWB_o#jen&{_49i0V00Y43uzgJmdL(xhCk)8f(qau3UfV&KC zmFn-X)#H8EGO?g9^hn$cT6D}MWsWd8q76OmB^719gfSi@_0a4(9!XieE+efFg9Wk>uf($~f>!hj_HJ60*Iz&bj{E&;Bq&r>M z6Frg7j&2BH-w}f0&RWX~>K^4Si7bjgD>ZNS<_d&^po8`m8|h85IB-(Li?wY*JM(4x*Y0uV>G%mJirUy3 zp!f(Qzz1LEovyU@t>iP)Aysb;uXuFPvMxvG^#i^rGyx-(B}Uk&#d-;q#X2m$I)g&inA; zFA5?fho8(AARjlM_}qY_OtNQ<62H;P8HZ8w1XkIbP3%qPy{`$N?(7XVNOTaoiTzqb zQMnLR@dKY*`UPHd^3qp;-&Z)gxgH)%W51R&pFguXZQQQ^K51}3+5@B&9iV&L`XrbG zC$oYlC)-oanloa>CmKgD(>O+ROW#71qdy$&zB#<%%~%aN&66$lzs!HEvo5h}hnZnk z8O_K{nGxeYaTNLfTaLJ4t&67<=7GgnCRVWzib|jXG=B=EAk}3=M)-c3R})%3ko;3S z!S)C50&$AK`%KhNvEGDe-|_@d-YFBJhCTBQe2|oMP%^ZzyCV%L-zJS4%tG=&DFg0y^%P) zY5KaFC2LofwJW&`16~kuKPK%0LeCS8WT-!C$;34{;>a*0>dd*kQ%_zrX#b4t>Ws2= z98X-sKXmRxP>TOMEo;NCeweYmy@cxoFOf#Tgw9+3Sgp@CoOK|nHgwoRn(u+WyT&mKGG4f8-!+f2 zSID{($pTR)J`gbaJX@DUeLF|`E~W4}UfDeE=^YgcPnlxWSbz1Nvr#C*21sCKj zOj%0TOPfRpqC?Y>^8}@H83F}awFC@_>pP7!N_{d#=I9(X_<}DoT(FRxPJren zHbfes&UnAH_Y>=x20E`*6ZV)Hem#-uK)J#!iXL`jiMc-M1C)A!l6sM|WZp@vC-e4WzLz%*rN5Cg7sPXAC%V zZ0E{U>cpaPQTLOPHLOreiQ@Yci9tt!o?@K6lX0i+PMG3K=0#3?FBL9$+&5QU=0W~VycgZWiK>OJ7KKSVnrmw~9TG-1{Ii$Wb*o=~!pjicDzTk>|{Rdz7k4G&n9`f2tuC zaSZRpOZ}r}YqCk-hGJt-+XPfF$`0R|-Uecff`>__?LqW&! zmFwH3BCHS$?JCe-Y_=#&d=#>1DG@85?bBQZ$?%|u(j(rvrK|W`?TOozD;oM(w=FqV zi708Z$DX%FYw=Ln+n7@Qy>I5iZ35k@-t@X1_>`%`uImOweZ_KZrc&-gMkXbNFUqy# z8mzXg%O27%2~}BV%oW|_+L9`$adgMHL!|!bCrk1KPiM z={i4?*CcJ4*Yj!fyW?Lqo169yF9_O?fI^J(G44r^=MA+eIgQTg;D4qfPK-gWS$2qW zw(}r%#qWI+?tVzzrMguz$?kQ#X*ahLhJ8%yg(g8`c(W+Lef$83_@Ip7x=kEfiY#|9 zRUS3!mm=DxMQyxojHoYU*Tl`aT@~7U)T*83Vv4bMO)Om;;72@RoQMP0J6atz)wAK+ zZSx@JldxyZH$NwlJV#6yl_dmiX@UjnwD%ecnd#-h-1W+?3;n$AmKu z63)Vt#iBe-V~gpaN;uS%8+PGHnOv}?Q$trPWhJHlLIR3pgyP3wptdgmB-OI z$6As;;@SFr3l2bKDfYeIH(y=A7}ShgOzFQRcViOu5NKCVJDL!#rF?4W`;*plXx$P76Dj`*Pe;1$Y;`F zTh)3+b~TDP3VXiYE?nRKEbjHe(I0*lgJ|Ll-L`S?jmt~Xgewn5>o@JXq&2(u<@Dn% z$|DLA#+8lH2io#21M@A67U~VHPzKtSNH}pJFfP{6CdyHy(xmqa57=CQGa2zCE4A67s}z$>r>ZzMB>jr&vj>rkV}-Uj>s*x zK2cQW(GkXPY1G@Whdwgh0@P9-Pb6XF=bCH-%24YjA&&~ZX925h7LR33d*x-+2(vBL zPDqfA5DG!G3xxw)Bvux8xNR(_OMy$yB`+<>PAsh_m0ht&h07b^>BgEHmMN=S6n@?l z(We*6{olE%S!dkH6AS30({wju4;%xhT(qm}8c7Qxx+(8VuKMp8H42U<_ce=|_Y!O* zz2_r~d-!S{G;j6HqhFuNgcuHObhPEbC_T#C>a<{KCDnh~IWlr@VT)Tqkm_~tC{*RK z*mbXT`lW)mz+P+KVld~hd z1dyc&L)A$wYw}c$#r3i(OF_0N!^&)$6A`T9f&-pWj_Blo*A(N7Gr$|+^mHl1Wwmzt3} z8VXOXf;7^ePjvkBCn0(MG-3g05S!<3XTiZ_#kiCywqQj~1I0%XjhNZPG`Y6|<6X#* zKJZ7|EN9ps&Hedl5##NTm2OZyqjd>P8s#xH)EnKAqROZn`x0KehRAyO%~_>&y0+$H+jGQe@wyH|IM3{=)v|@p_43`WOno zD0Ldk;_|f5MR|I36X^io-Dr8qftWu2wrh#fE;tw#oHiK zKG&spUvN%T(@-VA_BUM$sa9SA4ZvJH;{6KGmWD-2Q!F|+?<(LN2FhkNTCu{BpOcl9 zv{joX*kuDx|5`v{%aYNm6Q9u5nZQp&MAN4vvvVyDRxlVF{h6peT=N|z?A!-u!dad* zg;?SZP8JKrNDf-MQGxA*W?`}S8_P-x#Li(V(%nqPYN@u2vq^Cbib1g9>Qi|g5>``v zA?kSqMo^~U(bpSTBFJcFI2@4DK53`I^r;;;9FL1Dr>?x0{Wbl1;j4b!d^elmg z@ka_S2QeYCq)2Cb27V078Akq8>Nr;&xC~=ze2s6cVV7&Jm}Bb$K6+o zRs;Jce^o?Yv9Eg~RkuO4@56)C;l^Z55Q$h7AD|zjmz#I zv(L}EMmR%Ju5fzDS`_c0%V-QjXl%NRw(rWn-9oWBrJG(81R_^^sg!r<3$JQ0U)3#ALyIh97x8h@|+T3tH($O5!RND4T+A%i#%DH~%2}*)tT0dd! zyWp0Xj_gbeCDo+TI}nXCA$s~r8!J|bfO6uSv(s+p^Njh6EiQ3Vm=kaT2pd3Ka>-?0 zHPtq_5W&Zd-{EX`&>i1_|>$-6MDsV(P>`<4-_e8e*8X&^iw z>=ICf^ppVH5^Zg=LOVIy!8pRL$Obub8tkYobdqeEBKvej1(Tb#hsgz8}!#79|fidkf{SloGpi z{S38uTwK#|D(L0VQzPJ*OYFTT8)gDxIq{!hezQL>R3Ei_j$W;KB{_@g*6Wm68CqaB zTI`-N9FAa5rsA9@e}O(piJr%#s6jwpk{91~h^V_u`}t@Q;!Z3_fM$pd3b~C%SXmww z^?T$5O8Wjzi5!OZmRl~_ev@1I{m7uhQ%o-qx|A$s+T{l!cfn6?kKEQ9lfgsOh)ym$ zLi(MKgyZ=Fnr>$=q!wbIq1fH<0H{xKfo$LE`yc~I3CgAj2QQ4Hs3PIg8GMKjf!$x$ zh~m0UH*e5lR@T@@$Xa2;+rK!rGe&!B1xcV#G3W3$sjYv!XF%<}X^BAI3xh7sat=G* zaP2$`bGt2I9`JxX~PMUVq)aM>oh4@2H6hyC| zWFRS`qoR@ohSD4f+xRqHxWN0$~sDZib zHLg2SQG8SHYz&NaMch@qee+p*%;tMkTT;X*6mGD%1hJBQfx%ZpQbOI&AJhh5wtGHo zOna%VgsObh62qC^;NV8p+@y}BFRFgj01L^Ev@`l^T5C6;T@-9GS{a&@c=shn2H-27 zGOpW*k8F`*7mZ{y@zR=G*LH#P!w|r=%mb$R1r^WoS{(i_yZ+B#?&IcBE zFBAPr%3zg%VrmiXSEz>dcpeh_Ju9wyLC!T_Ulc8%W55Y<8|U%|f7XlQ9saQ;=9O?a zS-lvc`36h}B>3ITDvT_Jt)Po;Rj91J&&ep+@}+EWkHdhW&t(VSq4xECv&DQqw&Fi4g9c&Ip^ApkB|0$BbQst3jSu2ZkH>fXRk z=rE9}@6$|gC-E9G^>pnzJ^~F{4n~PQ zR7k()m`!T^4$s#P-SA(`Psr4>&ikAL-}QwTu&Xb@3HblOf6}n~@m))(|_ zy0;;NvDG!Sp^~EH8bZD)`41Tv`G?qQK!DlZUs+!o>q*9NmDJC6?{}@COzjI1y3rf$ zHkJiz&sRnyV)k|u$Cl4zz=UB*yxMA^L%W)NK~4@N=FF2#-yaX@$$sN%^k9@zJB{cy z(C;YxTwd&gRrifTaE6V9SJ_<-ljWC5qwpQp9~{-VfvUP4I;@S)JG;~*D->JWv8Vf2 zMSFQbPTmFiiBx$ye-Jj;3sSvUcYfGlE7SWqZ;tc>?>ufiEjVaK?-+6is`a;OPXacB ztwMa9d{Ae9alA%N>U&?p` z-}R{tcUyKLZkG`r?ke>}%FvyW(q{QGdzd`WtX{6H+Wc&(%TC(3b^4#|s3RwqEy;Cnr z-@)do+fa&w!S40Fw)PQ33m+6Udp0XNV{#Ho+|qW6#v;eCvxJxKPi+YYN68ssAX971 zj0NN@sZ}Sw`G<^T`-6?vmi~wrdU0)*-%stj!0_^dHxpVUosT#p!KQKzsEz5m{rc0* zxNt`K^p_1Y672S;nh_W3p^F#6LwuHViys5H<20ENy# z#zFuEZ$LNtO2q4tf&^te_0nqA!S#vhKcKfN zFlhot;!bzN!(T4Q*yp#Pl8ZRv<|*#Bv;vVU>B7yipNr`lGZOl}dM4@_4%MHIzjEa; z!CN9h*09xzTiM-9D6rD-88WLk+0iso2q$WK5Ra@AHhQjgJga|>4LbB-Fknb+E68Ib zcZ6gYgOtfD&Y0!?JPM6>)v&m!2 zIpaenoU`ccL>izQ$a{;NL-1O3^Z7`>3u8|NSQ|3>-$pwOa)ej(%f XQl0p2$hGayzgJ`>l_V;~j6?nhr(^z6 literal 0 HcmV?d00001 diff --git a/docs/source/rosette-logo.svg b/docs/source/rosette-logo.svg deleted file mode 100644 index 4c69ed4..0000000 --- a/docs/source/rosette-logo.svg +++ /dev/null @@ -1,35 +0,0 @@ - - - - - -rosette2 - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From ce6e29cf239ebacdc8fd31199c0fcdaf395f4f7a Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Fri, 25 Oct 2024 12:55:10 +0200 Subject: [PATCH 083/106] WS-3314: documentation rebranding --- docs/source/conf.py | 4 ++-- docs/source/index.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 39446dd..5b56fd1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -47,8 +47,8 @@ # General information about the project. project = '' -copyright = '2024, Basis Technology' -author = 'Basis Technology' +copyright = '2024, Babel Street' +author = 'Babel Street' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/docs/source/index.rst b/docs/source/index.rst index 40ebcf1..1eac0ca 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -6,7 +6,7 @@ Python Binding ========================================== -This is the API documentation for the Rosette API Python Binding. For examples and usage, please refer to our `API Guide `_. +This is the API documentation for the Babel Street Analytics API Python Binding. For examples and usage, please refer to our `API Guide `_. .. toctree:: :maxdepth: 2 From 1bcdea585a74422135c9bf78eeafa75a6598cfe9 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Fri, 25 Oct 2024 13:48:35 +0200 Subject: [PATCH 084/106] WS-3314: update examples --- examples/README.md | 12 ++++++------ examples/address_similarity.py | 8 ++++---- examples/categories.py | 12 ++++++------ examples/entities.py | 12 ++++++------ examples/events.py | 8 ++++---- examples/events_negation.py | 8 ++++---- examples/info.py | 8 ++++---- examples/language.py | 8 ++++---- examples/language_multilingual.py | 8 ++++---- examples/morphology_complete.py | 12 ++++++------ examples/morphology_compound-components.py | 12 ++++++------ examples/morphology_han-readings.py | 12 ++++++------ examples/morphology_lemmas.py | 12 ++++++------ examples/morphology_parts-of-speech.py | 12 ++++++------ examples/name_deduplication.py | 8 ++++---- examples/name_similarity.py | 8 ++++---- examples/name_translation.py | 8 ++++---- examples/ping.py | 8 ++++---- examples/record_similarity.py | 8 ++++---- examples/relationships.py | 8 ++++---- examples/semantic_vectors.py | 12 ++++++------ examples/sentences.py | 8 ++++---- examples/sentiment.py | 12 ++++++------ examples/similar_terms.py | 12 ++++++------ examples/syntax_dependencies.py | 8 ++++---- examples/tokens.py | 12 ++++++------ examples/topics.py | 12 ++++++------ examples/transliteration.py | 12 ++++++------ 28 files changed, 140 insertions(+), 140 deletions(-) diff --git a/examples/README.md b/examples/README.md index e52b2cb..74b23a9 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,18 +1,18 @@ ## Endpoint Examples -Each example file demonstrates one of the capabilities of the Rosette Platform. +Each example file demonstrates one of the capabilities of the Babel Street Analytics Platform. Here are some methods for running the examples. Each example will also accept an optional `--url` parameter for overriding the default URL. -A note on prerequisites. Rosette API only supports TLS 1.2 so ensure your toolchain also supports it. +A note on prerequisites. Analytics API only supports TLS 1.2 so ensure your toolchain also supports it. #### Virtualenv/Latest Release ``` git clone git@github.com:rosette-api/python.git cd python/examples -virtualenv rosette_venv -source rosette_venv/bin/activate +virtualenv analytics_venv +source analytics_venv/bin/activate pip install rosette_api python ping.py -k $API_KEY ``` @@ -21,8 +21,8 @@ python ping.py -k $API_KEY ``` git clone git@github.com:rosette-api/python.git cd python -virtualenv rosette_venv -source rosette_venv/bin/activate +virtualenv analytics_venv +source analytics_venv/bin/activate python setup.py install cd examples python ping.py -k $API_KEY diff --git a/examples/address_similarity.py b/examples/address_similarity.py index f69e4e1..2175817 100644 --- a/examples/address_similarity.py +++ b/examples/address_similarity.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get match score (similarity) of two addresses. +Example code to call Analytics API to get match score (similarity) of two addresses. """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, AddressSimilarityParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -29,9 +29,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/categories.py b/examples/categories.py index 1c3e122..6f09c75 100644 --- a/examples/categories.py +++ b/examples/categories.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get the category of a document (at a given URL). +Example code to call Analytics API to get the category of a document (at a given URL). """ import argparse @@ -12,7 +12,7 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ categories_text_data = "If you are a fan of the British television series Downton Abbey and you are planning to be in New York anytime before April 2nd, there is a perfect stop for you while in town." # Create an API instance @@ -20,8 +20,8 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): # Set selected API options # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#categorization + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#categorization # api.set_option('singleLabel', 'true') # api.set_option('scoreThreshold',- 0.20) @@ -38,9 +38,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/entities.py b/examples/entities.py index 30a2ea5..beba9de 100644 --- a/examples/entities.py +++ b/examples/entities.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get entities from a piece of text. +Example code to call Analytics API to get entities from a piece of text. """ import argparse @@ -10,15 +10,15 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#entity-extraction-and-linking + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#entity-extraction-and-linking # api.set_option('calculateSalience','true') # api.set_option('linkEntities','false') @@ -36,9 +36,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/events.py b/examples/events.py index 828dd45..79ffc3e 100644 --- a/examples/events.py +++ b/examples/events.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get events from a piece of text. +Example code to call Analytics API to get events from a piece of text. """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -27,9 +27,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/events_negation.py b/examples/events_negation.py index 880420f..becc731 100644 --- a/examples/events_negation.py +++ b/examples/events_negation.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get events, based on a set negation option, from a piece of text. +Example code to call Analytics API to get events, based on a set negation option, from a piece of text. """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -31,9 +31,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/info.py b/examples/info.py index 9684088..8fba621 100644 --- a/examples/info.py +++ b/examples/info.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get information such as version and build +Example code to call Analytics API to get information such as version and build """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -24,9 +24,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/language.py b/examples/language.py index fbfc936..e4fa87a 100644 --- a/examples/language.py +++ b/examples/language.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to determine the language of a piece of text. +Example code to call Analytics API to determine the language of a piece of text. """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -28,9 +28,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/language_multilingual.py b/examples/language_multilingual.py index c442b76..36bd8e6 100644 --- a/examples/language_multilingual.py +++ b/examples/language_multilingual.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to determine the language of a piece of text. +Example code to call Analytics API to determine the language of a piece of text. """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -30,9 +30,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/morphology_complete.py b/examples/morphology_complete.py index b1c0880..10b1004 100644 --- a/examples/morphology_complete.py +++ b/examples/morphology_complete.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get the complete morphological analysis of a piece of text. +Example code to call Analytics API to get the complete morphological analysis of a piece of text. """ import argparse @@ -10,15 +10,15 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#morphological-analysis-introduction + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#morphological-analysis-introduction # api.set_option('modelType','perceptron') #Valid for Chinese and Japanese only @@ -34,9 +34,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/morphology_compound-components.py b/examples/morphology_compound-components.py index 3332e71..5bacddb 100644 --- a/examples/morphology_compound-components.py +++ b/examples/morphology_compound-components.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get de-compounded words from a piece of text. +Example code to call Analytics API to get de-compounded words from a piece of text. """ import argparse @@ -10,15 +10,15 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#morphological-analysis-introduction + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#morphological-analysis-introduction # api.set_option('modelType','perceptron') #Valid for Chinese and Japanese only @@ -34,9 +34,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/morphology_han-readings.py b/examples/morphology_han-readings.py index b140969..f5c12f6 100644 --- a/examples/morphology_han-readings.py +++ b/examples/morphology_han-readings.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get Chinese readings of words in a piece of text. +Example code to call Analytics API to get Chinese readings of words in a piece of text. """ import argparse @@ -10,14 +10,14 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#morphological-analysis-introduction + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#morphological-analysis-introduction # api.set_option('modelType','perceptron') #Valid for Chinese and Japanese only @@ -33,9 +33,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/morphology_lemmas.py b/examples/morphology_lemmas.py index 20921cb..dc7bb8d 100644 --- a/examples/morphology_lemmas.py +++ b/examples/morphology_lemmas.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get lemmas for words in a piece of text. +Example code to call Analytics API to get lemmas for words in a piece of text. """ import argparse @@ -10,15 +10,15 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#morphological-analysis-introduction + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#morphological-analysis-introduction # api.set_option('modelType','perceptron') #Valid for Chinese and Japanese only @@ -34,9 +34,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/morphology_parts-of-speech.py b/examples/morphology_parts-of-speech.py index 48e3a07..f020ca2 100644 --- a/examples/morphology_parts-of-speech.py +++ b/examples/morphology_parts-of-speech.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get part-of-speech tags for words in a piece of text. +Example code to call Analytics API to get part-of-speech tags for words in a piece of text. """ import argparse @@ -10,15 +10,15 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#morphological-analysis-introduction + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#morphological-analysis-introduction # api.set_option('modelType','perceptron') # Valid for Chinese and Japanese only @@ -34,9 +34,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/name_deduplication.py b/examples/name_deduplication.py index 3c56fa9..7c69e20 100644 --- a/examples/name_deduplication.py +++ b/examples/name_deduplication.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to deduplicate a list of names. +Example code to call Analytics API to deduplicate a list of names. """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, NameDeduplicationParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -29,9 +29,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/name_similarity.py b/examples/name_similarity.py index d700789..b8a51ec 100644 --- a/examples/name_similarity.py +++ b/examples/name_similarity.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get match score (similarity) of two names. +Example code to call Analytics API to get match score (similarity) of two names. """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, NameSimilarityParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -31,9 +31,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/name_translation.py b/examples/name_translation.py index fd9a753..455fc50 100644 --- a/examples/name_translation.py +++ b/examples/name_translation.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to translate a name from one language to another. +Example code to call Analytics API to translate a name from one language to another. """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, NameTranslationParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -30,9 +30,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/ping.py b/examples/ping.py index 89d0925..f908367 100644 --- a/examples/ping.py +++ b/examples/ping.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to send Rosette API a ping to check its reachability. +Example code to send Analytics API a ping to check its reachability. """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -24,9 +24,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/record_similarity.py b/examples/record_similarity.py index f39b548..0ef1ea7 100644 --- a/examples/record_similarity.py +++ b/examples/record_similarity.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get similarity score between a list of records +Example code to call Analytics API to get similarity score between a list of records """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, RecordSimilarityParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -102,9 +102,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/relationships.py b/examples/relationships.py index a04651c..490a527 100644 --- a/examples/relationships.py +++ b/examples/relationships.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get entities's relationships from a piece of text. +Example code to call Analytics API to get entities's relationships from a piece of text. """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -26,9 +26,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/semantic_vectors.py b/examples/semantic_vectors.py index c67e326..ef99e5b 100644 --- a/examples/semantic_vectors.py +++ b/examples/semantic_vectors.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get text vectors from a piece of text. +Example code to call Analytics API to get text vectors from a piece of text. """ import argparse @@ -10,15 +10,15 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#semantic-vectors + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#semantic-vectors # api.set_option('perToken', 'true') @@ -34,9 +34,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/sentences.py b/examples/sentences.py index 747db2e..f0c3e12 100644 --- a/examples/sentences.py +++ b/examples/sentences.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get sentences in a piece of text. +Example code to call Analytics API to get sentences in a piece of text. """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) @@ -28,9 +28,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/sentiment.py b/examples/sentiment.py index dd5b52e..1a292d8 100644 --- a/examples/sentiment.py +++ b/examples/sentiment.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get the sentiment of a local file. +Example code to call Analytics API to get the sentiment of a local file. """ import argparse @@ -12,7 +12,7 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create default file to read from temp_file = tempfile.NamedTemporaryFile(suffix=".html") @@ -25,8 +25,8 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#sentiment-analysis + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#sentiment-analysis # api.set_option('modelType','dnn') #Valid for English only @@ -49,9 +49,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/similar_terms.py b/examples/similar_terms.py index 88f2940..753e397 100644 --- a/examples/similar_terms.py +++ b/examples/similar_terms.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get similar terms for an input. +Example code to call Analytics API to get similar terms for an input. """ import argparse @@ -10,15 +10,15 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#similar-terms + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#similar-terms api.set_option("resultLanguages", ['spa', 'deu', 'jpn']) @@ -34,9 +34,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/syntax_dependencies.py b/examples/syntax_dependencies.py index 38a86b0..e5e99a0 100644 --- a/examples/syntax_dependencies.py +++ b/examples/syntax_dependencies.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get the syntactic dependencies of a document (at a given URL). +Example code to call Analytics API to get the syntactic dependencies of a document (at a given URL). """ import argparse @@ -10,7 +10,7 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ syntax_dependencies_data = "Yoshinori Ohsumi, a Japanese cell biologist, was awarded the Nobel Prize in Physiology or Medicine on Monday." params = DocumentParameters() @@ -26,9 +26,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/tokens.py b/examples/tokens.py index a7f47a6..e98601c 100644 --- a/examples/tokens.py +++ b/examples/tokens.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get the tokens (words) in a piece of text. +Example code to call Analytics API to get the tokens (words) in a piece of text. """ import argparse @@ -10,15 +10,15 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#tokenization + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#tokenization # api.set_option('modelType','perceptron') #Valid for Chinese and Japanese only @@ -34,9 +34,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/topics.py b/examples/topics.py index 55fa627..e33a745 100644 --- a/examples/topics.py +++ b/examples/topics.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to get the topics (key phrases and concepts) in a piece of text. +Example code to call Analytics API to get the topics (key phrases and concepts) in a piece of text. """ import argparse @@ -10,15 +10,15 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#topic-extraction + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#topic-extraction # api.set_option('keyphraseSalienceThreshold','.5') # api.set_option('conceptSalienceThreshold','.1') @@ -35,9 +35,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() diff --git a/examples/transliteration.py b/examples/transliteration.py index be9aa82..bc7c5da 100644 --- a/examples/transliteration.py +++ b/examples/transliteration.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Example code to call Rosette API to transliterate a piece of text. +Example code to call Analytics API to transliterate a piece of text. """ import argparse @@ -10,15 +10,15 @@ from rosette.api import API, DocumentParameters, RosetteException -def run(key, alt_url='https://api.rosette.com/rest/v1/'): +def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): """ Run the example """ # Create an API instance api = API(user_key=key, service_url=alt_url) # Set selected API options. # For more information on the functionality of these - # and other available options, see Rosette Features & Functions - # https://developer.rosette.com/features-and-functions#transliteration + # and other available options, see Analytics Features & Functions + # https://developer.babelstreet.com/features-and-functions#transliteration # To transliterate from native Arabic script to Arabizi add: # api.set_option('reversed','True') @@ -36,9 +36,9 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'): PARSER = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint') -PARSER.add_argument('-k', '--key', help='Rosette API Key', required=True) +PARSER.add_argument('-k', '--key', help='Analytics API Key', required=True) PARSER.add_argument('-u', '--url', help="Alternative API URL", - default='https://api.rosette.com/rest/v1/') + default='https://analytics.babelstreet.com/rest/v1/') if __name__ == '__main__': ARGS = PARSER.parse_args() From 740a61c62c7032fba5db2b09a3537c57bcdc6e00 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Fri, 25 Oct 2024 14:05:25 +0200 Subject: [PATCH 085/106] WS-3314: update url, key header and documentation comments --- rosette/__init__.py | 2 +- rosette/api.py | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/rosette/__init__.py b/rosette/__init__.py index 200c03e..880e295 100644 --- a/rosette/__init__.py +++ b/rosette/__init__.py @@ -1,5 +1,5 @@ """ -Python client for the Rosette API. +Python client for the Babel Street Analytics API. Copyright (c) 2014-2022 Basis Technology Corporation. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/rosette/api.py b/rosette/api.py index 6114554..b6fa7af 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -Python client for the Rosette API. +Python client for the Babel Street Analytics API. Copyright (c) 2014-2024 Basis Technology Corporation. @@ -68,7 +68,7 @@ def _my_loads(obj, response_headers): class RosetteException(Exception): - """Exception thrown by all Rosette API operations for errors local and remote. + """Exception thrown by all Analytics API operations for errors local and remote. TBD. Right now, the only valid operation is conversion to __str__. """ @@ -96,13 +96,13 @@ def __init__(self, repertoire): def __setitem__(self, key, val): if key not in self.__params: raise RosetteException( - "badKey", "Unknown Rosette parameter key", repr(key)) + "badKey", "Unknown Analytics parameter key", repr(key)) self.__params[key] = val def __getitem__(self, key): if key not in self.__params: raise RosetteException( - "badKey", "Unknown Rosette parameter key", repr(key)) + "badKey", "Unknown Analytics parameter key", repr(key)) return self.__params[key] def validate(self): @@ -370,9 +370,9 @@ def validate(self): class EndpointCaller(object): """L{EndpointCaller} objects are invoked via their instance methods to obtain results - from the Rosette server described by the L{API} object from which they + from the Analytics server described by the L{API} object from which they are created. Each L{EndpointCaller} object communicates with a specific endpoint - of the Rosette server, specified at its creation. Use the specific + of the Analytics server, specified at its creation. Use the specific instance methods of the L{API} object to create L{EndpointCaller} objects bound to corresponding endpoints. @@ -382,7 +382,7 @@ class EndpointCaller(object): The results of all operations are returned as python dictionaries, whose keys and values correspond exactly to those of the corresponding - JSON return value described in the Rosette web service documentation. + JSON return value described in the Analytics web service documentation. """ def __init__(self, api, suburl): @@ -413,7 +413,7 @@ def __finish_result(self, response, ename): complaint_url = ename + " " + self.suburl raise RosetteException(code, complaint_url + - " : failed to communicate with Rosette", msg) + " : failed to communicate with Analytics", msg) def __set_headers(self): headers = {'Accept': _APPLICATION_JSON, @@ -435,7 +435,7 @@ def __set_headers(self): headers[_CUSTOM_HEADER_PREFIX + 'Devel'] = 'true' if self.user_key is not None: - headers[_CUSTOM_HEADER_PREFIX + "Key"] = self.user_key + headers["X-BabelStreetAPI-Key"] = self.user_key return headers @@ -473,7 +473,7 @@ def call(self, parameters, paramtype=None): In all cases, the result is returned as a python dictionary conforming to the JSON object described in the endpoint's entry - in the Rosette web service documentation. + in the Analytics web service documentation. @param parameters: An object specifying the data, and possible metadata, to be processed by the endpoint. See the @@ -548,22 +548,22 @@ def call(self, parameters, paramtype=None): class API(object): """ - Rosette Python Client Binding API; representation of a Rosette server. + Analytics Python Client Binding API; representation of an Analytics server. Call instance methods upon this object to obtain L{EndpointCaller} objects - which can communicate with particular Rosette server endpoints. + which can communicate with particular Analytics server endpoints. """ def __init__( self, user_key=None, - service_url='https://api.rosette.com/rest/v1/', + service_url='https://analytics.babelstreet.com/rest/v1/', retries=5, refresh_duration=0.5, debug=False): """ Create an L{API} object. @param user_key: (Optional; required for servers requiring authentication.) An authentication string to be sent as user_key with all requests. The - default Rosette server requires authentication to the server. + default Analytics server requires authentication to the server. """ # logging.basicConfig(filename="binding.log", filemode="w", level=logging.DEBUG) self.user_key = user_key @@ -703,7 +703,7 @@ def _make_request(self, operation, url, data, headers): except requests.exceptions.RequestException as exception: raise RosetteException( exception, - "Unable to establish connection to the Rosette API server", + "Unable to establish connection to the Analytics API server", url) raise RosetteException(code, message, url) From ea8bbc34bdb66e11ba3f6cffa534fe140b80384b Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Fri, 25 Oct 2024 14:37:14 +0200 Subject: [PATCH 086/106] WS-3314: update tests --- tests/test_rosette_api.py | 146 +++++++++++++++++++------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index a635025..8316b97 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -155,7 +155,7 @@ def test_user_agent(api): def test_ping(api, json_response): """Test ping""" httpretty.enable() - httpretty.register_uri(httpretty.GET, "https://api.rosette.com/rest/v1/ping", + httpretty.register_uri(httpretty.GET, "https://analytics.babelstreet.com/rest/v1/ping", body=json_response, status=200, content_type="application/json") result = api.ping() @@ -169,7 +169,7 @@ def test_ping(api, json_response): def test_info(api, json_response): """Test info""" httpretty.enable() - httpretty.register_uri(httpretty.GET, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.GET, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") result = api.info() @@ -184,7 +184,7 @@ def test_info(api, json_response): def test_for_409(api, json_409): """Test for 409 handling""" httpretty.enable() - httpretty.register_uri(httpretty.GET, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.GET, "https://analytics.babelstreet.com/rest/v1/info", body=json_409, status=409, content_type="application/json") with pytest.raises(RosetteException) as e_rosette: @@ -200,7 +200,7 @@ def test_for_409(api, json_409): def test_the_max_pool_size(json_response, doc_params): """Test max pool size""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/language", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/language", body=json_response, status=200, content_type="application/json", adding_headers={ 'x-rosetteapi-concurrency': 5 @@ -221,7 +221,7 @@ def test_the_max_pool_size(json_response, doc_params): def test_the_language_endpoint(api, json_response, doc_params, doc_map): """Test language endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/language", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/language", body=json_response, status=200, content_type="application/json") result = api.language(doc_params) @@ -240,7 +240,7 @@ def test_the_language_endpoint(api, json_response, doc_params, doc_map): def test_the_sentences_endpoint(api, json_response, doc_params, doc_map): """Test the sentences endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/sentences", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/sentences", body=json_response, status=200, content_type="application/json") result = api.sentences(doc_params) @@ -261,7 +261,7 @@ def test_the_sentences_endpoint(api, json_response, doc_params, doc_map): def test_the_tokens_endpoint(api, json_response, doc_params): """Test the tokens endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/tokens", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/tokens", body=json_response, status=200, content_type="application/json") result = api.tokens(doc_params) @@ -275,9 +275,9 @@ def test_the_tokens_endpoint(api, json_response, doc_params): def test_the_morphology_complete_endpoint(api, json_response, doc_params): """Test the morphology complete endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/morphology/complete", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/complete", body=json_response, status=200, content_type="application/json") result = api.morphology(doc_params) @@ -291,9 +291,9 @@ def test_the_morphology_complete_endpoint(api, json_response, doc_params): def test_the_morphology_lemmas_endpoint(api, json_response, doc_params): """Test the morphology lemmas endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/morphology/lemmas", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/lemmas", body=json_response, status=200, content_type="application/json") result = api.morphology(doc_params, 'lemmas') @@ -307,9 +307,9 @@ def test_the_morphology_lemmas_endpoint(api, json_response, doc_params): def test_the_morphology_parts_of_speech_endpoint(api, json_response, doc_params): """Test the morphology parts-of-speech endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/morphology/parts-of-speech", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/parts-of-speech", body=json_response, status=200, content_type="application/json") result = api.morphology(doc_params, 'parts-of-speech') @@ -323,9 +323,9 @@ def test_the_morphology_parts_of_speech_endpoint(api, json_response, doc_params) def test_the_morphology_compound_components_endpoint(api, json_response, doc_params): """Test the morphology compound-components endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/morphology/compound-components", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/compound-components", body=json_response, status=200, content_type="application/json") result = api.morphology(doc_params, 'compound-components') @@ -339,9 +339,9 @@ def test_the_morphology_compound_components_endpoint(api, json_response, doc_par def test_the_morphology_han_readings_endpoint(api, json_response, doc_params): """Test the morphology han-reading endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/morphology/han-readings", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/han-readings", body=json_response, status=200, content_type="application/json") result = api.morphology(doc_params, 'han-readings') @@ -355,9 +355,9 @@ def test_the_morphology_han_readings_endpoint(api, json_response, doc_params): def test_the_entities_endpoint(api, json_response, doc_params): """Test the entities endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/entities", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/entities", body=json_response, status=200, content_type="application/json") result = api.entities(doc_params) @@ -371,9 +371,9 @@ def test_the_entities_endpoint(api, json_response, doc_params): def test_the_categories_endpoint(api, json_response, doc_params): """Test the categories endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/categories", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/categories", body=json_response, status=200, content_type="application/json") result = api.categories(doc_params) @@ -387,9 +387,9 @@ def test_the_categories_endpoint(api, json_response, doc_params): def test_the_sentiment_endpoint(api, json_response, doc_params): """Test the sentiment endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/sentiment", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/sentiment", body=json_response, status=200, content_type="application/json") result = api.sentiment(doc_params) @@ -403,9 +403,9 @@ def test_the_sentiment_endpoint(api, json_response, doc_params): def test_the_multipart_operation(api, json_response, doc_params, tmpdir): """Test multipart""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/sentiment", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/sentiment", body=json_response, status=200, content_type="application/json") tmp_file = tmpdir.mkdir("sub").join("testfile.txt") @@ -420,9 +420,9 @@ def test_the_multipart_operation(api, json_response, doc_params, tmpdir): def test_incompatible_type(api, json_response): """Test the name translation endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/sentences", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/sentences", body=json_response, status=200, content_type="application/json") params = NameTranslationParameters() @@ -445,9 +445,9 @@ def test_incompatible_type(api, json_response): def test_the_name_translation_endpoint(api, json_response): """Test the name translation endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-translation", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-translation", body=json_response, status=200, content_type="application/json") params = NameTranslationParameters() @@ -465,9 +465,9 @@ def test_the_name_translation_endpoint(api, json_response): def test_the_name_requests_with_text(api, json_response): """Test the name similarity with text""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") with pytest.raises(RosetteException) as e_rosette: result = api.name_similarity("should fail") @@ -496,9 +496,9 @@ def test_the_name_requests_with_text(api, json_response): def test_the_name_similarity_single_parameters(api, json_response): """Test the name similarity parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") matched_name_data1 = "John Mike Smith" @@ -517,9 +517,9 @@ def test_the_name_similarity_single_parameters(api, json_response): def test_the_name_similarity_multiple_parameters(api, json_response): """Test the name similarity parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") matched_name_data1 = "John Mike Smith" @@ -538,9 +538,9 @@ def test_the_name_similarity_multiple_parameters(api, json_response): def test_the_name_similarity_endpoint(api, json_response): """Test the name similarity endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") matched_name_data1 = "Michael Jackson" @@ -564,9 +564,9 @@ def test_the_name_similarity_endpoint(api, json_response): def test_name_deduplication_parameters(api, json_response): """Test the Name Deduplication Parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-deduplication", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-deduplication", body=json_response, status=200, content_type="application/json") params = NameDeduplicationParameters() @@ -589,9 +589,9 @@ def test_name_deduplication_parameters(api, json_response): def test_the_name_deduplication_endpoint(api, json_response): """Test the name deduplication endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-deduplication", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-deduplication", body=json_response, status=200, content_type="application/json") dedup_list = ["John Smith", "Johnathon Smith", "Fred Jones"] @@ -611,9 +611,9 @@ def test_the_name_deduplication_endpoint(api, json_response): def test_the_relationships_endpoint(api, json_response): """Test the relationships endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/relationships", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/relationships", body=json_response, status=200, content_type="application/json") params = DocumentParameters() @@ -631,9 +631,9 @@ def test_for_404(api, json_response): """Test for 404 handling""" httpretty.enable() body = json.dumps({'message': 'not found'}) - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.GET, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.GET, "https://analytics.babelstreet.com/rest/v1/info", body=body, status=404, content_type="application/json") with pytest.raises(RosetteException) as e_rosette: @@ -650,9 +650,9 @@ def test_for_404(api, json_response): def test_for_content_and_contentUri(api, json_response, doc_params): """Test for content and contentUri in DocumentParameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/entities", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/entities", body=json_response, status=200, content_type="application/json") doc_params['contentUri'] = 'https://example.com' @@ -670,9 +670,9 @@ def test_for_content_and_contentUri(api, json_response, doc_params): def test_for_no_content_or_contentUri(api, json_response, doc_params): """Test for missing content and contentUri in DocumentParameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/entities", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/entities", body=json_response, status=200, content_type="application/json") doc_params['content'] = None @@ -688,9 +688,9 @@ def test_for_no_content_or_contentUri(api, json_response, doc_params): def test_for_address_similarity_required_parameters(api, json_response): """Test address similarity parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/address-similarity", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/address-similarity", body=json_response, status=200, content_type="application/json") params = AddressSimilarityParameters() @@ -724,9 +724,9 @@ def test_for_address_similarity_required_parameters(api, json_response): def test_for_address_similarity_optional_parameters(api, json_response): """Test address similarity parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/address-similarity", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/address-similarity", body=json_response, status=200, content_type="application/json") params = AddressSimilarityParameters() @@ -753,9 +753,9 @@ def test_for_address_similarity_optional_parameters(api, json_response): def test_for_name_similarity_required_parameters(api, json_response): """Test name similarity parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") matched_name_data1 = "Michael Jackson" @@ -791,9 +791,9 @@ def test_for_name_similarity_required_parameters(api, json_response): def test_for_name_translation_required_parameters(api, json_response): """Test name translation parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-translation", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-translation", body=json_response, status=200, content_type="application/json") params = NameTranslationParameters() @@ -826,7 +826,7 @@ def test_for_name_translation_required_parameters(api, json_response): def test_the_semantic_vectors_endpoint(api, json_response, doc_params): """Test semantic vectors endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/semantics/vector", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/semantics/vector", body=json_response, status=200, content_type="application/json") result = api.semantic_vectors(doc_params) @@ -838,7 +838,7 @@ def test_the_semantic_vectors_endpoint(api, json_response, doc_params): def test_the_syntax_dependencies_endpoint(api, json_response, doc_params): """Test syntax dependencies endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/syntax/dependencies", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/syntax/dependencies", body=json_response, status=200, content_type="application/json") result = api.syntax_dependencies(doc_params) @@ -852,9 +852,9 @@ def test_the_syntax_dependencies_endpoint(api, json_response, doc_params): def test_the_transliteration_endpoint(api, json_response): """Test the transliteration endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/transliteration", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/transliteration", body=json_response, status=200, content_type="application/json") params = DocumentParameters() @@ -870,9 +870,9 @@ def test_the_transliteration_endpoint(api, json_response): def test_the_topics_endpoint(api, json_response, doc_params): """Test the topics endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/topics", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/topics", body=json_response, status=200, content_type="application/json") result = api.topics(doc_params) @@ -886,7 +886,7 @@ def test_the_topics_endpoint(api, json_response, doc_params): def test_the_similar_terms_endpoint(api, json_response, doc_params): """Test the similar terms endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/semantics/similar", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/semantics/similar", body=json_response, status=200, content_type="application/json") api.set_option("resultLanguages", ["spa", "jpn", "deu"]) @@ -901,7 +901,7 @@ def test_the_deprecated_endpoints(api, json_response, doc_params): # TEXT_EMBEDDING calls SEMANTIC_VECTORS httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/semantics/vector", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/semantics/vector", body=json_response, status=200, content_type="application/json") result = api.text_embedding(doc_params) @@ -911,9 +911,9 @@ def test_the_deprecated_endpoints(api, json_response, doc_params): # MATCHED_NAME calls NAME_SIMILARITY httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") name_similarity_params = NameSimilarityParameters() @@ -932,9 +932,9 @@ def test_the_deprecated_endpoints(api, json_response, doc_params): # TRANSLATED_NAME calls NAME_TRANSLATION httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-translation", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-translation", body=json_response, status=200, content_type="application/json") name_translation_params = NameTranslationParameters() @@ -955,9 +955,9 @@ def test_the_deprecated_endpoints(api, json_response, doc_params): def test_the_events_endpoint(api, json_response, doc_params): """Test the events endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", body=json_response, status=200, content_type="application/json") - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/events", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/events", body=json_response, status=200, content_type="application/json") result = api.events(doc_params) @@ -971,7 +971,7 @@ def test_the_events_endpoint(api, json_response, doc_params): def test_the_record_similarity_endpoint(api, json_response): """Test the record similarity endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/record-similarity", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/record-similarity", body=json_response, status=200, content_type="application/json") params = RecordSimilarityParameters() @@ -988,7 +988,7 @@ def test_the_record_similarity_endpoint(api, json_response): def test_for_record_similarity_required_parameters(api, json_response): """Test record similarity parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/record-similarity", + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/record-similarity", body=json_response, status=200, content_type="application/json") params = RecordSimilarityParameters() From 69b8291986fa16de95841a95d3b18dcaf53274a2 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Fri, 25 Oct 2024 14:49:21 +0200 Subject: [PATCH 087/106] WS-3314: update readme and package description --- README.md | 34 ++++++++++++++++++++++++++-------- setup.py | 4 ++-- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ceb1212..2ce08ef 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,31 @@ - -# Rosette by Babel Street + + + + + Babel Street Logo + + + +# Analytics by Babel Street [![PyPI version](https://badge.fury.io/py/rosette-api.svg)](https://badge.fury.io/py/rosette-api) [![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) -Rosette uses natural language processing, statistical modeling, and machine learning to analyze unstructured and semi-structured text across hundreds of language-script combinations, revealing valuable information and actionable data. Rosette provides endpoints for extracting entities and relationships, translating and comparing the similarity of names, categorizing and adding linguistic tags to text and more. Rosette Server is the on-premises installation of Rosette, with access to Rosette's functions as RESTful web service endpoints. This solves cloud security worries and allows customization (models/indexes) as needed for your business. +Our product is a full text processing pipeline from data preparation to extracting the most relevant information and +analysis utilizing precise, focused AI that has built-in human understanding. Text Analytics provides foundational +linguistic analysis for identifying languages and relating words. The result is enriched and normalized text for +high-speed search and processing without translation. + +Text Analytics extracts events and entities — people, organizations, and places — from unstructured text and adds the +structure of associating those entities into events that deliver only the necessary information for near real-time +decision making. Accompanying tools shorten the process of training AI models to recognize domain-specific events. + +The product delivers a multitude of ways to sharpen and expand search results. Semantic similarity expands search +beyond keywords to words with the same meaning, even in other languages. Sentiment analysis and topic extraction help +filter results to what’s relevant. -## Rosette API Access -- Rosette Cloud [Sign Up](https://developer.rosette.com/signup) +## Analytics API Access +- Analytics Cloud [Sign Up](https://developer.babelstreet.com/signup) ## Quick Start @@ -15,14 +33,14 @@ Rosette uses natural language processing, statistical modeling, and machine lear `pip install rosette_api` #### Examples -View small example programs for each Rosette endpoint +View small example programs for each Analytics endpoint in the [examples](https://github.com/rosette-api/python/tree/develop/examples) directory. #### Documentation & Support - [Binding API](https://rosette-api.github.io/python/) -- [Rosette Platform API](https://docs.babelstreet.com/API/en/index-en.html) +- [Analytics Platform API](https://docs.babelstreet.com/API/en/index-en.html) - [Binding Release Notes](https://github.com/rosette-api/python/wiki/Release-Notes) -- [Rosette Platform Release Notes](https://babelstreet.my.site.com/support/s/article/Rosette-Cloud-Release-Notes) +- [Analytics Platform Release Notes](https://docs.babelstreet.com/Release/en/rosette-cloud.html) - [Support](https://babelstreet.my.site.com/support/s/) - [Binding License: Apache 2.0](https://github.com/rosette-api/python/blob/develop/LICENSE.txt) diff --git a/setup.py b/setup.py index 309ec07..78cb2b2 100755 --- a/setup.py +++ b/setup.py @@ -6,8 +6,8 @@ import rosette NAME = "rosette_api" -DESCRIPTION = "Rosette API Python client SDK" -AUTHOR = "Rosette by Babel Street" +DESCRIPTION = "Babel Street Analytics API Python client SDK" +AUTHOR = "Analytics by Babel Street" AUTHOR_EMAIL = "helpdesk@babelstreet.com" HOMEPAGE = "https://github.com/rosette-api/python" VERSION = rosette.__version__ From a48864d056398d5ad36c9c7ba7a43f99316930ab Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 28 Oct 2024 12:11:08 +0100 Subject: [PATCH 088/106] WS-3314: copyright year --- rosette/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosette/__init__.py b/rosette/__init__.py index 880e295..a1108fd 100644 --- a/rosette/__init__.py +++ b/rosette/__init__.py @@ -1,6 +1,6 @@ """ Python client for the Babel Street Analytics API. -Copyright (c) 2014-2022 Basis Technology Corporation. +Copyright (c) 2014-2024 Basis Technology Corporation. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at From 7c5f72cf150426db6967658e95aa954445e2d59b Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Tue, 29 Oct 2024 16:35:15 +0100 Subject: [PATCH 089/106] WS-3314: update example runner --- examples/run_all.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/run_all.sh b/examples/run_all.sh index 3f18bd7..d29f729 100644 --- a/examples/run_all.sh +++ b/examples/run_all.sh @@ -1,5 +1,11 @@ #!/bin/bash + +OPTS="" +if [ -n "$2" ]; then + OPTS="-u $2" +fi + for f in *.py do - python $f --key $1 + python $f --key $1 "$OPTS" done From 44f9b4815277f01531416d5bbcfb573f0ab3e1f5 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Tue, 29 Oct 2024 17:19:24 +0100 Subject: [PATCH 090/106] WS-3314: update example runner usage info --- examples/run_all.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/run_all.sh b/examples/run_all.sh index d29f729..738516f 100644 --- a/examples/run_all.sh +++ b/examples/run_all.sh @@ -1,5 +1,9 @@ #!/bin/bash +if [ $# -eq 0 ]; then + echo "Usage: $0 API_KEY [ALT_URL]" 1>&2 + exit 1 +fi OPTS="" if [ -n "$2" ]; then OPTS="-u $2" From db7e3a1adb8616d82e30356de68dbf2b9ea511e6 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 4 Nov 2024 11:38:37 +0100 Subject: [PATCH 091/106] WS-3314: fix example runner --- examples/run_all.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/run_all.sh b/examples/run_all.sh index 738516f..ab797c9 100644 --- a/examples/run_all.sh +++ b/examples/run_all.sh @@ -4,12 +4,12 @@ if [ $# -eq 0 ]; then echo "Usage: $0 API_KEY [ALT_URL]" 1>&2 exit 1 fi -OPTS="" -if [ -n "$2" ]; then - OPTS="-u $2" -fi for f in *.py do - python $f --key $1 "$OPTS" + if [ -n "$2" ]; then + python $f --key $1 --url $2 + else + python $f --key $1 + fi done From b8742d0d1ab320fe9e64d80bd57e24c028a3c904 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 4 Nov 2024 14:18:12 +0100 Subject: [PATCH 092/106] WS-3314: update more headers --- rosette/api.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/rosette/api.py b/rosette/api.py index b6fa7af..d999380 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -31,9 +31,12 @@ _APPLICATION_JSON = 'application/json' _BINDING_LANGUAGE = 'python' _BINDING_VERSION = '1.30.0' -_CONCURRENCY_HEADER = 'x-rosetteapi-concurrency' -_CUSTOM_HEADER_PREFIX = 'X-RosetteAPI-' -_CUSTOM_HEADER_PATTERN = re.compile('^' + _CUSTOM_HEADER_PREFIX) +# TODO Remove legacies in future release +_LEGACY_CONCURRENCY_HEADER = 'x-rosetteapi-concurrency' +_CONCURRENCY_HEADER = 'x-babelstreetapi-concurrency' +_LEGACY_CUSTOM_HEADER_PREFIX = 'X-RosetteAPI-' +_CUSTOM_HEADER_PREFIX = "X-BabelStreetAPI-" +_CUSTOM_HEADER_PATTERN = re.compile('^(:?' + _CUSTOM_HEADER_PREFIX + '|' + _LEGACY_CUSTOM_HEADER_PREFIX + ')') _GZIP_BYTEARRAY = bytearray([0x1F, 0x8b, 0x08]) _ISPY3 = sys.version_info[0] == 3 @@ -413,12 +416,15 @@ def __finish_result(self, response, ename): complaint_url = ename + " " + self.suburl raise RosetteException(code, complaint_url + - " : failed to communicate with Analytics", msg) + " : failed to communicate with Babel Street Analytics API", msg) def __set_headers(self): headers = {'Accept': _APPLICATION_JSON, _CUSTOM_HEADER_PREFIX + 'Binding': _BINDING_LANGUAGE, - _CUSTOM_HEADER_PREFIX + 'Binding-Version': _BINDING_VERSION} + _CUSTOM_HEADER_PREFIX + 'Binding-Version': _BINDING_VERSION, + #TODO Remove in future release + _LEGACY_CUSTOM_HEADER_PREFIX + 'Binding': _BINDING_LANGUAGE, + _LEGACY_CUSTOM_HEADER_PREFIX + 'Binding-Version': _BINDING_VERSION} custom_headers = self.api.get_custom_headers() if custom_headers is not None: @@ -427,12 +433,13 @@ def __set_headers(self): headers[key] = custom_headers[key] else: raise RosetteException("badHeader", - "Custom header name must begin with \"" + _CUSTOM_HEADER_PREFIX + "\"", + "Custom header name must begin with \"" + _CUSTOM_HEADER_PREFIX + "\" or \"" + + _LEGACY_CUSTOM_HEADER_PREFIX + "\"", key) self.api.clear_custom_headers() if self.debug: - headers[_CUSTOM_HEADER_PREFIX + 'Devel'] = 'true' + headers[_LEGACY_CUSTOM_HEADER_PREFIX + 'Devel'] = 'true' if self.user_key is not None: headers["X-BabelStreetAPI-Key"] = self.user_key @@ -537,7 +544,7 @@ def call(self, parameters, paramtype=None): _my_loads(rdata, response_headers), status) else: if self.debug: - headers[_CUSTOM_HEADER_PREFIX + 'Devel'] = 'true' + headers[_LEGACY_CUSTOM_HEADER_PREFIX + 'Devel'] = 'true' self.logger.info('operate: ' + url) headers['Accept'] = _APPLICATION_JSON headers['Accept-Encoding'] = "gzip" @@ -584,7 +591,7 @@ def __init__( self.url_parameters = {} self.max_pool_size = 1 self.session = requests.Session() - self.user_agent_string = 'RosetteAPIPython/' + _BINDING_VERSION + '/' + platform.python_version() + self.user_agent_string = 'Babel-Street-Analytics-API-Python/' + _BINDING_VERSION + '/' + platform.python_version() self.morphology_output = { 'LEMMAS': 'lemmas', @@ -646,8 +653,12 @@ def set_pool_size(self, new_pool_size): self.session.mount('http://', adapter) # NOSONAR def __adjust_concurrency(self, dict_headers): - if _CONCURRENCY_HEADER in dict_headers and dict_headers[_CONCURRENCY_HEADER] != self.max_pool_size: - self.set_pool_size(dict_headers[_CONCURRENCY_HEADER]) + if _CONCURRENCY_HEADER in dict_headers: + if dict_headers[_CONCURRENCY_HEADER] != self.max_pool_size: + self.set_pool_size(dict_headers[_CONCURRENCY_HEADER]) + elif _LEGACY_CONCURRENCY_HEADER in dict_headers: + if dict_headers[_LEGACY_CONCURRENCY_HEADER] != self.max_pool_size: + self.set_pool_size(dict_headers[_LEGACY_CONCURRENCY_HEADER]) def _make_request(self, operation, url, data, headers): """ From 22b945fc3579522d39e2dbf6413bcf0a90267b91 Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 4 Nov 2024 14:23:59 +0100 Subject: [PATCH 093/106] WS-3314: update tests with additional headers and remove mocking of the info endpoint --- tests/test_rosette_api.py | 179 +++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 101 deletions(-) diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index 8316b97..81de474 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -38,7 +38,7 @@ @pytest.fixture def json_response(): """ fixture to return info body""" - body = json.dumps({'name': 'Rosette', 'versionChecked': True}) + body = json.dumps({'name': 'Babel Street Analytics', 'versionChecked': True}) return body @@ -120,7 +120,7 @@ def test_url_parameter_clear_single(api): def test_custom_header_props(api): """Test custom header get/set/clear""" - key = 'X-RosetteAPI-Test' + key = 'X-BabelStreetAPI-Test' value = 'foo' api.set_custom_headers(key, value) assert value == api.get_custom_headers()[key] @@ -145,7 +145,7 @@ def test_invalid_header(api): def test_user_agent(api): """ Test user agent """ - value = "RosetteAPIPython/" + api.get_binding_version() + "/" + platform.python_version() + value = "Babel-Street-Analytics-API-Python/" + api.get_binding_version() + "/" + platform.python_version() assert value == api.get_user_agent_string() # Test that pinging the API is working properly @@ -159,7 +159,7 @@ def test_ping(api, json_response): body=json_response, status=200, content_type="application/json") result = api.ping() - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -173,7 +173,7 @@ def test_info(api, json_response): body=json_response, status=200, content_type="application/json") result = api.info() - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -197,7 +197,7 @@ def test_for_409(api, json_409): # Test the max_pool_size -def test_the_max_pool_size(json_response, doc_params): +def test_the_max_pool_size_rosette(json_response, doc_params): """Test max pool size""" httpretty.enable() httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/language", @@ -208,13 +208,50 @@ def test_the_max_pool_size(json_response, doc_params): api = API('bogus_key') assert api.get_pool_size() == 1 result = api.language(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" assert api.get_pool_size() == 5 api.set_pool_size(11) assert api.get_pool_size() == 11 httpretty.disable() httpretty.reset() +def test_the_max_pool_size_babelstreet(json_response, doc_params): + """Test max pool size""" + httpretty.enable() + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/language", + body=json_response, status=200, content_type="application/json", + adding_headers={ + 'x-babelstreetapi-concurrency': 5 + }) + api = API('bogus_key') + assert api.get_pool_size() == 1 + result = api.language(doc_params) + assert result["name"] == "Babel Street Analytics" + assert api.get_pool_size() == 5 + api.set_pool_size(11) + assert api.get_pool_size() == 11 + httpretty.disable() + httpretty.reset() + +def test_the_max_pool_size_bot(json_response, doc_params): + """Test max pool size""" + httpretty.enable() + httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/language", + body=json_response, status=200, content_type="application/json", + adding_headers={ + 'x-rosetteapi-concurrency': 5, + 'x-babelstreetapi-concurrency': 8 + }) + api = API('bogus_key') + assert api.get_pool_size() == 1 + result = api.language(doc_params) + assert result["name"] == "Babel Street Analytics" + assert api.get_pool_size() == 8 + api.set_pool_size(11) + assert api.get_pool_size() == 11 + httpretty.disable() + httpretty.reset() + # Test the language endpoint @@ -225,7 +262,7 @@ def test_the_language_endpoint(api, json_response, doc_params, doc_map): body=json_response, status=200, content_type="application/json") result = api.language(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" with pytest.raises(RosetteException) as e_rosette: result = api.language(doc_map) @@ -244,7 +281,7 @@ def test_the_sentences_endpoint(api, json_response, doc_params, doc_map): body=json_response, status=200, content_type="application/json") result = api.sentences(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" with pytest.raises(RosetteException) as e_rosette: result = api.sentences(doc_map) @@ -265,7 +302,7 @@ def test_the_tokens_endpoint(api, json_response, doc_params): body=json_response, status=200, content_type="application/json") result = api.tokens(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -275,13 +312,11 @@ def test_the_tokens_endpoint(api, json_response, doc_params): def test_the_morphology_complete_endpoint(api, json_response, doc_params): """Test the morphology complete endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/complete", body=json_response, status=200, content_type="application/json") result = api.morphology(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -291,13 +326,11 @@ def test_the_morphology_complete_endpoint(api, json_response, doc_params): def test_the_morphology_lemmas_endpoint(api, json_response, doc_params): """Test the morphology lemmas endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/lemmas", body=json_response, status=200, content_type="application/json") result = api.morphology(doc_params, 'lemmas') - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -307,13 +340,11 @@ def test_the_morphology_lemmas_endpoint(api, json_response, doc_params): def test_the_morphology_parts_of_speech_endpoint(api, json_response, doc_params): """Test the morphology parts-of-speech endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/parts-of-speech", body=json_response, status=200, content_type="application/json") result = api.morphology(doc_params, 'parts-of-speech') - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -323,13 +354,11 @@ def test_the_morphology_parts_of_speech_endpoint(api, json_response, doc_params) def test_the_morphology_compound_components_endpoint(api, json_response, doc_params): """Test the morphology compound-components endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/compound-components", body=json_response, status=200, content_type="application/json") result = api.morphology(doc_params, 'compound-components') - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -339,13 +368,11 @@ def test_the_morphology_compound_components_endpoint(api, json_response, doc_par def test_the_morphology_han_readings_endpoint(api, json_response, doc_params): """Test the morphology han-reading endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/han-readings", body=json_response, status=200, content_type="application/json") result = api.morphology(doc_params, 'han-readings') - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -355,13 +382,11 @@ def test_the_morphology_han_readings_endpoint(api, json_response, doc_params): def test_the_entities_endpoint(api, json_response, doc_params): """Test the entities endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/entities", body=json_response, status=200, content_type="application/json") result = api.entities(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -371,13 +396,11 @@ def test_the_entities_endpoint(api, json_response, doc_params): def test_the_categories_endpoint(api, json_response, doc_params): """Test the categories endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/categories", body=json_response, status=200, content_type="application/json") result = api.categories(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -387,13 +410,11 @@ def test_the_categories_endpoint(api, json_response, doc_params): def test_the_sentiment_endpoint(api, json_response, doc_params): """Test the sentiment endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/sentiment", body=json_response, status=200, content_type="application/json") result = api.sentiment(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -403,8 +424,6 @@ def test_the_sentiment_endpoint(api, json_response, doc_params): def test_the_multipart_operation(api, json_response, doc_params, tmpdir): """Test multipart""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/sentiment", body=json_response, status=200, content_type="application/json") @@ -412,7 +431,7 @@ def test_the_multipart_operation(api, json_response, doc_params, tmpdir): tmp_file.write(json_response) doc_params.load_document_file = tmp_file result = api.sentiment(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -420,8 +439,6 @@ def test_the_multipart_operation(api, json_response, doc_params, tmpdir): def test_incompatible_type(api, json_response): """Test the name translation endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/sentences", body=json_response, status=200, content_type="application/json") @@ -445,8 +462,6 @@ def test_incompatible_type(api, json_response): def test_the_name_translation_endpoint(api, json_response): """Test the name translation endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-translation", body=json_response, status=200, content_type="application/json") @@ -456,7 +471,7 @@ def test_the_name_translation_endpoint(api, json_response): params["targetLanguage"] = "eng" params["targetScript"] = "Latn" result = api.name_translation(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -465,8 +480,6 @@ def test_the_name_translation_endpoint(api, json_response): def test_the_name_requests_with_text(api, json_response): """Test the name similarity with text""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") with pytest.raises(RosetteException) as e_rosette: @@ -496,8 +509,6 @@ def test_the_name_requests_with_text(api, json_response): def test_the_name_similarity_single_parameters(api, json_response): """Test the name similarity parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") @@ -509,7 +520,7 @@ def test_the_name_similarity_single_parameters(api, json_response): params["parameters"] = {"conflictScore": "0.9"} result = api.name_similarity(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -517,8 +528,6 @@ def test_the_name_similarity_single_parameters(api, json_response): def test_the_name_similarity_multiple_parameters(api, json_response): """Test the name similarity parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") @@ -530,7 +539,7 @@ def test_the_name_similarity_multiple_parameters(api, json_response): params["parameters"] = {"conflictScore": "0.9", "deletionScore": "0.5"} result = api.name_similarity(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -538,8 +547,6 @@ def test_the_name_similarity_multiple_parameters(api, json_response): def test_the_name_similarity_endpoint(api, json_response): """Test the name similarity endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") @@ -553,7 +560,7 @@ def test_the_name_similarity_endpoint(api, json_response): params["name2"] = {"text": matched_name_data2, "entityType": "PERSON"} result = api.name_similarity(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -564,8 +571,6 @@ def test_the_name_similarity_endpoint(api, json_response): def test_name_deduplication_parameters(api, json_response): """Test the Name Deduplication Parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-deduplication", body=json_response, status=200, content_type="application/json") @@ -580,7 +585,7 @@ def test_name_deduplication_parameters(api, json_response): params["names"] = ["John Smith", "Johnathon Smith", "Fred Jones"] result = api.name_deduplication(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -589,8 +594,6 @@ def test_name_deduplication_parameters(api, json_response): def test_the_name_deduplication_endpoint(api, json_response): """Test the name deduplication endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-deduplication", body=json_response, status=200, content_type="application/json") @@ -601,7 +604,7 @@ def test_the_name_deduplication_endpoint(api, json_response): params["threshold"] = threshold result = api.name_deduplication(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -611,8 +614,6 @@ def test_the_name_deduplication_endpoint(api, json_response): def test_the_relationships_endpoint(api, json_response): """Test the relationships endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/relationships", body=json_response, status=200, content_type="application/json") @@ -620,7 +621,7 @@ def test_the_relationships_endpoint(api, json_response): params["content"] = "some text data" api.set_option('accuracyMode', 'PRECISION') result = api.relationships(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -631,8 +632,6 @@ def test_for_404(api, json_response): """Test for 404 handling""" httpretty.enable() body = json.dumps({'message': 'not found'}) - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.GET, "https://analytics.babelstreet.com/rest/v1/info", body=body, status=404, content_type="application/json") @@ -650,8 +649,6 @@ def test_for_404(api, json_response): def test_for_content_and_contentUri(api, json_response, doc_params): """Test for content and contentUri in DocumentParameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/entities", body=json_response, status=200, content_type="application/json") @@ -670,8 +667,6 @@ def test_for_content_and_contentUri(api, json_response, doc_params): def test_for_no_content_or_contentUri(api, json_response, doc_params): """Test for missing content and contentUri in DocumentParameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/entities", body=json_response, status=200, content_type="application/json") @@ -688,8 +683,6 @@ def test_for_no_content_or_contentUri(api, json_response, doc_params): def test_for_address_similarity_required_parameters(api, json_response): """Test address similarity parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/address-similarity", body=json_response, status=200, content_type="application/json") @@ -716,7 +709,7 @@ def test_for_address_similarity_required_parameters(api, json_response): params["address2"] = {"text": "160 Pennsilvana Avenue, Washington, D.C., 20500"} result = api.address_similarity(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -724,8 +717,6 @@ def test_for_address_similarity_required_parameters(api, json_response): def test_for_address_similarity_optional_parameters(api, json_response): """Test address similarity parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/address-similarity", body=json_response, status=200, content_type="application/json") @@ -742,7 +733,7 @@ def test_for_address_similarity_optional_parameters(api, json_response): params["parameters"] = {"houseNumberAddressFieldWeight": "0.9"} result = api.address_similarity(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -753,8 +744,6 @@ def test_for_address_similarity_optional_parameters(api, json_response): def test_for_name_similarity_required_parameters(api, json_response): """Test name similarity parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") @@ -781,7 +770,7 @@ def test_for_name_similarity_required_parameters(api, json_response): params["name2"] = {"text": matched_name_data2, "entityType": "PERSON"} result = api.name_similarity(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -791,8 +780,6 @@ def test_for_name_similarity_required_parameters(api, json_response): def test_for_name_translation_required_parameters(api, json_response): """Test name translation parameters""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-translation", body=json_response, status=200, content_type="application/json") @@ -817,7 +804,7 @@ def test_for_name_translation_required_parameters(api, json_response): params["targetLanguage"] = "eng" result = api.name_translation(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -830,7 +817,7 @@ def test_the_semantic_vectors_endpoint(api, json_response, doc_params): body=json_response, status=200, content_type="application/json") result = api.semantic_vectors(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -842,7 +829,7 @@ def test_the_syntax_dependencies_endpoint(api, json_response, doc_params): body=json_response, status=200, content_type="application/json") result = api.syntax_dependencies(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -852,15 +839,13 @@ def test_the_syntax_dependencies_endpoint(api, json_response, doc_params): def test_the_transliteration_endpoint(api, json_response): """Test the transliteration endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/transliteration", body=json_response, status=200, content_type="application/json") params = DocumentParameters() params["content"] = "Some test content" result = api.transliteration(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -870,13 +855,11 @@ def test_the_transliteration_endpoint(api, json_response): def test_the_topics_endpoint(api, json_response, doc_params): """Test the topics endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/topics", body=json_response, status=200, content_type="application/json") result = api.topics(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -891,7 +874,7 @@ def test_the_similar_terms_endpoint(api, json_response, doc_params): api.set_option("resultLanguages", ["spa", "jpn", "deu"]) result = api.similar_terms(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -905,14 +888,12 @@ def test_the_deprecated_endpoints(api, json_response, doc_params): body=json_response, status=200, content_type="application/json") result = api.text_embedding(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() # MATCHED_NAME calls NAME_SIMILARITY httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", body=json_response, status=200, content_type="application/json") @@ -926,14 +907,12 @@ def test_the_deprecated_endpoints(api, json_response, doc_params): name_similarity_params["name2"] = {"text": "迈克尔·杰克逊", "entityType": "PERSON"} result = api.matched_name(name_similarity_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() # TRANSLATED_NAME calls NAME_TRANSLATION httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-translation", body=json_response, status=200, content_type="application/json") @@ -944,7 +923,7 @@ def test_the_deprecated_endpoints(api, json_response, doc_params): name_translation_params["targetLanguage"] = "eng" result = api.translated_name(name_translation_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -955,13 +934,11 @@ def test_the_deprecated_endpoints(api, json_response, doc_params): def test_the_events_endpoint(api, json_response, doc_params): """Test the events endpoint""" httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/events", body=json_response, status=200, content_type="application/json") result = api.events(doc_params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -979,7 +956,7 @@ def test_the_record_similarity_endpoint(api, json_response): params["properties"] = {} params["records"] = {} result = api.record_similarity(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() @@ -1002,6 +979,6 @@ def test_for_record_similarity_required_parameters(api, json_response): params["records"] = {} result = api.record_similarity(params) - assert result["name"] == "Rosette" + assert result["name"] == "Babel Street Analytics" httpretty.disable() httpretty.reset() From 6f818d42a9d71ee6076cd65a28010338973d7e17 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Tue, 5 Nov 2024 18:22:39 -0600 Subject: [PATCH 094/106] WS-3314: Few small tweaks. --- docs/source/index.rst | 2 +- examples/README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 1eac0ca..9436fde 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -6,7 +6,7 @@ Python Binding ========================================== -This is the API documentation for the Babel Street Analytics API Python Binding. For examples and usage, please refer to our `API Guide `_. +This is the API documentation for the Babel Street Analytics API Python Binding. For examples and usage, please refer to our `API Guide `_. .. toctree:: :maxdepth: 2 diff --git a/examples/README.md b/examples/README.md index 74b23a9..80a19b0 100644 --- a/examples/README.md +++ b/examples/README.md @@ -11,7 +11,7 @@ A note on prerequisites. Analytics API only supports TLS 1.2 so ensure your too ``` git clone git@github.com:rosette-api/python.git cd python/examples -virtualenv analytics_venv +python -m venv analytics_venv source analytics_venv/bin/activate pip install rosette_api python ping.py -k $API_KEY @@ -21,7 +21,7 @@ python ping.py -k $API_KEY ``` git clone git@github.com:rosette-api/python.git cd python -virtualenv analytics_venv +python -m venv analytics_venv source analytics_venv/bin/activate python setup.py install cd examples From 1eaf585c1a0f35c847155aeed21cf0bab585b97f Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 11 Nov 2024 13:52:12 +0100 Subject: [PATCH 095/106] no-jira: add fields as required parameter --- rosette/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosette/api.py b/rosette/api.py index d999380..179683a 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -363,7 +363,7 @@ def __init__(self): def validate(self): """Internal. Do not use.""" - for option in ["records"]: # required + for option in ["records","fields"]: # required if self[option] is None: raise RosetteException( "missingParameter", From 170b46fb0cecba45957091903bbf861dd9a2e95f Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Mon, 11 Nov 2024 13:53:40 +0100 Subject: [PATCH 096/106] no-jira: add test case for fields being required --- tests/test_rosette_api.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index 81de474..8429719 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -978,6 +978,11 @@ def test_for_record_similarity_required_parameters(api, json_response): params["records"] = {} + assert e_rosette.value.status == 'missingParameter' + assert e_rosette.value.message == 'Required Record Similarity parameter is missing: fields' + + params["fields"] = {} + result = api.record_similarity(params) assert result["name"] == "Babel Street Analytics" httpretty.disable() From b176a9859a5a096dabfb00bf99ad51e58d970443 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Fri, 15 Nov 2024 13:38:23 -0600 Subject: [PATCH 097/106] NO-JIRA: Call again to generate new status message. --- tests/test_rosette_api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index 8429719..f8252f2 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -978,6 +978,9 @@ def test_for_record_similarity_required_parameters(api, json_response): params["records"] = {} + with pytest.raises(RosetteException) as e_rosette: + api.record_similarity(params) + assert e_rosette.value.status == 'missingParameter' assert e_rosette.value.message == 'Required Record Similarity parameter is missing: fields' From 37df247d3f9c387a6997f225f14b24c79224f492 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Fri, 15 Nov 2024 13:58:27 -0600 Subject: [PATCH 098/106] NO-JIRA: Add Python 3.13 to tests. Drop 3.8. --- CI.Jenkinsfile | 11 ++++++----- docs/README.md | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index 811c36a..f855b8b 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -1,6 +1,6 @@ -def versions = [3.8, 3.9, 3.10, 3.11, 3.12] +def versions = [3.9, 3.10, 3.11, 3.12, 3.13] def runSonnarForPythonVersion(sourceDir, ver){ mySonarOpts="-Dsonar.sources=/source -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}" @@ -15,12 +15,13 @@ def runSonnarForPythonVersion(sourceDir, ver){ // Only run Sonar once. // Check for new versions at https://binaries.sonarsource.com/?prefix=Distribution/sonar-scanner-cli/ - if(ver == 3.12) { + sonarScannerFilename="sonar-scanner-6.2.1.4610-linux-x64" + if(ver == 3.13) { sonarExec="cd /root/ && \ - wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.1.3023-linux.zip && \ - unzip -q sonar-scanner-cli-4.8.1.3023-linux.zip && \ + wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/${sonarScannerFilename}.zip && \ + unzip -q ${sonarScannerFilename}.zip && \ cd /source && \ - /root/sonar-scanner-4.8.1.3023-linux/bin/sonar-scanner ${mySonarOpts}" + /root/${sonarScannerFilename}/bin/sonar-scanner ${mySonarOpts}" } else { sonarExec="echo Skipping Sonar for this version." } diff --git a/docs/README.md b/docs/README.md index 2ca7a5b..b9f2584 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,9 +8,9 @@ Files in the source directory are generally static and should not need to be upd This will overwrite the *.rst files, which may then require some editing to provide the desired look. Edits to date: 1. index.rst: Changed the `Welcome ...` title to `Python Binding` -1. index.rst: Added minor summary, "This is the API documentation for the Rosette API Python Binding. For examples and usage, please refer to our `API Guide `_." +1. index.rst: Added minor summary, "This is the API documentation for the Babel Street Analytics API Python Binding. For examples and usage, please refer to our `API Guide `_." 1. conf.py: removed blank line at end of file -1. conf.py: added rosette logo +1. conf.py: added Babel Street logo 1. conf.py: blank project (let logo handle it) 1. conf.py: added version (auto updated by publish) 1. conf.py: added author From 6a846d9cf90fc2d96926c860d5c5ba50d1ad5ba9 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Fri, 15 Nov 2024 18:00:30 -0600 Subject: [PATCH 099/106] NO-JIRA: Replace httpretty with pook. Some test parameterization. --- tests/test_rosette_api.py | 744 ++++++++++++-------------------------- tests/tox.ini | 2 +- tox.ini | 2 +- 3 files changed, 232 insertions(+), 516 deletions(-) diff --git a/tests/test_rosette_api.py b/tests/test_rosette_api.py index f8252f2..ca8085c 100644 --- a/tests/test_rosette_api.py +++ b/tests/test_rosette_api.py @@ -21,7 +21,7 @@ import json import sys import platform -import httpretty +import pook import pytest from rosette.api import (AddressSimilarityParameters, API, @@ -35,10 +35,15 @@ _ISPY3 = sys.version_info[0] == 3 +def get_base_url(): + return "https://analytics.babelstreet.com/rest/" + + @pytest.fixture def json_response(): """ fixture to return info body""" - body = json.dumps({'name': 'Babel Street Analytics', 'versionChecked': True}) + body = json.dumps({'name': 'Babel Street Analytics', + 'versionChecked': True}) return body @@ -66,20 +71,13 @@ def doc_params(): params['content'] = 'Sample test string' return params + @pytest.fixture def doc_map(): """ fixture for a simple map of doc request """ return {'content': 'Simple test string'} -# Of Note: httpretty provides a short hand decorator, @httpretty.activate, that wraps the decorated -# function with httpretty.enable() and ends it with httpretty.disable(). However, when combined -# with pytest fixtures, the passed in fixture arguments are ignored, resulting in a TypeError. -# Use the old enable/disable to avoid this. - -# Test the option set/get/clear - - def test_option_get_set_clear(api): """Tests the get/set/clear methods""" api.set_option('test', 'foo') @@ -115,8 +113,6 @@ def test_url_parameter_clear_single(api): api.set_url_parameter('test', None) assert api.get_url_parameter('test') is None -# Test the custom header set/get/clear - def test_custom_header_props(api): """Test custom header get/set/clear""" @@ -128,8 +124,6 @@ def test_custom_header_props(api): api.clear_custom_headers() assert len(api.get_custom_headers()) == 0 -# Test for invalid header name - def test_invalid_header(api): """Test for invalid header""" @@ -145,66 +139,53 @@ def test_invalid_header(api): def test_user_agent(api): """ Test user agent """ - value = "Babel-Street-Analytics-API-Python/" + api.get_binding_version() + "/" + platform.python_version() + value = ("Babel-Street-Analytics-API-Python/" + + api.get_binding_version() + "/" + platform.python_version()) assert value == api.get_user_agent_string() -# Test that pinging the API is working properly -# @httpretty.activate - -def test_ping(api, json_response): - """Test ping""" - httpretty.enable() - httpretty.register_uri(httpretty.GET, "https://analytics.babelstreet.com/rest/v1/ping", - body=json_response, status=200, content_type="application/json") +@pook.on +def test_ping_pook(api, json_response): + pook.get(url=get_base_url() + "v1/ping", + response_json=json_response, + reply=200) result = api.ping() assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test that getting the info about the API is being called correctly +@pook.on def test_info(api, json_response): - """Test info""" - httpretty.enable() - httpretty.register_uri(httpretty.GET, "https://analytics.babelstreet.com/rest/v1/info", - body=json_response, status=200, content_type="application/json") + pook.get(url=get_base_url() + "v1/info", + response_json=json_response, + reply=200) result = api.info() assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - - -# Test for 409 +@pook.on def test_for_409(api, json_409): - """Test for 409 handling""" - httpretty.enable() - httpretty.register_uri(httpretty.GET, "https://analytics.babelstreet.com/rest/v1/info", - body=json_409, status=409, content_type="application/json") + pook.get(url=get_base_url() + "v1/info", + response_json=json_409, + reply=409) with pytest.raises(RosetteException) as e_rosette: result = api.info() assert e_rosette.value.status == 'incompatibleClientVersion' - httpretty.disable() - httpretty.reset() -# Test the max_pool_size +@pook.on +@pytest.mark.parametrize("header_key", + ['x-rosetteapi-concurrency', + 'x-babelstreetapi-concurrency']) +def test_the_max_pool_size_header(json_response, doc_params, header_key): + pook.post(url=get_base_url() + "v1/language", + response_json=json_response, + reply=200, + response_headers={header_key: 5}) -def test_the_max_pool_size_rosette(json_response, doc_params): - """Test max pool size""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/language", - body=json_response, status=200, content_type="application/json", - adding_headers={ - 'x-rosetteapi-concurrency': 5 - }) api = API('bogus_key') assert api.get_pool_size() == 1 result = api.language(doc_params) @@ -212,36 +193,16 @@ def test_the_max_pool_size_rosette(json_response, doc_params): assert api.get_pool_size() == 5 api.set_pool_size(11) assert api.get_pool_size() == 11 - httpretty.disable() - httpretty.reset() - -def test_the_max_pool_size_babelstreet(json_response, doc_params): - """Test max pool size""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/language", - body=json_response, status=200, content_type="application/json", - adding_headers={ - 'x-babelstreetapi-concurrency': 5 - }) - api = API('bogus_key') - assert api.get_pool_size() == 1 - result = api.language(doc_params) - assert result["name"] == "Babel Street Analytics" - assert api.get_pool_size() == 5 - api.set_pool_size(11) - assert api.get_pool_size() == 11 - httpretty.disable() - httpretty.reset() - -def test_the_max_pool_size_bot(json_response, doc_params): - """Test max pool size""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/language", - body=json_response, status=200, content_type="application/json", - adding_headers={ - 'x-rosetteapi-concurrency': 5, - 'x-babelstreetapi-concurrency': 8 - }) + + +@pook.on +def test_the_max_pool_size_both(json_response, doc_params): + pook.post(url=get_base_url() + "v1/language", + response_json=json_response, + reply=200, + response_headers={'x-rosetteapi-concurrency': 5, + 'x-babelstreetapi-concurrency': 8}) + api = API('bogus_key') assert api.get_pool_size() == 1 result = api.language(doc_params) @@ -249,198 +210,106 @@ def test_the_max_pool_size_bot(json_response, doc_params): assert api.get_pool_size() == 8 api.set_pool_size(11) assert api.get_pool_size() == 11 - httpretty.disable() - httpretty.reset() -# Test the language endpoint - -def test_the_language_endpoint(api, json_response, doc_params, doc_map): - """Test language endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/language", - body=json_response, status=200, content_type="application/json") - - result = api.language(doc_params) - assert result["name"] == "Babel Street Analytics" +@pook.on +def test_a_doc_endpoint_fails_on_map(api, json_response, doc_map): + pook.post(url=get_base_url() + "v1/language", + response_json=json_response, + reply=200) with pytest.raises(RosetteException) as e_rosette: result = api.language(doc_map) assert e_rosette.value.status == 'incompatible' - httpretty.disable() - httpretty.reset() - -# Test the sentences endpoint - - -def test_the_sentences_endpoint(api, json_response, doc_params, doc_map): - """Test the sentences endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/sentences", - body=json_response, status=200, content_type="application/json") - - result = api.sentences(doc_params) - assert result["name"] == "Babel Street Analytics" - - with pytest.raises(RosetteException) as e_rosette: - result = api.sentences(doc_map) - - assert e_rosette.value.status == 'incompatible' - - - httpretty.disable() - httpretty.reset() - -# Test the tokens endpoint - - -def test_the_tokens_endpoint(api, json_response, doc_params): - """Test the tokens endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/tokens", - body=json_response, status=200, content_type="application/json") - - result = api.tokens(doc_params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the morphology complete endpoint - - -def test_the_morphology_complete_endpoint(api, json_response, doc_params): - """Test the morphology complete endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/complete", - body=json_response, status=200, content_type="application/json") - - result = api.morphology(doc_params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the morphology lemmas endpoint - - -def test_the_morphology_lemmas_endpoint(api, json_response, doc_params): - """Test the morphology lemmas endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/lemmas", - body=json_response, status=200, content_type="application/json") - - result = api.morphology(doc_params, 'lemmas') - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the morphology parts-of-speech endpoint - - -def test_the_morphology_parts_of_speech_endpoint(api, json_response, doc_params): - """Test the morphology parts-of-speech endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/parts-of-speech", - body=json_response, status=200, content_type="application/json") - - result = api.morphology(doc_params, 'parts-of-speech') - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the morphology compound-components endpoint - - -def test_the_morphology_compound_components_endpoint(api, json_response, doc_params): - """Test the morphology compound-components endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/compound-components", - body=json_response, status=200, content_type="application/json") - - result = api.morphology(doc_params, 'compound-components') - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the morphology han-readings endpoint - - -def test_the_morphology_han_readings_endpoint(api, json_response, doc_params): - """Test the morphology han-reading endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/morphology/han-readings", - body=json_response, status=200, content_type="application/json") - - result = api.morphology(doc_params, 'han-readings') - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the entities endpoint - - -def test_the_entities_endpoint(api, json_response, doc_params): - """Test the entities endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/entities", - body=json_response, status=200, content_type="application/json") - - result = api.entities(doc_params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the categories endpoint - - -def test_the_categories_endpoint(api, json_response, doc_params): - """Test the categories endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/categories", - body=json_response, status=200, content_type="application/json") - - result = api.categories(doc_params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the sentiment endpoint - - -def test_the_sentiment_endpoint(api, json_response, doc_params): - """Test the sentiment endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/sentiment", - body=json_response, status=200, content_type="application/json") - - result = api.sentiment(doc_params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the multipart operation - +@pook.on +@pytest.mark.parametrize("endpoint", + ['categories', + 'entities', + 'events', + 'language', + 'morphology/complete', + 'morphology/compound-components', + 'morphology/han-readings', + 'morphology/lemmas', + 'morphology/parts-of-speech', + 'relationships', + 'semantics/similar', + 'semantics/vector', + 'sentences', + 'sentiment', + 'syntax/dependencies', + 'tokens', + 'topics', + 'transliteration']) +def test_document_endpoints(api, json_response, doc_params, endpoint): + pook.post(url=get_base_url() + "v1/" + endpoint, + response_json=json_response, + reply=200) + + # TODO: Convert to match-case when minimum supported version is 3.10 + if endpoint == "categories": + result = api.categories(doc_params) + elif endpoint == "entities": + result = api.entities(doc_params) + elif endpoint == "events": + result = api.events(doc_params) + elif endpoint == "language": + result = api.language(doc_params) + elif endpoint == "morphology/complete": + result = api.morphology(doc_params) + elif endpoint == "morphology/compound-components": + result = api.morphology(doc_params, "compound-components") + elif endpoint == "morphology/han-readings": + result = api.morphology(doc_params, "han-readings") + elif endpoint == "morphology/lemmas": + result = api.morphology(doc_params, "lemmas") + elif endpoint == "morphology/parts-of-speech": + result = api.morphology(doc_params, "parts-of-speech") + elif endpoint == "relationships": + api.set_option('accuracyMode', 'PRECISION') + result = api.relationships(doc_params) + elif endpoint == "semantics/similar": + result = api.similar_terms(doc_params) + elif endpoint == "semantics/vector": + result = api.semantic_vectors(doc_params) + elif endpoint == "sentences": + result = api.sentences(doc_params) + elif endpoint == "sentiment": + result = api.sentiment(doc_params) + elif endpoint == "syntax/dependencies": + result = api.syntax_dependencies(doc_params) + elif endpoint == "tokens": + result = api.tokens(doc_params) + elif endpoint == "topics": + result = api.topics(doc_params) + elif endpoint == "transliteration": + result = api.transliteration(doc_params) + else: + raise Exception("Unknown endpoint.") + + assert result["name"] == "Babel Street Analytics" + + +@pook.on def test_the_multipart_operation(api, json_response, doc_params, tmpdir): - """Test multipart""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/sentiment", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/sentiment", + response_json=json_response, + reply=200) tmp_file = tmpdir.mkdir("sub").join("testfile.txt") tmp_file.write(json_response) doc_params.load_document_file = tmp_file result = api.sentiment(doc_params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() +@pook.on def test_incompatible_type(api, json_response): - """Test the name translation endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/sentences", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/sentences", + response_json=json_response, + reply=200) params = NameTranslationParameters() params["name"] = "some data to translate" @@ -452,18 +321,12 @@ def test_incompatible_type(api, json_response): with pytest.raises(RosetteException) as e_rosette: api.sentences(params) - httpretty.disable() - httpretty.reset() - - -# Test the name translation endpoint - +@pook.on def test_the_name_translation_endpoint(api, json_response): - """Test the name translation endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-translation", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/name-translation", + response_json=json_response, + reply=200) params = NameTranslationParameters() params["name"] = "some data to translate" @@ -472,16 +335,14 @@ def test_the_name_translation_endpoint(api, json_response): params["targetScript"] = "Latn" result = api.name_translation(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() -# Test the name similarity endpoint +@pook.on def test_the_name_requests_with_text(api, json_response): - """Test the name similarity with text""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/name-similarity", + response_json=json_response, + reply=200) + with pytest.raises(RosetteException) as e_rosette: result = api.name_similarity("should fail") assert e_rosette.value.status == 'incompatible' @@ -502,15 +363,12 @@ def test_the_name_requests_with_text(api, json_response): result = api.record_similarity("should fail") assert e_rosette.value.status == 'incompatible' - httpretty.disable() - httpretty.reset() - +@pook.on def test_the_name_similarity_single_parameters(api, json_response): - """Test the name similarity parameters""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/name-similarity", + response_json=json_response, + reply=200) matched_name_data1 = "John Mike Smith" matched_name_data2 = "John Joe Smith" @@ -521,15 +379,13 @@ def test_the_name_similarity_single_parameters(api, json_response): result = api.name_similarity(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() +@pook.on def test_the_name_similarity_multiple_parameters(api, json_response): - """Test the name similarity parameters""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/name-similarity", + response_json=json_response, + reply=200) matched_name_data1 = "John Mike Smith" matched_name_data2 = "John Joe Smith" @@ -540,15 +396,13 @@ def test_the_name_similarity_multiple_parameters(api, json_response): result = api.name_similarity(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() +@pook.on def test_the_name_similarity_endpoint(api, json_response): - """Test the name similarity endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/name-similarity", + response_json=json_response, + reply=200) matched_name_data1 = "Michael Jackson" matched_name_data2 = "迈克尔·杰克逊" @@ -561,18 +415,13 @@ def test_the_name_similarity_endpoint(api, json_response): result = api.name_similarity(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - - -# Test the name deduplication endpoint +@pook.on def test_name_deduplication_parameters(api, json_response): - """Test the Name Deduplication Parameters""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-deduplication", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/name-deduplication", + response_json=json_response, + reply=200) params = NameDeduplicationParameters() @@ -580,22 +429,20 @@ def test_name_deduplication_parameters(api, json_response): api.name_deduplication(params) assert e_rosette.value.status == 'missingParameter' - assert e_rosette.value.message == 'Required Name De-Duplication parameter is missing: names' + assert (e_rosette.value.message == + 'Required Name De-Duplication parameter is missing: names') params["names"] = ["John Smith", "Johnathon Smith", "Fred Jones"] result = api.name_deduplication(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - +@pook.on def test_the_name_deduplication_endpoint(api, json_response): - """Test the name deduplication endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-deduplication", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/name-deduplication", + response_json=json_response, + reply=200) dedup_list = ["John Smith", "Johnathon Smith", "Fred Jones"] threshold = 0.75 @@ -605,86 +452,56 @@ def test_the_name_deduplication_endpoint(api, json_response): result = api.name_deduplication(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the relationships endpoint -def test_the_relationships_endpoint(api, json_response): - """Test the relationships endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/relationships", - body=json_response, status=200, content_type="application/json") - - params = DocumentParameters() - params["content"] = "some text data" - api.set_option('accuracyMode', 'PRECISION') - result = api.relationships(params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test for non 200 - - -def test_for_404(api, json_response): - """Test for 404 handling""" - httpretty.enable() - body = json.dumps({'message': 'not found'}) - httpretty.register_uri(httpretty.GET, "https://analytics.babelstreet.com/rest/v1/info", - body=body, status=404, content_type="application/json") +@pook.on +def test_for_404(api): + pook.get(url=get_base_url() + "v1/info", + response_json={'message': 'not found'}, + reply=404) with pytest.raises(RosetteException) as e_rosette: api.info() assert e_rosette.value.status == 404 assert e_rosette.value.message == 'not found' - httpretty.disable() - httpretty.reset() -# Test for content and contentUri - -def test_for_content_and_contentUri(api, json_response, doc_params): - """Test for content and contentUri in DocumentParameters""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/entities", - body=json_response, status=200, content_type="application/json") +@pook.on +def test_both_content_and_content_uri(api, json_response, doc_params): + pook.post(url=get_base_url() + "v1/entities", + response_json=json_response, + reply=200) doc_params['contentUri'] = 'https://example.com' with pytest.raises(RosetteException) as e_rosette: api.entities(doc_params) assert e_rosette.value.status == 'badArgument' - assert e_rosette.value.message == 'Cannot supply both Content and ContentUri' - httpretty.disable() - httpretty.reset() - -# Test for content and contentUri + assert (e_rosette.value.message == + 'Cannot supply both Content and ContentUri') -def test_for_no_content_or_contentUri(api, json_response, doc_params): - """Test for missing content and contentUri in DocumentParameters""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/entities", - body=json_response, status=200, content_type="application/json") +@pook.on +def test_for_no_content_or_content_uri(api, json_response, doc_params): + pook.post(url=get_base_url() + "v1/entities", + response_json=json_response, + reply=200) doc_params['content'] = None with pytest.raises(RosetteException) as e_rosette: api.entities(doc_params) assert e_rosette.value.status == 'badArgument' - assert e_rosette.value.message == 'Must supply one of Content or ContentUri' - httpretty.disable() - httpretty.reset() + assert (e_rosette.value.message == + 'Must supply one of Content or ContentUri') +@pook.on def test_for_address_similarity_required_parameters(api, json_response): - """Test address similarity parameters""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/address-similarity", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/address-similarity", + response_json=json_response, + reply=200) params = AddressSimilarityParameters() @@ -692,7 +509,8 @@ def test_for_address_similarity_required_parameters(api, json_response): api.address_similarity(params) assert e_rosette.value.status == 'missingParameter' - assert e_rosette.value.message == 'Required Address Similarity parameter is missing: address1' + assert (e_rosette.value.message == + 'Required Address Similarity parameter is missing: address1') params["address1"] = {"houseNumber": "1600", "road": "Pennsylvania Ave NW", @@ -704,21 +522,21 @@ def test_for_address_similarity_required_parameters(api, json_response): api.address_similarity(params) assert e_rosette.value.status == 'missingParameter' - assert e_rosette.value.message == 'Required Address Similarity parameter is missing: address2' + assert (e_rosette.value.message == + 'Required Address Similarity parameter is missing: address2') - params["address2"] = {"text": "160 Pennsilvana Avenue, Washington, D.C., 20500"} + params["address2"] =\ + {"text": "160 Pennsilvana Avenue, Washington, D.C., 20500"} result = api.address_similarity(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() +@pook.on def test_for_address_similarity_optional_parameters(api, json_response): - """Test address similarity parameters""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/address-similarity", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/address-similarity", + response_json=json_response, + reply=200) params = AddressSimilarityParameters() @@ -728,24 +546,20 @@ def test_for_address_similarity_optional_parameters(api, json_response): "state": "DC", "postCode": "20500"} - params["address2"] = {"text": "160 Pennsilvana Avenue, Washington, D.C., 20500"} + params["address2"] =\ + {"text": "160 Pennsilvana Avenue, Washington, D.C., 20500"} params["parameters"] = {"houseNumberAddressFieldWeight": "0.9"} result = api.address_similarity(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - - -# Test for required Name Similarity parameters +@pook.on def test_for_name_similarity_required_parameters(api, json_response): - """Test name similarity parameters""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/name-similarity", + response_json=json_response, + reply=200) matched_name_data1 = "Michael Jackson" matched_name_data2 = "迈克尔·杰克逊" @@ -755,7 +569,8 @@ def test_for_name_similarity_required_parameters(api, json_response): api.name_similarity(params) assert e_rosette.value.status == 'missingParameter' - assert e_rosette.value.message == 'Required Name Similarity parameter is missing: name1' + assert (e_rosette.value.message == + 'Required Name Similarity parameter is missing: name1') params["name1"] = { "text": matched_name_data1, @@ -765,23 +580,20 @@ def test_for_name_similarity_required_parameters(api, json_response): api.name_similarity(params) assert e_rosette.value.status == 'missingParameter' - assert e_rosette.value.message == 'Required Name Similarity parameter is missing: name2' + assert (e_rosette.value.message == + 'Required Name Similarity parameter is missing: name2') params["name2"] = {"text": matched_name_data2, "entityType": "PERSON"} result = api.name_similarity(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test for required Name Translation parameters +@pook.on def test_for_name_translation_required_parameters(api, json_response): - """Test name translation parameters""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-translation", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/name-translation", + response_json=json_response, + reply=200) params = NameTranslationParameters() params["entityType"] = "PERSON" @@ -791,7 +603,8 @@ def test_for_name_translation_required_parameters(api, json_response): api.name_translation(params) assert e_rosette.value.status == 'missingParameter' - assert e_rosette.value.message == 'Required Name Translation parameter is missing: name' + assert (e_rosette.value.message == + 'Required Name Translation parameter is missing: name') params["name"] = "some data to translate" @@ -799,103 +612,29 @@ def test_for_name_translation_required_parameters(api, json_response): api.name_translation(params) assert e_rosette.value.status == 'missingParameter' - assert e_rosette.value.message == 'Required Name Translation parameter is missing: targetLanguage' + assert (e_rosette.value.message == + 'Required Name Translation parameter is missing: targetLanguage') params["targetLanguage"] = "eng" result = api.name_translation(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - - -def test_the_semantic_vectors_endpoint(api, json_response, doc_params): - """Test semantic vectors endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/semantics/vector", - body=json_response, status=200, content_type="application/json") - - result = api.semantic_vectors(doc_params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - - -def test_the_syntax_dependencies_endpoint(api, json_response, doc_params): - """Test syntax dependencies endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/syntax/dependencies", - body=json_response, status=200, content_type="application/json") - - result = api.syntax_dependencies(doc_params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - - -# Test the transliteration endpoint - -def test_the_transliteration_endpoint(api, json_response): - """Test the transliteration endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/transliteration", - body=json_response, status=200, content_type="application/json") - - params = DocumentParameters() - params["content"] = "Some test content" - result = api.transliteration(params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - - -# Test the topics endpoint - -def test_the_topics_endpoint(api, json_response, doc_params): - """Test the topics endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/topics", - body=json_response, status=200, content_type="application/json") - - result = api.topics(doc_params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - - -# Test the similar-terms endpoint - -def test_the_similar_terms_endpoint(api, json_response, doc_params): - """Test the similar terms endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/semantics/similar", - body=json_response, status=200, content_type="application/json") - - api.set_option("resultLanguages", ["spa", "jpn", "deu"]) - result = api.similar_terms(doc_params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - +@pook.on def test_the_deprecated_endpoints(api, json_response, doc_params): - """There are three deprecated endpoints. Exercise them until they are deleted.""" - # TEXT_EMBEDDING calls SEMANTIC_VECTORS - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/semantics/vector", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/semantics/vector", + response_json=json_response, + reply=200) result = api.text_embedding(doc_params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() # MATCHED_NAME calls NAME_SIMILARITY - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-similarity", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/name-similarity", + response_json=json_response, + reply=200) name_similarity_params = NameSimilarityParameters() @@ -904,17 +643,16 @@ def test_the_deprecated_endpoints(api, json_response, doc_params): "language": "eng", "entityType": "PERSON"} - name_similarity_params["name2"] = {"text": "迈克尔·杰克逊", "entityType": "PERSON"} + name_similarity_params["name2"] =\ + {"text": "迈克尔·杰克逊", "entityType": "PERSON"} result = api.matched_name(name_similarity_params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() # TRANSLATED_NAME calls NAME_TRANSLATION - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/name-translation", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/name-translation", + response_json=json_response, + reply=200) name_translation_params = NameTranslationParameters() name_translation_params["entityType"] = "PERSON" @@ -925,31 +663,12 @@ def test_the_deprecated_endpoints(api, json_response, doc_params): result = api.translated_name(name_translation_params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the events endpoint - - -def test_the_events_endpoint(api, json_response, doc_params): - """Test the events endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/events", - body=json_response, status=200, content_type="application/json") - - result = api.events(doc_params) - assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() - -# Test the record similarity endpoint - +@pook.on def test_the_record_similarity_endpoint(api, json_response): - """Test the record similarity endpoint""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/record-similarity", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/record-similarity", + response_json=json_response, + reply=200) params = RecordSimilarityParameters() params["fields"] = {} @@ -957,16 +676,13 @@ def test_the_record_similarity_endpoint(api, json_response): params["records"] = {} result = api.record_similarity(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() -# Tests for required record-similarities parameters +@pook.on def test_for_record_similarity_required_parameters(api, json_response): - """Test record similarity parameters""" - httpretty.enable() - httpretty.register_uri(httpretty.POST, "https://analytics.babelstreet.com/rest/v1/record-similarity", - body=json_response, status=200, content_type="application/json") + pook.post(url=get_base_url() + "v1/record-similarity", + response_json=json_response, + reply=200) params = RecordSimilarityParameters() @@ -974,7 +690,8 @@ def test_for_record_similarity_required_parameters(api, json_response): api.record_similarity(params) assert e_rosette.value.status == 'missingParameter' - assert e_rosette.value.message == 'Required Record Similarity parameter is missing: records' + assert (e_rosette.value.message == + 'Required Record Similarity parameter is missing: records') params["records"] = {} @@ -982,11 +699,10 @@ def test_for_record_similarity_required_parameters(api, json_response): api.record_similarity(params) assert e_rosette.value.status == 'missingParameter' - assert e_rosette.value.message == 'Required Record Similarity parameter is missing: fields' + assert (e_rosette.value.message == + 'Required Record Similarity parameter is missing: fields') params["fields"] = {} result = api.record_similarity(params) assert result["name"] == "Babel Street Analytics" - httpretty.disable() - httpretty.reset() diff --git a/tests/tox.ini b/tests/tox.ini index bdf6e7d..ed9b966 100644 --- a/tests/tox.ini +++ b/tests/tox.ini @@ -7,6 +7,6 @@ commands = pytest -s deps = pytest - httpretty + pook epydoc requests diff --git a/tox.ini b/tox.ini index 808daa0..7f53adf 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ skipsdist = True deps = pytest pep8 - httpretty + pook epydoc requests coverage From 2c4bf420f7ebfe708d4fc77b17348f7a7a5988f7 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Fri, 15 Nov 2024 18:30:14 -0600 Subject: [PATCH 100/106] NO-JIRA: Fix Sonar CLI updates. --- CI.Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile index f855b8b..8704189 100644 --- a/CI.Jenkinsfile +++ b/CI.Jenkinsfile @@ -15,13 +15,13 @@ def runSonnarForPythonVersion(sourceDir, ver){ // Only run Sonar once. // Check for new versions at https://binaries.sonarsource.com/?prefix=Distribution/sonar-scanner-cli/ - sonarScannerFilename="sonar-scanner-6.2.1.4610-linux-x64" + sonarScannerVersion="6.2.1.4610-linux-x64" if(ver == 3.13) { sonarExec="cd /root/ && \ - wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/${sonarScannerFilename}.zip && \ - unzip -q ${sonarScannerFilename}.zip && \ + wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${sonarScannerVersion}.zip && \ + unzip -q sonar-scanner-cli-${sonarScannerVersion}.zip && \ cd /source && \ - /root/${sonarScannerFilename}/bin/sonar-scanner ${mySonarOpts}" + /root/sonar-scanner-${sonarScannerVersion}/bin/sonar-scanner ${mySonarOpts}" } else { sonarExec="echo Skipping Sonar for this version." } From 0dcee40cb2a30403462b0935abd1abbda319f25f Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Fri, 15 Nov 2024 18:41:23 -0600 Subject: [PATCH 101/106] NO-JIRA: package metadata --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 78cb2b2..1bcd653 100755 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ NAME = "rosette_api" DESCRIPTION = "Babel Street Analytics API Python client SDK" AUTHOR = "Analytics by Babel Street" -AUTHOR_EMAIL = "helpdesk@babelstreet.com" +AUTHOR_EMAIL = "analyticssupport@babelstreet.com" HOMEPAGE = "https://github.com/rosette-api/python" VERSION = rosette.__version__ @@ -49,11 +49,11 @@ def read(*filenames, **kwargs): 'Natural Language :: English', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', 'Topic :: Software Development :: Libraries :: Python Modules' ] ) From e80d481919458da6bccb1e5dac26da59c646b09b Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Mon, 18 Nov 2024 19:54:54 +0000 Subject: [PATCH 102/106] Version 1.31.0 --- docs/source/conf.py | 4 ++-- rosette/__init__.py | 2 +- rosette/api.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 5b56fd1..2114fa5 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -55,9 +55,9 @@ # built documents. # # The short X.Y version. -version = '1.30.0' +version = '1.31.0' # The full version, including alpha/beta/rc tags. -release = '1.30.0' +release = '1.31.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/rosette/__init__.py b/rosette/__init__.py index a1108fd..5c89253 100644 --- a/rosette/__init__.py +++ b/rosette/__init__.py @@ -12,4 +12,4 @@ limitations under the License. """ -__version__ = '1.30.0' +__version__ = '1.31.0' diff --git a/rosette/api.py b/rosette/api.py index 179683a..734b4d4 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -30,7 +30,7 @@ _APPLICATION_JSON = 'application/json' _BINDING_LANGUAGE = 'python' -_BINDING_VERSION = '1.30.0' +_BINDING_VERSION = '1.31.0' # TODO Remove legacies in future release _LEGACY_CONCURRENCY_HEADER = 'x-rosetteapi-concurrency' _CONCURRENCY_HEADER = 'x-babelstreetapi-concurrency' From e32db6392003b60c0efad5dd238479681c019ab3 Mon Sep 17 00:00:00 2001 From: seth-mg Date: Fri, 22 Nov 2024 11:45:59 -0600 Subject: [PATCH 103/106] Add default image --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ce08ef..bc34f47 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ - Babel Street Logo + Babel Street Logo From 36fdb337990ad3003426ab9b9230418c37cad3e8 Mon Sep 17 00:00:00 2001 From: Kenny Chen Date: Thu, 12 Dec 2024 17:10:27 -0500 Subject: [PATCH 104/106] NOJIRA: Remove warning filter * This overrode user's warning filters. * This was (arguably) erroneously added to warn users of deprecations. However, DeprecationWarnings are intentionally ignored by default in Python. --- rosette/api.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/rosette/api.py b/rosette/api.py index 734b4d4..9dadf15 100644 --- a/rosette/api.py +++ b/rosette/api.py @@ -24,7 +24,6 @@ import sys import os import re -import warnings import requests import platform @@ -46,8 +45,6 @@ else: _GZIP_SIGNATURE = str(_GZIP_BYTEARRAY) -warnings.simplefilter('always') - class _ReturnObject(object): From ab360fd9de9c175c9d8c89b06adddcac570c0a87 Mon Sep 17 00:00:00 2001 From: Jacob McIntosh Date: Tue, 11 Mar 2025 12:56:26 -0600 Subject: [PATCH 105/106] github url string updates --- DEVELOPER.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DEVELOPER.md b/DEVELOPER.md index 54afffa..dfa4aa0 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -58,7 +58,7 @@ Optional parameters for the `docker run` execution are: - For testing a single example file instead of all the example files. To alter the behavior of the pre-configured Docker environment, you can see the Dockerfile source and entry-point -script [here](https://git.basistech.net/raas/rapid-development-tools/tree/master/binding-dockerfiles). +script [here](https://github.com/RosetteTextAnalytics/rapid-development-tools/tree/master/binding-dockerfiles). ### Documentation Generation The existing README for documentation generation is [here](docs/README.md). @@ -68,7 +68,7 @@ The next time the API documentation is touched, please refresh the README and mi There's an old [Docker README](examples/docker) in the examples directory that might be a candidate for removal. ### Building A Release -See the [instructions](https://git.basistech.net/raas/rapid-development-tools/tree/master/publish) +See the [instructions](https://github.com/RosetteTextAnalytics/rapid-development-tools/tree/master/publish) ### TODOs - Inconsistent references with `rosette_api` and `rosette-api` From 005888457d1d8b978cc52fb9e482ac0a872a71ec Mon Sep 17 00:00:00 2001 From: Adam Soos Date: Fri, 12 Dec 2025 15:21:33 +0100 Subject: [PATCH 106/106] WS_3698: update record-similarity example with new field types --- examples/record_similarity.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/examples/record_similarity.py b/examples/record_similarity.py index 0ef1ea7..a2c1fe2 100644 --- a/examples/record_similarity.py +++ b/examples/record_similarity.py @@ -31,6 +31,18 @@ def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): "dob2": { "type": "rni_date", "weight": 0.1 + }, + "jobTitle": { + "type": "rni_string", + "weight": 0.2 + }, + "age": { + "type": "rni_number", + "weight": 0.4 + }, + "isRetired": { + "type": "rni_boolean", + "weight": 0.05 } } properties = { @@ -52,7 +64,8 @@ def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): "dob2": { "date": "04161993", "format": "MMddyyyy" - } + }, + "jobTitle": "software engineer" }, { "dob": { @@ -60,7 +73,9 @@ def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): }, "primaryName": { "text": "Evan R" - } + }, + "age": 47, + "isRetired": False } ], "right": [ @@ -71,7 +86,9 @@ def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): "primaryName": { "text": "Seth R", "language": "eng" - } + }, + "jobTitle": "manager", + "isRetired": True }, { "primaryName": "Ivan R", @@ -84,7 +101,9 @@ def run(key, alt_url='https://analytics.babelstreet.com/rest/v1/'): }, "dob2": { "date": "1993/04/16" - } + }, + "age": 72, + "isRetired": True } ] }