diff --git a/nifi-stanfordcorenlp-processors/src/main/java/com/iss/nifi/processors/stanfordcorenlp/StanfordCoreNLPService.java b/nifi-stanfordcorenlp-processors/src/main/java/com/iss/nifi/processors/stanfordcorenlp/StanfordCoreNLPService.java index a030909..2848051 100644 --- a/nifi-stanfordcorenlp-processors/src/main/java/com/iss/nifi/processors/stanfordcorenlp/StanfordCoreNLPService.java +++ b/nifi-stanfordcorenlp-processors/src/main/java/com/iss/nifi/processors/stanfordcorenlp/StanfordCoreNLPService.java @@ -98,31 +98,27 @@ public Map> extractEntities(String text, String entityTypes } CoreDocument document = annotateDocument(text); - try { - List mentions = document.entityMentions(); - if (document.entityMentions() == null) { - mentions = new ArrayList(); - } - for (CoreEntityMention entityMention : mentions) { - String eType = entityMention.entityType(); - if (extractLocations && locationNerTagList.contains(eType)) { - List locs = output.get("location"); - locs.add(entityMention.text()); - output.put("location", locs); - continue; - } - if (nerTagList.contains(eType)) { - List e = output.get(eType.toLowerCase()); - e.add(entityMention.text()); - output.put(eType.toLowerCase(), e); - } - } + List mentions = document.entityMentions(); + if (document.entityMentions() == null) { + mentions = new ArrayList(); + } - return output; - } catch (Exception e) { - System.out.println("Exception while finding mentions: " + e); + for (CoreEntityMention entityMention : mentions) { + String eType = entityMention.entityType(); + if (extractLocations && locationNerTagList.contains(eType)) { + List locs = output.get("location"); + locs.add(entityMention.text()); + output.put("location", locs); + continue; + } + if (nerTagList.contains(eType)) { + List e = output.get(eType.toLowerCase()); + e.add(entityMention.text()); + output.put(eType.toLowerCase(), e); + } } + return output; }