#573·storm

Removing unfinished sentences drops multiple citations after the last complete sentence

Author: Afloat16Created Sep 29, 2026Updated Sep 29, 2026

Problem and proposed change

The end-of-sentence regex consumes at most one citation. Truncation then cuts off additional citations that belong to the same complete sentence. Consume the full sequence of trailing citation markers.

Reproduction

python
from knowledge_storm.utils import ArticleTextProcessing
print(ArticleTextProcessing.remove_uncompleted_sentences_with_citations("A fact.[1][2] Unfinished"))
# Expected: A fact.[1][2]
# Actual: A fact.[1]

Validation

Source: knowledge_storm/utils.py, Git blob 4411b05e48e2fefd16722e395a8318da7296b5ef; rechecked against current upstream. Focused before/after tests were rerun for this submission.

Complete source file pinned; ArticleTextProcessing class executed independently of model and retrieval dependencies.

Before: 5 failed, 5 passed in 0.04s

After: 10 passed in 0.02s

Candidate patch

diff
--- a/knowledge_storm/utils.py
+++ b/knowledge_storm/utils.py
@@ -416,7 +416,7 @@
         #     combined_sentences += ' '.join(trailing_citations)
 
         # Regex pattern to match sentence endings, including optional citation markers.
-        eos_pattern = r"([.!?])\s*(\[\d+\])?\s*"
+        eos_pattern = r"([.!?])\s*(?:\[\d+\]\s*)*"
         matches = list(re.finditer(eos_pattern, text))
         if matches:
             last_match = matches[-1]