Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions rosette/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import json
import logging
import sys
import pprint
import time
from socket import gethostbyname, gaierror
from datetime import datetime
Expand Down Expand Up @@ -538,7 +537,7 @@ def call(self, parameters):
Passes data and metadata specified by C{parameters} to the server
endpoint to which this L{EndpointCaller} object is bound. For all
endpoints except C{translated_name} and C{matched_name}, it must be a L{DocumentParameters}
object; for C{translated_name}, it must be an L{NameTranslationParameters} object;
object or a string; for C{translated_name}, it must be an L{NameTranslationParameters} object;
for C{matched_name}, it must be an L{NameMatchingParameters} object.

In all cases, the result is returned as a python dictionary
Expand All @@ -548,10 +547,19 @@ 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{translated_name}, L{NameTranslationParameters}, otherwise L{DocumentParameters}
@type parameters: For C{translated_name}, L{NameTranslationParameters}, otherwise L{DocumentParameters} or L{str}
@return: A python dictionary expressing the result of the invocation.
"""

if not isinstance(parameters, _DocumentParamSetBase):
if self.suburl != "matched-name" and self.suburl != "translated-name":
text = parameters
parameters = DocumentParameters()
parameters['content'] = text
else:
raise RosetteException("incompatible", "Text-only input only works for DocumentParameter endpoints",
self.suburl)

self.checker()

if self.useMultipart and (parameters['contentType'] != DataFormat.SIMPLE):
Expand Down Expand Up @@ -641,7 +649,7 @@ def language(self, parameters):
Create an L{EndpointCaller} for language identification and call it.
@param parameters: An object specifying the data,
and possible metadata, to be processed by the language identifier.
@type parameters: L{DocumentParameters}
@type parameters: L{DocumentParameters} or L{str}
@return: A python dictionary containing the results of language
identification."""
return EndpointCaller(self, "language").call(parameters)
Expand All @@ -651,7 +659,7 @@ def sentences(self, parameters):
Create an L{EndpointCaller} to break a text into sentences and call it.
@param parameters: An object specifying the data,
and possible metadata, to be processed by the sentence identifier.
@type parameters: L{DocumentParameters}
@type parameters: L{DocumentParameters} or L{str}
@return: A python dictionary containing the results of sentence identification."""
return EndpointCaller(self, "sentences").call(parameters)

Expand All @@ -660,7 +668,7 @@ def tokens(self, parameters):
Create an L{EndpointCaller} to break a text into tokens and call it.
@param parameters: An object specifying the data,
and possible metadata, to be processed by the tokens identifier.
@type parameters: L{DocumentParameters}
@type parameters: L{DocumentParameters} or L{str}
@return: A python dictionary containing the results of tokenization."""
return EndpointCaller(self, "tokens").call(parameters)

Expand All @@ -670,7 +678,7 @@ def morphology(self, parameters, facet=MorphologyOutput.COMPLETE):
of the morphological analyses of texts to which it is applied and call it.
@param parameters: An object specifying the data,
and possible metadata, to be processed by the morphology analyzer.
@type parameters: L{DocumentParameters}
@type parameters: L{DocumentParameters} or L{str}
@param facet: The facet desired, to be returned by the created L{EndpointCaller}.
@type facet: An element of L{MorphologyOutput}.
@return: A python dictionary containing the results of morphological analysis."""
Expand All @@ -681,12 +689,12 @@ def entities(self, parameters, linked=False):
Create an L{EndpointCaller} to identify named entities found in the texts
to which it is applied and call it. Linked entity information is optional, and
its need must be specified at the time the operator is created.
@param parameters: An object specifying the data,
and possible metadata, to be processed by the entity identifier.
@type parameters: L{DocumentParameters} or L{str}
@param linked: Specifies whether or not linked entity information will
be wanted.
@type linked: Boolean
@param parameters: An object specifying the data,
and possible metadata, to be processed by the entity identifier.
@type parameters: L{DocumentParameters}
@return: A python dictionary containing the results of entity extraction."""
if linked:
return EndpointCaller(self, "entities/linked").call(parameters)
Expand All @@ -699,7 +707,7 @@ def categories(self, parameters):
it is applied and call it.
@param parameters: An object specifying the data,
and possible metadata, to be processed by the category identifier.
@type parameters: L{DocumentParameters}
@type parameters: L{DocumentParameters} or L{str}
@return: A python dictionary containing the results of categorization."""
return EndpointCaller(self, "categories").call(parameters)

Expand All @@ -709,7 +717,7 @@ def sentiment(self, parameters):
which it is applied and call it.
@param parameters: An object specifying the data,
and possible metadata, to be processed by the sentiment identifier.
@type parameters: L{DocumentParameters}
@type parameters: L{DocumentParameters} or L{str}
@return: A python dictionary containing the results of sentiment identification."""
"""Create an L{EndpointCaller} to identify sentiments of the texts
to which is applied.
Expand Down
Loading