Skip to content

Commit cc50564

Browse files
committed
fix: the paragraph cannot be empty
``` IllegalArgumentException: The paragraph cannot be empty ```
1 parent e34bdf1 commit cc50564

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/main/java/ai/elimu/web/content/word/WordListController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ public String handleRequest(Model model) {
5151
model.addAttribute("maxUsageCount", maxUsageCount);
5252

5353
// Extract letter frequency distribution from storybook paragraphs
54-
List<String> wordsInParagraphs = new ArrayList<>();
54+
List<String> paragraphs = new ArrayList<>();
5555
for (StoryBookParagraph storyBookParagraph : storyBookParagraphDao.readAll()) {
56-
for (String word : storyBookParagraph.getOriginalText().split(" ")) {
57-
wordsInParagraphs.add(word);
56+
if (StringUtils.isNotBlank(storyBookParagraph.getOriginalText())) {
57+
paragraphs.add(storyBookParagraph.getOriginalText());
5858
}
5959
}
6060
if (StringUtils.isNotBlank(ConfigHelper.getProperty("content.language"))) {
6161
Language language = Language.valueOf(ConfigHelper.getProperty("content.language"));
62-
Map<String, Integer> wordFrequencyMap = WordFrequencyHelper.getWordFrequency(wordsInParagraphs, language);
62+
Map<String, Integer> wordFrequencyMap = WordFrequencyHelper.getWordFrequency(paragraphs, language);
6363
model.addAttribute("wordFrequencyMap", wordFrequencyMap);
6464
}
6565

0 commit comments

Comments
 (0)