From 8a510bbda347790d180937d953c7ae096b5c4fc0 Mon Sep 17 00:00:00 2001 From: Ervin Papp Date: Tue, 27 Jun 2023 12:13:48 +0200 Subject: [PATCH 1/2] 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 4a35e54b3dcfabe392d6cce9c00a7a44e313e490 Mon Sep 17 00:00:00 2001 From: seth-mg Date: Mon, 21 Aug 2023 10:24:19 -0500 Subject: [PATCH 2/2] 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