2323import json
2424import logging
2525import sys
26- import pprint
2726import time
2827from socket import gethostbyname , gaierror
2928from datetime import datetime
@@ -538,7 +537,7 @@ def call(self, parameters):
538537 Passes data and metadata specified by C{parameters} to the server
539538 endpoint to which this L{EndpointCaller} object is bound. For all
540539 endpoints except C{translated_name} and C{matched_name}, it must be a L{DocumentParameters}
541- object; for C{translated_name}, it must be an L{NameTranslationParameters} object;
540+ object or a string ; for C{translated_name}, it must be an L{NameTranslationParameters} object;
542541 for C{matched_name}, it must be an L{NameMatchingParameters} object.
543542
544543 In all cases, the result is returned as a python dictionary
@@ -548,10 +547,19 @@ def call(self, parameters):
548547 @param parameters: An object specifying the data,
549548 and possible metadata, to be processed by the endpoint. See the
550549 details for those object types.
551- @type parameters: For C{translated_name}, L{NameTranslationParameters}, otherwise L{DocumentParameters}
550+ @type parameters: For C{translated_name}, L{NameTranslationParameters}, otherwise L{DocumentParameters} or L{str}
552551 @return: A python dictionary expressing the result of the invocation.
553552 """
554553
554+ if not isinstance (parameters , _DocumentParamSetBase ):
555+ if self .suburl != "matched-name" and self .suburl != "translated-name" :
556+ text = parameters
557+ parameters = DocumentParameters ()
558+ parameters ['content' ] = text
559+ else :
560+ raise RosetteException ("incompatible" , "Text-only input only works for DocumentParameter endpoints" ,
561+ self .suburl )
562+
555563 self .checker ()
556564
557565 if self .useMultipart and (parameters ['contentType' ] != DataFormat .SIMPLE ):
@@ -641,7 +649,7 @@ def language(self, parameters):
641649 Create an L{EndpointCaller} for language identification and call it.
642650 @param parameters: An object specifying the data,
643651 and possible metadata, to be processed by the language identifier.
644- @type parameters: L{DocumentParameters}
652+ @type parameters: L{DocumentParameters} or L{str}
645653 @return: A python dictionary containing the results of language
646654 identification."""
647655 return EndpointCaller (self , "language" ).call (parameters )
@@ -651,7 +659,7 @@ def sentences(self, parameters):
651659 Create an L{EndpointCaller} to break a text into sentences and call it.
652660 @param parameters: An object specifying the data,
653661 and possible metadata, to be processed by the sentence identifier.
654- @type parameters: L{DocumentParameters}
662+ @type parameters: L{DocumentParameters} or L{str}
655663 @return: A python dictionary containing the results of sentence identification."""
656664 return EndpointCaller (self , "sentences" ).call (parameters )
657665
@@ -660,7 +668,7 @@ def tokens(self, parameters):
660668 Create an L{EndpointCaller} to break a text into tokens and call it.
661669 @param parameters: An object specifying the data,
662670 and possible metadata, to be processed by the tokens identifier.
663- @type parameters: L{DocumentParameters}
671+ @type parameters: L{DocumentParameters} or L{str}
664672 @return: A python dictionary containing the results of tokenization."""
665673 return EndpointCaller (self , "tokens" ).call (parameters )
666674
@@ -670,7 +678,7 @@ def morphology(self, parameters, facet=MorphologyOutput.COMPLETE):
670678 of the morphological analyses of texts to which it is applied and call it.
671679 @param parameters: An object specifying the data,
672680 and possible metadata, to be processed by the morphology analyzer.
673- @type parameters: L{DocumentParameters}
681+ @type parameters: L{DocumentParameters} or L{str}
674682 @param facet: The facet desired, to be returned by the created L{EndpointCaller}.
675683 @type facet: An element of L{MorphologyOutput}.
676684 @return: A python dictionary containing the results of morphological analysis."""
@@ -681,12 +689,12 @@ def entities(self, parameters, linked=False):
681689 Create an L{EndpointCaller} to identify named entities found in the texts
682690 to which it is applied and call it. Linked entity information is optional, and
683691 its need must be specified at the time the operator is created.
692+ @param parameters: An object specifying the data,
693+ and possible metadata, to be processed by the entity identifier.
694+ @type parameters: L{DocumentParameters} or L{str}
684695 @param linked: Specifies whether or not linked entity information will
685696 be wanted.
686697 @type linked: Boolean
687- @param parameters: An object specifying the data,
688- and possible metadata, to be processed by the entity identifier.
689- @type parameters: L{DocumentParameters}
690698 @return: A python dictionary containing the results of entity extraction."""
691699 if linked :
692700 return EndpointCaller (self , "entities/linked" ).call (parameters )
@@ -699,7 +707,7 @@ def categories(self, parameters):
699707 it is applied and call it.
700708 @param parameters: An object specifying the data,
701709 and possible metadata, to be processed by the category identifier.
702- @type parameters: L{DocumentParameters}
710+ @type parameters: L{DocumentParameters} or L{str}
703711 @return: A python dictionary containing the results of categorization."""
704712 return EndpointCaller (self , "categories" ).call (parameters )
705713
@@ -709,7 +717,7 @@ def sentiment(self, parameters):
709717 which it is applied and call it.
710718 @param parameters: An object specifying the data,
711719 and possible metadata, to be processed by the sentiment identifier.
712- @type parameters: L{DocumentParameters}
720+ @type parameters: L{DocumentParameters} or L{str}
713721 @return: A python dictionary containing the results of sentiment identification."""
714722 """Create an L{EndpointCaller} to identify sentiments of the texts
715723 to which is applied.
0 commit comments