Class TppHelper
java.lang.Object
es.uvigo.esei.sing.textproc.abstracttppstep.TppHelper
final class TppHelper extends java.lang.Object
Contains common logic to text processing steps that involve calling the Text
Processing Python web service, or any compatible web service.
- Author:
- Alejandro González García
-
Constructor Summary
Constructors Constructor Description TppHelper()
-
Method Summary
Modifier and Type Method Description static java.util.List<java.util.Map<java.lang.String,java.lang.String>>
processAttributes(@NonNull java.util.List<java.lang.String[]> attributesBatch, int startIndex, @NonNull java.lang.String[] attributeNames, @NonNull javax.ws.rs.client.WebTarget target, @NonNull AbstractProcessingStep.ProcessingConsumer<? super javax.json.stream.JsonGenerator> requestParametersAction, @NonNull JsonResponseAttributeType responseAttributeType, @NonNull ProcessingBiConsumer<? super java.util.Map.Entry<java.lang.String,javax.json.JsonObject>,? super java.util.Map<java.lang.String,java.lang.String>> storeProcessedAttributeAction)
Processes the batch of attributes contained in the specified list, each attribute identified by a name, by sending an appropriate POST HTTP request to Text Processing Python, and parsing the resulting JSON response.
-
Constructor Details
-
Method Details
-
processAttributes
public static java.util.List<java.util.Map<java.lang.String,java.lang.String>> processAttributes(@NonNull @NonNull java.util.List<java.lang.String[]> attributesBatch, int startIndex, @NonNull @NonNull java.lang.String[] attributeNames, @NonNull @NonNull javax.ws.rs.client.WebTarget target, @NonNull @NonNull AbstractProcessingStep.ProcessingConsumer<? super javax.json.stream.JsonGenerator> requestParametersAction, @NonNull @NonNull JsonResponseAttributeType responseAttributeType, @NonNull @NonNull ProcessingBiConsumer<? super java.util.Map.Entry<java.lang.String,javax.json.JsonObject>,? super java.util.Map<java.lang.String,java.lang.String>> storeProcessedAttributeAction) throws ProcessingExceptionProcesses the batch of attributes contained in the specified list, each attribute identified by a name, by sending an appropriate POST HTTP request to Text Processing Python, and parsing the resulting JSON response. The resulting list contains maps of attribute names with their processed versions, in the same order as the input documents in the batch.- Parameters:
attributesBatch
- The batch of attribute values, as directly read from the DB. It must have at least one element. By convention, the first attribute value for each element is its primary key.startIndex
- The start index from where actual attributes will be read fromattributes
, inclusive.attributeNames
- The attribute names. This array length must be equal toattributes - startIndex
.target
- The web service endpoint to send the POST HTTP request to.requestParametersAction
- The action to execute to populate the request object with parameters, after the documents object.responseAttributeType
- The expected type of the processed text in the response.storeProcessedAttributeAction
- An action that receives the JSON document object of the response, and is expected to put its processed form in the provided map.- Returns:
- The described list. The values of this list and its maps are not
null
. This list is not modifiable. - Throws:
ProcessingException
- If some exception occurs during the operation.java.lang.IllegalArgumentException
- If some parameter isnull
or invalid.
-