added lemma nullchecks to avoid nullpointers
This commit is contained in:
parent
e32f515b3d
commit
7981416183
@ -887,7 +887,7 @@ public class SentimentAnalyzerTest {
|
||||
if (sentenceConstituencyParse2 != null && !sentenceConstituencyParse2.isEmpty()) {
|
||||
for (CoreLabel LBW : sentenceConstituencyParse1.taggedLabeledYield()) {
|
||||
for (CoreLabel LBW1 : sentenceConstituencyParse2.taggedLabeledYield()) {
|
||||
if (LBW.lemma().equals(LBW1.lemma())) {
|
||||
if (LBW.lemma() != null && LBW1.lemma() != null && LBW.lemma().equals(LBW1.lemma())) {
|
||||
boolean found = false;
|
||||
for (String str : filerTreeContent) {
|
||||
if (str.equals(LBW.lemma())) {
|
||||
@ -895,7 +895,7 @@ public class SentimentAnalyzerTest {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
if (!found && LBW.lemma() != null) {
|
||||
filerTreeContent.add(LBW.lemma());
|
||||
runCount1++;
|
||||
}
|
||||
@ -2151,9 +2151,11 @@ public class SentimentAnalyzerTest {
|
||||
for (CoreLabel token : tokensSentiment) {
|
||||
Set<?> stopWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
|
||||
Set<?> stopWordsCustom = StopwordAnnotator.getStopWordList(customStopWordList, true);
|
||||
String lemma = token.lemma().toLowerCase();
|
||||
if (stopWords.contains(lemma) || stopWordsCustom.contains(lemma)) {
|
||||
arrs.add(lemma);
|
||||
if (token.lemma() != null) {
|
||||
String lemma = token.lemma().toLowerCase();
|
||||
if (stopWords.contains(lemma) || stopWordsCustom.contains(lemma)) {
|
||||
arrs.add(lemma);
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrs;
|
||||
|
Loading…
Reference in New Issue
Block a user