in source/src/main/java/com/amazonaws/comprehend/esproxy/lambda/processor/operations/DetectSyntax.java [90:106]
private static JSONObject flattenSyntaxList(@NonNull final List<SyntaxToken> syntaxList) {
JSONObject flattenedSyntaxObject = new JSONObject();
for (SyntaxToken syntax : syntaxList) {
try {
// If the syntax type exists, add the new syntax to the JSONArray, otherwise create a new JSONObject
if (flattenedSyntaxObject.has(syntax.getPartOfSpeech().getTag())) {
flattenedSyntaxObject.getJSONArray(syntax.getPartOfSpeech().getTag()).put(new JSONObject(syntax));
} else {
flattenedSyntaxObject.put(syntax.getPartOfSpeech().getTag(),
Collections.singletonList((new JSONObject(syntax))));
}
} catch (JSONException e) {
return null;
}
}
return flattenedSyntaxObject;
}