Skip to content

Commit 1cde636

Browse files
committed
Unified entities and entities/linked
1 parent fc91caa commit 1cde636

File tree

4 files changed

+4
-55
lines changed

4 files changed

+4
-55
lines changed

examples/entities.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def run(key, altUrl='https://api.rosette.com/rest/v1/'):
1717
entities_text_data = "Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS"
1818
params = DocumentParameters()
1919
params["content"] = entities_text_data
20+
# to improve performance, and if you don't need the QID, set this option
21+
# api.setOption("linkEntities", False)
2022
return api.entities(params) # entity linking is turned off
2123

2224
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint')

examples/entities_linked.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

rosette/api.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -692,22 +692,16 @@ def morphology(self, parameters, facet=MorphologyOutput.COMPLETE):
692692
@return: A python dictionary containing the results of morphological analysis."""
693693
return EndpointCaller(self, "morphology/" + facet).call(parameters)
694694

695-
def entities(self, parameters, resolve_entities=False):
695+
def entities(self, parameters):
696696
"""
697697
Create an L{EndpointCaller} to identify named entities found in the texts
698698
to which it is applied and call it. Linked entity information is optional, and
699699
its need must be specified at the time the operator is created.
700700
@param parameters: An object specifying the data,
701701
and possible metadata, to be processed by the entity identifier.
702702
@type parameters: L{DocumentParameters} or L{str}
703-
@param resolve_entities: Specifies whether or not linked entity information will
704-
be wanted.
705-
@type resolve_entities: Boolean
706703
@return: A python dictionary containing the results of entity extraction."""
707-
if resolve_entities:
708-
return EndpointCaller(self, "entities/linked").call(parameters)
709-
else:
710-
return EndpointCaller(self, "entities").call(parameters)
704+
return EndpointCaller(self, "entities").call(parameters)
711705

712706
def categories(self, parameters):
713707
"""

tests/test_rosette_api.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -261,21 +261,6 @@ def test_the_entities_endpoint(api, json_response, doc_params):
261261
httpretty.disable()
262262
httpretty.reset()
263263

264-
# Test the entities/linked endpoint
265-
266-
267-
def test_the_entities_linked_endpoint(api, json_response, doc_params):
268-
httpretty.enable()
269-
httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info",
270-
body=json_response, status=200, content_type="application/json")
271-
httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/entities/linked",
272-
body=json_response, status=200, content_type="application/json")
273-
274-
result = api.entities(doc_params, True)
275-
assert result["name"] == "Rosette API"
276-
httpretty.disable()
277-
httpretty.reset()
278-
279264
# Test the categories endpoint
280265

281266

0 commit comments

Comments
 (0)