From e4d382dd1247397caa90e3853aa1fc0de074f301 Mon Sep 17 00:00:00 2001 From: chengxl Date: Mon, 18 Aug 2025 18:03:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Aireview.php | 45 ++++++++----------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/application/api/controller/Aireview.php b/application/api/controller/Aireview.php index d0bb228..537697b 100644 --- a/application/api/controller/Aireview.php +++ b/application/api/controller/Aireview.php @@ -45,7 +45,7 @@ class Aireview extends Base if(empty($aArticle)){ return json_encode(array('status' => 3,'msg' => 'No articles requiring review were found' )); } - // //AI审稿信息 + //AI审稿信息 $aAiReview = empty($aResult['data']) ? [] : $aResult['data']; if(!empty($aAiReview['is_finish']) && $aAiReview['is_finish'] == 1){ return json_encode(array('status' => 1,'msg' => 'AI has been reviewed','data' => $aAiReview)); @@ -125,6 +125,7 @@ class Aireview extends Base } }else{ $aFile = json_decode($oArticle->getFileContent(['article_id' => $iArticleId]),true); + $aFile = empty($aFile['data']) ? [] : $aFile['data']; $aArticleMain = empty($aFile['mains']) ? [] : $aFile['mains']; } @@ -195,39 +196,21 @@ class Aireview extends Base return []; } - $pattern = '/]*?>/i'; - $sContent = preg_replace($pattern, '', $sContent); - - // 关键修复:将分隔符从 / 改为 #,避免与 < > 冲突 - $pattern = '#Reference|Reference:|References:|References|References|References:#'; - - // 查找标识在文本中的位置 - preg_match($pattern, $sContent, $matches, PREG_OFFSET_CAPTURE); - - if (empty($matches)) { - // 未找到任何标识 - $before = $sContent; - $after = ''; - } else { - // 截取标识前后内容 - $marker = $matches[0][0]; - $markerStart = $matches[0][1]; - $before = substr($sContent, 0, $markerStart); - $after = substr($sContent, $markerStart + strlen($marker)); - } - if(empty($after)){ - $lastPos = strrpos($sContent, 'Reference'); - if ($lastPos === false) { + //拆分字符串 + $lastPos = strrpos($sContent, 'Reference'); + if ($lastPos === false) { + $lastPos = strrpos($sContent, 'REFERENCE'); + if($lastPos === false){ // 未找到 "Reference",返回原字符串和空 - return [$sContent, '']; + return ['before' => $sContent, 'after' => '']; } - - // 拆分:关键词之前的内容 - $before = substr($sContent, 0, $lastPos); - // 关键词及之后的内容(包含关键词本身) - $after = substr($sContent, $lastPos); } - return ['before' => $before,'after' => $after,'content' => $sContent]; + + // 拆分:关键词之前的内容 + $before = substr($sContent, 0, $lastPos); + // 关键词及之后的内容(包含关键词本身) + $after = substr($sContent, $lastPos); + return ['before' => $before,'after' => $after]; } /**