Skip to content

Commit

Permalink
improved negativeWords Set check
Browse files Browse the repository at this point in the history
  • Loading branch information
norm-ideal committed Jul 18, 2020
1 parent 93a3845 commit cf5336a
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ public void validate(Sentence sentence) {
String errorPart = "";
List<TokenElement> tokens = sentence.getTokens();
for (TokenElement token : tokens) {
for (String negativeWord : negativeWords) {
if (token.getSurface().toLowerCase().equals(negativeWord)) {
count++;
errorPart += " " + token.getSurface().toLowerCase();
}
if (count >= 2) {
addLocalizedError(sentence, errorPart);
return;
}
if (negativeWords.contains(token.getSurface().toLowerCase())) {
count++;
errorPart += " " + token.getSurface().toLowerCase();
}
if (count >= 2) {
addLocalizedError(sentence, errorPart);
return;
}
}
}
Expand Down

0 comments on commit cf5336a

Please sign in to comment.