Class PredictAPIUtil


  • public class PredictAPIUtil
    extends Object
    Helper methods for working with the POST /v1beta1/{model_name}:predict endpoint.
    • Field Detail

      • CONTENT_CHAR_LIMIT

        public static final int CONTENT_CHAR_LIMIT
        The maximum number of characters that can be translated in a single call to the predict endpoint.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PredictAPIUtil

        public PredictAPIUtil()
    • Method Detail

      • getPredictRequests

        public List<org.json.simple.JSONObject> getPredictRequests​(String sourceText)
        Given source text of any length, constructs one or more JSONs that can be used as request bodies for the predict endpoint.
      • extractTranslation

        public String extractTranslation​(InputStream is)
                                  throws org.json.simple.parser.ParseException
        Extracts the translation from a stream containing the response body data.
        Throws:
        org.json.simple.parser.ParseException