Skip to content

Commit

Permalink
Merge pull request #368 from boxheed/master
Browse files Browse the repository at this point in the history
Issue #366 - added null check to the 'text' variable
  • Loading branch information
anidotnet authored Oct 31, 2020
2 parents 20d03c8 + f197a4d commit d16b002
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ public abstract class BaseTextTokenizer implements TextTokenizer {
@Override
public Set<String> tokenize(String text) throws IOException {
Set<String> words = new HashSet<>();
StringTokenizer tokenizer = new StringTokenizer(text, WHITESPACE_CHARS);
while (tokenizer.hasMoreTokens()) {
String word = tokenizer.nextToken();
word = convertWord(word);
if (word != null) {
words.add(word);
if(text != null) {
StringTokenizer tokenizer = new StringTokenizer(text, WHITESPACE_CHARS);
while (tokenizer.hasMoreTokens()) {
String word = tokenizer.nextToken();
word = convertWord(word);
if (word != null) {
words.add(word);
}
}
}
return words;
Expand Down

0 comments on commit d16b002

Please sign in to comment.