This commit is contained in:
wyn
2026-05-21 14:37:04 +08:00
parent 6f76c483ec
commit 3663dd4ea6
2 changed files with 38 additions and 10 deletions

View File

@@ -193,7 +193,7 @@ class ReferenceCheckService
'created_at' => $now,
'updated_at' => $now,
]);
// continue;
$this->pushJob(intval($checkId), $delay);
$checkIds[] = $checkId;
$queued++;
@@ -697,20 +697,32 @@ class ReferenceCheckService
}
$hasPriorCiteInParagraph = ($prevTagEnd > $paragraphStart);
// 同段后续引用:从上一 <blue> 后开始;段内首个引用:从段落开头到本标签前(非仅最后一句)
// 同段后续引用:从上一 <blue> 后开始;段内首个引用:从段落开头到本标签前
if ($hasPriorCiteInParagraph) {
$localStart = $prevTagEnd;
} else {
$localStart = $this->capContextStartBeforeTag($content, $tagStart, $paragraphStart);
$sentenceStart = $this->findSentenceStart($content, $tagStart);
$localStart = $this->capContextStartBeforeTag(
$content,
$tagStart,
max($paragraphStart, $sentenceStart)
);
}
// 默认:引用标签前的论述(如 Yin et al. [13] → 含 “higher than … Yin et al.”)
// 默认:引用标签前的论述
$localEnd = $tagStart;
$originalText = $this->buildCitationContextText($content, $localStart, $localEnd);
// 标签前几乎无正文(如句末 … ICU nurses [14]→ 改用标签后至下一引用或句末
// 同句多引(如 …[23] and external environment [24]:上一标签后仅几个词,回退到本句开头
if ($hasPriorCiteInParagraph && mb_strlen($originalText) < 50) {
$sentenceStart = $this->findSentenceStart($content, $tagStart);
$localStart = max($paragraphStart, $sentenceStart);
$originalText = $this->buildCitationContextText($content, $localStart, $localEnd);
}
// 仅段内首个引用且标签前极短时才用标签后文(避免 [24] 误截到 [25] 所在句)
if (!$this->isMeaningfulCitationContext($originalText)
|| $this->shouldUseTrailingCitationContext($content, $localStart, $tagStart, $tagEnd)
|| (!$hasPriorCiteInParagraph && $this->shouldUseTrailingCitationContext($content, $localStart, $tagStart, $tagEnd))
) {
$trailEnd = ($nextTagStart < $sentenceEnd) ? $nextTagStart : $sentenceEnd;
$trailText = $this->buildCitationContextText($content, $tagEnd, $trailEnd);
@@ -811,6 +823,7 @@ class ReferenceCheckService
$text = trim(strip_tags($text));
$text = preg_replace('/\s+/u', ' ', $text);
$text = ltrim($text, "\xEF\xBB\xBF");
$text = preg_replace('/^[\s.,。;、:!?]+/u', '', $text);
return $text;
}