|
...
|
...
|
@@ -85,7 +85,6 @@ class GeoQuestionRes extends Command |
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($platform == 'Google AI Overview') {
|
|
|
|
continue;
|
|
|
|
// overview 数据结构不确定, 需要单独处理数据
|
|
|
|
$data = $geo_service->getGooglePlatformResult($question);
|
|
|
|
$result = $this->dealGoogleData($data);
|
|
...
|
...
|
@@ -106,21 +105,18 @@ class GeoQuestionRes extends Command |
|
|
|
$title = array_column(array_column($result['annotations'], 'url_citation'), 'title');;
|
|
|
|
$hit_data = array_merge($url, $title, $hit_data);
|
|
|
|
}
|
|
|
|
$hit_string = implode(',', $hit_data);
|
|
|
|
// 命中关键词和路由
|
|
|
|
$hit_keyword = $hit_url = [];
|
|
|
|
$hit = 0;
|
|
|
|
if (!empty($taskInfo['keywords'])) {
|
|
|
|
$pattern = '/(' . implode('|', array_map('preg_quote', $taskInfo['keywords'])) . ')/i';
|
|
|
|
if (preg_match($pattern, $hit_string, $matches)) {
|
|
|
|
$hit_keyword = $matches[0];
|
|
|
|
$hit_keyword = $this->getKeywords($taskInfo['keywords'],$hit_data);
|
|
|
|
if (!empty($hit_keyword)) {
|
|
|
|
$hit++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!empty($taskInfo['url'])) {
|
|
|
|
$pattern = '/(' . implode('|', array_map('preg_quote', $taskInfo['url'])) . ')/i';
|
|
|
|
if (preg_match($pattern, $hit_string, $matches)) {
|
|
|
|
$hit_url = $matches[0];
|
|
|
|
$hit_url = $this->getUrl($taskInfo['url'],$hit_data);
|
|
|
|
if (!empty($hit_url)) {
|
|
|
|
$hit++;
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -154,6 +150,46 @@ class GeoQuestionRes extends Command |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取命中的url
|
|
|
|
* @name :getUrl
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/7/3 16:38
|
|
|
|
*/
|
|
|
|
public function getUrl($urlArr = [],$result_annotations = []){
|
|
|
|
$url = [];
|
|
|
|
if(!empty($urlArr)){
|
|
|
|
$str = implode(',',$result_annotations);
|
|
|
|
foreach ($urlArr as $u_item){
|
|
|
|
if (str_contains($str, $u_item)) {
|
|
|
|
$url[] = $u_item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return array_values(array_unique($url));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取命中的关键词
|
|
|
|
* @name :getKeywords
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/7/3 16:26
|
|
|
|
*/
|
|
|
|
public function getKeywords($keywordArr = [],$result_text = []){
|
|
|
|
$keywords = [];
|
|
|
|
if(!empty($keywordArr) && !empty($result_text)){
|
|
|
|
$str = implode(',',$result_text);
|
|
|
|
foreach ($keywordArr as $k_item){
|
|
|
|
if (str_contains($str, $k_item)) {
|
|
|
|
$keywords[] = $k_item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $keywords;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 整合Google平台数据
|
|
|
|
* @param $data
|
|
|
|
* @return array
|
...
|
...
|
|