Skip to content

Commit 1cb3713

Browse files
Merge pull request #107 from rosette-api/RCB-601-events-endpoint
RCB-601 new: events endpoint
2 parents a940bdc + fbf0c65 commit 1cb3713

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

rosette/api.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,8 @@ def __init__(
589589
'TEXT_EMBEDDING': 'semantics/vector',
590590
'TOKENS': 'tokens',
591591
'TOPICS': 'topics',
592-
'TRANSLITERATION': 'transliteration'
592+
'TRANSLITERATION': 'transliteration',
593+
'EVENTS': 'events'
593594
}
594595

595596
def __del__(self):
@@ -1010,3 +1011,13 @@ def similar_terms(self, parameters):
10101011
:return: A python dictionary containing the similar terms and their similarity
10111012
"""
10121013
return EndpointCaller(self, self.endpoints['SIMILAR_TERMS']).call(parameters)
1014+
1015+
def events(self, parameters):
1016+
"""
1017+
Create an L{EndpointCaller} to identify events found in the texts.
1018+
@param parameters: An object specifying the data,
1019+
and possible metadata, to be processed by the 'events' identifier.
1020+
@type parameters: L{DocumentParameters} or L{str}
1021+
@return: A python dictionary containing the results of event extraction.
1022+
"""
1023+
return EndpointCaller(self, self.endpoints['EVENTS']).call(parameters)

tests/test_rosette_api.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,3 +882,19 @@ def test_the_deprecated_endpoints(api, json_response, doc_params):
882882

883883
httpretty.disable()
884884
httpretty.reset()
885+
886+
# Test the events endpoint
887+
888+
889+
def test_the_events_endpoint(api, json_response, doc_params):
890+
"""Test the events endpoint"""
891+
httpretty.enable()
892+
httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info",
893+
body=json_response, status=200, content_type="application/json")
894+
httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/events",
895+
body=json_response, status=200, content_type="application/json")
896+
897+
result = api.events(doc_params)
898+
assert result["name"] == "Rosette"
899+
httpretty.disable()
900+
httpretty.reset()

0 commit comments

Comments
 (0)