final URI extractivServerURI;
try {
extractivServerURI = new URI(API_URL);
} catch (URISyntaxException e) {
throw new AnnotationException(e);
}
final HttpMethodBase extractivRequest;
File tmp = null;
try {
tmp = File.createTempFile("tmpText", ".txt");
FileWriter fileWriter = new FileWriter(tmp);
fileWriter.write(text.text());
fileWriter.close();
extractivRequest = getExtractivProcessFileRequest(extractivServerURI, tmp);
} catch (IOException e) {
throw new AnnotationException("Could not create request for Extractiv API.");
}
final String extractivResults = request(extractivRequest);
JSONObject resultsJSON = null;
JSONArray entities = null;
try {
resultsJSON = new JSONObject(extractivResults);
entities = resultsJSON.getJSONArray("entities");
} catch (JSONException e) {
throw new AnnotationException("Received invalid response from Extractiv API.");
}
for (int i = 0; i < entities.length(); i++) {
try {
JSONObject entity = (JSONObject) entities.get(i);