-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
230 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- 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) | ||
|
||
events_text_data = "I am looking for flights to Super Bowl 2022 in Inglewood, LA." | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ | |
limitations under the License. | ||
""" | ||
|
||
__version__ = '1.25.1' | ||
__version__ = '1.28.0' |
Oops, something went wrong.