fix NPE in citation servlet on empty text field

pull/51/head
reger 9 years ago
parent efb9f1a8b7
commit 4e0892962a

@ -116,13 +116,15 @@ public class citation {
ArrayList<String> sentences = new ArrayList<String>(); ArrayList<String> sentences = new ArrayList<String>();
if (title != null) for (String s: title) if (s.length() > 0) sentences.add(s); if (title != null) for (String s: title) if (s.length() > 0) sentences.add(s);
SentenceReader sr = new SentenceReader(text); if (text != null && !text.isEmpty()) {
StringBuilder line; SentenceReader sr = new SentenceReader(text);
while (sr.hasNext()) { StringBuilder line;
line = sr.next(); while (sr.hasNext()) {
if (line.length() > 0) sentences.add(line.toString()); line = sr.next();
if (line.length() > 0) sentences.add(line.toString());
}
} }
// for each line make a statistic about the number of occurrences somewhere else // for each line make a statistic about the number of occurrences somewhere else
OrderedScoreMap<String> scores = new OrderedScoreMap<String>(null); // accumulates scores for citating urls OrderedScoreMap<String> scores = new OrderedScoreMap<String>(null); // accumulates scores for citating urls
LinkedHashMap<String, Set<DigestURL>> sentenceOcc = new LinkedHashMap<String, Set<DigestURL>>(); LinkedHashMap<String, Set<DigestURL>> sentenceOcc = new LinkedHashMap<String, Set<DigestURL>>();

Loading…
Cancel
Save