From a9888c1679bf40776e9c12d7f4015d4d04c77496 Mon Sep 17 00:00:00 2001 From: jenz Date: Tue, 14 Feb 2023 12:29:40 +0100 Subject: [PATCH] annotate function causes crash sometimes to just exception handling it --- .../src/main/java/FunctionLayer/Datahandler.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java b/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java index dd99bd10..0d53dff2 100644 --- a/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java +++ b/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java @@ -198,11 +198,15 @@ public class Datahandler { private void createStrAnnotation(String str, StanfordCoreNLP stanfordCoreNLP, Boolean sentimentBool) { Annotation strAnno2 = new Annotation(str); strAnno2.compact(); - stanfordCoreNLP.annotate(strAnno2); - if (sentimentBool) { - pipelineSentimentAnnotationCache.put(str, strAnno2); - } else { - pipelineAnnotationCache.put(str, strAnno2); + try { + stanfordCoreNLP.annotate(strAnno2); + if (sentimentBool) { + pipelineSentimentAnnotationCache.put(str, strAnno2); + } else { + pipelineAnnotationCache.put(str, strAnno2); + } + } catch (Exception e) { + System.out.println("stanfordcorenlp annotate failed" + e.getMessage()); } }