Skip to content
Snippets Groups Projects
Commit 45e96264 authored by Eike Cochu's avatar Eike Cochu
Browse files

fixed npe while importing

parent 268f7513
No related branches found
No related tags found
No related merge requests found
...@@ -53,8 +53,8 @@ public class FilebaseWordIndex implements Iterable<String> { ...@@ -53,8 +53,8 @@ public class FilebaseWordIndex implements Iterable<String> {
public String transform(final String[] words, final boolean dbInsert) { public String transform(final String[] words, final boolean dbInsert) {
final CountMap<String> countMap = new CountMap<>(); final CountMap<String> countMap = new CountMap<>();
for (final String word : words) { for (final String word : words) {
if (!word.trim().isEmpty()) { if (word != null && !word.trim().isEmpty()) {
countMap.count(word); countMap.count(word.trim());
if (dbInsert) if (dbInsert)
newWords.add(word); newWords.add(word);
} }
......
...@@ -21,8 +21,8 @@ public class ProcessedText { ...@@ -21,8 +21,8 @@ public class ProcessedText {
final String[] allWords = text.toLowerCase().trim().split("\\s+"); final String[] allWords = text.toLowerCase().trim().split("\\s+");
final List<String> wordList = new ArrayList<>(allWords.length); final List<String> wordList = new ArrayList<>(allWords.length);
for (final String word : allWords) for (final String word : allWords)
if (!word.trim().isEmpty()) if (word != null && !word.trim().isEmpty())
wordList.add(word); wordList.add(word.trim());
words = wordList.toArray(new String[allWords.length]); words = wordList.toArray(new String[allWords.length]);
originalWordCount = wordCount; originalWordCount = wordCount;
reducedWordCount = words.length; reducedWordCount = words.length;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment