|
...
|
...
|
@@ -75,8 +75,15 @@ class GeoQuestionRes extends Command |
|
|
|
$result_data = $geoService->setWebSearchChatAction($q_item,$p_item);
|
|
|
|
echo 'success:'.$result_data['code'].PHP_EOL;
|
|
|
|
if(isset($result_data) && $result_data['code'] == 200){
|
|
|
|
$keywords = $this->getKeywords($keywordArr,$result_data['text'] ?? []);
|
|
|
|
$urls = $this->getUrl($urlArr,$result_data['annotations'] ?? []);
|
|
|
|
$result_data_annotations[] = $result_data['text'];
|
|
|
|
if(!empty($result_data['annotations'])){
|
|
|
|
$url = array_column($result_data['annotations'], 'url');
|
|
|
|
$title = array_column($result_data['annotations'], 'title');
|
|
|
|
$result_data_annotations = array_merge($url,$title,$result_data_annotations);
|
|
|
|
}
|
|
|
|
dd($result_data_annotations);
|
|
|
|
$keywords = $this->getKeywords($keywordArr,$result_data_annotations ?? []);
|
|
|
|
$urls = $this->getUrl($urlArr,$result_data_annotations ?? []);
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
echo $e->getMessage().PHP_EOL;
|
|
...
|
...
|
@@ -124,22 +131,13 @@ class GeoQuestionRes extends Command |
|
|
|
* @method :post
|
|
|
|
* @time :2025/7/3 16:38
|
|
|
|
*/
|
|
|
|
public function getUrl($urlArr = [],$result_annotations = [],$result_text = []){
|
|
|
|
public function getUrl($urlArr = [],$result_annotations = []){
|
|
|
|
$url = [];
|
|
|
|
if(!empty($urlArr)){
|
|
|
|
$str = implode(',',$result_annotations);
|
|
|
|
foreach ($urlArr as $u_item){
|
|
|
|
if(!empty($result_text)){
|
|
|
|
if (str_contains($result_text, $u_item)) {
|
|
|
|
$url[] = $u_item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!empty($result_annotations)){
|
|
|
|
foreach ($result_annotations as $a_item){
|
|
|
|
echo 'url'.$a_item['url_citation']['url'].PHP_EOL.'当前的url:'.$u_item;
|
|
|
|
if (str_contains($a_item['url_citation']['url'], $u_item) || str_contains($a_item['url_citation']['title'], $u_item)) {
|
|
|
|
$url[] = $u_item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (str_contains($str, $u_item)) {
|
|
|
|
$url[] = $u_item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -156,8 +154,9 @@ class GeoQuestionRes extends Command |
|
|
|
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($result_text, $k_item)) {
|
|
|
|
if (str_contains($str, $k_item)) {
|
|
|
|
$keywords[] = $k_item;
|
|
|
|
}
|
|
|
|
}
|
...
|
...
|
|