in source/src/main/java/com/amazonaws/comprehend/esproxy/lambda/processor/operations/DetectKeyPhrases.java [65:91]
public BatchResponse sendBatchRequest(@NonNull final List<BatchFieldLocator> fieldLocatorList,
@NonNull final List<String> contentList,
@NonNull final LanguageCode languageCode,
@NonNull final AmazonComprehend comprehendClient) {
BatchDetectKeyPhrasesRequest request
= new BatchDetectKeyPhrasesRequest().withTextList(contentList).withLanguageCode(languageCode.toString());
BatchDetectKeyPhrasesResult batchDetectKeyPhrasesResult = comprehendClient.batchDetectKeyPhrases(request);
List<JSONObject> copiedKeyPhrasesList = new ArrayList<>();
// Copy KeyPhrases result
for (BatchDetectKeyPhrasesItemResult resultItem : batchDetectKeyPhrasesResult.getResultList()) {
// Parse List<KeyPhrase> to List<JSONObject>
List<JSONObject> keyPhraseJsonList = resultItem.getKeyPhrases()
.stream().map(JSONObject::new).collect(Collectors.toList());
try {
// Add the index key and JSONObject list to the copied list
copiedKeyPhrasesList.add(new JSONObject().put(Constants.KEYPHRASES_KEY_NAME, keyPhraseJsonList));
} catch (JSONException e) {
copiedKeyPhrasesList.add(null);
}
}
return new BatchResponse<>(
fieldLocatorList,
batchDetectKeyPhrasesResult.getResultList(),
batchDetectKeyPhrasesResult.getErrorList(), copiedKeyPhrasesList);
}