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