zhengkun 8 месяцев назад
Родитель
Сommit
542c6b784c
7 измененных файлов с 71 добавлено и 45 удалено
  1. 11 19
      clean/c_region.go
  2. 2 2
      config.json
  3. 5 3
      extract/extract.go
  4. 34 4
      main.go
  5. 1 1
      prompt/prompt_buyer.go
  6. 17 15
      ul/global.go
  7. 1 1
      ul/init.go

+ 11 - 19
clean/c_region.go

@@ -30,44 +30,36 @@ func CleanRegion(area string, city string) (string, string) {
 			}
 		}
 	}
-	//确认城市
+	//确认城市-从下往上补
 	if city != "" {
-		//校验城市
 		if ul.S_CityDict[city] != nil {
 			new_city = city
-			if new_area == "" {
-				new_area = ul.S_CityDict[city][0].P_Name
-			}
-		} else {
+			new_area = ul.S_CityDict[city][0].P_Name
+		} else { //是否存在包含关系
 			for k, v := range ul.S_CityDict {
 				if strings.Contains(k, city) || strings.Contains(city, k) {
 					for _, v1 := range v {
-						if new_area == "" {
-							new_area = v1.P_Name
-							new_city = k
-							break
-						} else {
-							if new_area == v1.P_Name {
-								new_city = k
-								break
-							}
-						}
+						new_area = v1.P_Name
+						new_city = k
 					}
 				}
 			}
 		}
-		//校验区县
+		if new_area != "" && new_city != "" {
+			return new_area, new_city
+		}
+		//可能抽取区县信息
 		if ul.S_DistrictDict[city] != nil {
 			districts := ul.S_DistrictDict[city]
 			for _, v := range districts {
 				if new_area == "" {
 					new_area = v.P_Name
 					new_city = v.C_Name
-					break
+					return new_area, new_city
 				} else {
 					if new_area == v.P_Name {
 						new_city = v.C_Name
-						break
+						return new_area, new_city
 					}
 				}
 			}

+ 2 - 2
config.json

@@ -12,7 +12,7 @@
     "local": true,
     "l_addr": "127.0.0.1:12005",
     "addr": "172.17.189.140:27080,172.17.189.141:27081",
-    "dbname" : "qfw_ai",
+    "dbname" : "qfw",
     "username": "zhengkun",
     "password": "zk@123123"
   },
@@ -20,7 +20,7 @@
     "local": true,
     "l_addr": "127.0.0.1:12005",
     "addr": "172.17.189.140:27080,172.17.189.141:27081",
-    "dbname" : "qfw_ai",
+    "dbname" : "qfw",
     "username": "zhengkun",
     "password": "zk@123123"
   },

+ 5 - 3
extract/extract.go

@@ -94,7 +94,7 @@ func ResolveInfo(v map[string]interface{}) map[string]interface{} {
 	f_info_3 := prompt.AcquireExtractFieldInfoThird(new_detail)
 	f_info := MergeInfo([]map[string]interface{}{f_info_1, f_info_2, f_info_3})
 
-	//非短文本以下识别
+	//非短文本以下识别-纯测试
 	if !shorText {
 		//获取分包信息
 		if pkg := prompt.AcquireNewMultiplePackageInfo(new_detail); len(pkg) > 0 {
@@ -106,8 +106,10 @@ func ResolveInfo(v map[string]interface{}) map[string]interface{} {
 		f_info["s_subtype"] = s_subtype
 
 		//调用标的物识别
-		if s_purchasinglist := getPurList(v, old_detail, f_info); len(s_purchasinglist) > 0 {
-			f_info["s_purchasinglist"] = s_purchasinglist
+		if !ul.IsTool {
+			if s_purchasinglist := getPurList(v, old_detail, f_info); len(s_purchasinglist) > 0 {
+				f_info["s_purchasinglist"] = s_purchasinglist
+			}
 		}
 	}
 

+ 34 - 4
main.go

@@ -1,10 +1,11 @@
 package main
 
 import (
+	"data_ai/prompt"
 	"data_ai/tool"
 	"data_ai/udp"
 	"data_ai/ul"
-	log "github.com/donnie4w/go-logger/logger"
+	"fmt"
 )
 
 func init() {
@@ -19,7 +20,9 @@ func init() {
 			udp.InitProcessVar()
 		}
 	}
-	ul.InitOss(ul.IsLocal)
+	if !ul.IsTool {
+		ul.InitOss(ul.IsLocal)
+	}
 }
 
 func main() {
@@ -33,8 +36,35 @@ func main() {
 
 // 测试调试数据
 func test() {
-	arr := []string{}
+	arr := []string{
+		"福建亿力集团有限公司三明优信公司",
+		"北京市顺义区疾病预防控制中心",
+		"海南博鳌乐城数字科技发展有限公司",
+		"济南市公安局章丘区分局",
+		"固镇县公安局,固镇县城市建设投资发展有限责任公司",
+		"中共耒阳市纪律检查委员会耒阳市监察委员会",
+		"苏州市吴江区公安局太湖新城片区公安",
+		"安徽公司马鞍山电厂",
+		"安徽公司合肥电厂",
+		"国能宿州热电有限公司",
+		"中山市港口镇下南小学",
+		"中山市港口镇大丰小学",
+		"中山市港口镇大南中学",
+		"中山市港口镇石特小学",
+		"中国铁路乌鲁木齐局集团有限公司阿勒泰基础设施段",
+		"常德市澧县澧州实验学校",
+		"宜章县杨梅山镇杨梅山学校",
+		"永州市东安县芦洪市镇人民政府",
+		"云南省彝医医院",
+		"台山市台城街道办事处长岭村松梅经济合作社",
+		"杭州市钱塘区听涛幼儿园",
+		"杭州市临平区启文中学",
+		"杭州市余杭区舟枕小学",
+		"宁波高新区信懋小学",
+		"杭州市钱塘区星华幼儿园",
+	}
 	for _, v := range arr {
-		log.Debug(v)
+		zp_buyer := prompt.AcquireBuyerInfo(v)
+		fmt.Println(v, "~", zp_buyer["实体单位"])
 	}
 }

+ 1 - 1
prompt/prompt_buyer.go

@@ -14,7 +14,7 @@ func AcquireBuyerInfo(detail string) map[string]interface{} {
 // 提示词优选 - 提问词补偿不需要限制
 func PromptBuyerText(detail string) string {
 	content := `请根据我提供的正文进行"实体单位"的抽取;
-你在识别"实体单位"的时候,只能返回一个实体单位,不要返回多个实体单位,如果识别不出来,请填写"无";
+你在识别"实体单位"的时候,只能返回一个最全的实体单位,请务必不要省略分公司,全称的中小学校等,如果是多个实体单位,请填写"无"
 请将上述的识别结果、信息分类结果,按照JSON格式输出,
 严格按照json格式
 {

+ 17 - 15
ul/global.go

@@ -302,65 +302,67 @@ func ChooseTheBestOtherField(ai_zhipu map[string]interface{}, tmp map[string]int
 		}
 	}
 	//新增字段
-	if biddingcode := ai_zhipu["s_biddingcode"]; biddingcode != nil {
+	if biddingcode := qu.ObjToString(ai_zhipu["s_biddingcode"]); biddingcode != "" {
 		(*update_info)["biddingcode"] = biddingcode
 	}
-	if packagecode := ai_zhipu["s_packagecode"]; packagecode != nil {
+	if packagecode := qu.ObjToString(ai_zhipu["s_packagecode"]); packagecode != "" {
 		(*update_info)["packagecode"] = packagecode
 	}
 
 	//替换字段
-	if contractcode := ai_zhipu["s_contractcode"]; contractcode != nil {
+	if contractcode := qu.ObjToString(ai_zhipu["s_contractcode"]); contractcode != "" {
 		(*update_info)["contractcode"] = contractcode
 		(*ext_ai_record)["contractcode"] = tmp["contractcode"]
 	}
-	if bidopenaddress := ai_zhipu["s_bidopenaddress"]; bidopenaddress != nil {
+	if bidopenaddress := qu.ObjToString(ai_zhipu["s_bidopenaddress"]); bidopenaddress != "" {
 		(*update_info)["bidopenaddress"] = bidopenaddress
 		(*ext_ai_record)["bidopenaddress"] = tmp["bidopenaddress"]
 	}
-	if biddiscount := ai_zhipu["s_biddiscount"]; biddiscount != nil {
+	//折扣
+	if biddiscount := qu.Float64All(ai_zhipu["s_biddiscount"]); biddiscount > 0.0 {
 		(*update_info)["biddiscount"] = biddiscount
 		(*ext_ai_record)["biddiscount"] = tmp["biddiscount"]
 	}
-	if bidopentime := ai_zhipu["s_bidopentime"]; bidopentime != nil {
+	//时间戳
+	if bidopentime := qu.Int64All(ai_zhipu["s_bidopentime"]); bidopentime > 0 {
 		(*update_info)["bidopentime"] = bidopentime
 		(*ext_ai_record)["bidopentime"] = tmp["bidopentime"]
 	}
-	if bidendtime := ai_zhipu["s_bidendtime"]; bidendtime != nil {
+	if bidendtime := qu.Int64All(ai_zhipu["s_bidendtime"]); bidendtime > 0 {
 		(*update_info)["bidendtime"] = bidendtime
 		(*ext_ai_record)["bidendtime"] = tmp["bidendtime"]
 	}
-	if docstarttime := ai_zhipu["s_docstarttime"]; docstarttime != nil {
+	if docstarttime := qu.Int64All(ai_zhipu["s_docstarttime"]); docstarttime > 0 {
 		(*update_info)["docstarttime"] = docstarttime
 		(*ext_ai_record)["docstarttime"] = tmp["docstarttime"]
 	}
-	if docendtime := ai_zhipu["s_docendtime"]; docendtime != nil {
+	if docendtime := qu.Int64All(ai_zhipu["s_docendtime"]); docendtime > 0 {
 		(*update_info)["docendtime"] = docendtime
 		(*ext_ai_record)["docendtime"] = tmp["docendtime"]
 	}
 
 	//联系方式
-	if buyerperson := ai_zhipu["s_buyerperson"]; buyerperson != nil {
+	if buyerperson := qu.ObjToString(ai_zhipu["s_buyerperson"]); buyerperson != "" {
 		(*update_info)["buyerperson"] = buyerperson
 		(*ext_ai_record)["buyerperson"] = tmp["buyerperson"]
 	}
-	if buyertel := ai_zhipu["s_buyertel"]; buyertel != nil {
+	if buyertel := qu.ObjToString(ai_zhipu["s_buyertel"]); buyertel != "" {
 		(*update_info)["buyertel"] = buyertel
 		(*ext_ai_record)["buyertel"] = tmp["buyertel"]
 	}
-	if agencyperson := ai_zhipu["s_agencyperson"]; agencyperson != nil {
+	if agencyperson := qu.ObjToString(ai_zhipu["s_agencyperson"]); agencyperson != "" {
 		(*update_info)["agencyperson"] = agencyperson
 		(*ext_ai_record)["agencyperson"] = tmp["agencyperson"]
 	}
-	if agencytel := ai_zhipu["s_agencytel"]; agencytel != nil {
+	if agencytel := qu.ObjToString(ai_zhipu["s_agencytel"]); agencytel != "" {
 		(*update_info)["agencytel"] = agencytel
 		(*ext_ai_record)["agencytel"] = tmp["agencytel"]
 	}
-	if winnerperson := ai_zhipu["s_winnerperson"]; winnerperson != nil {
+	if winnerperson := qu.ObjToString(ai_zhipu["s_winnerperson"]); winnerperson != "" {
 		(*update_info)["winnerperson"] = winnerperson
 		(*ext_ai_record)["winnerperson"] = tmp["winnerperson"]
 	}
-	if winnertel := ai_zhipu["s_winnertel"]; winnertel != nil {
+	if winnertel := qu.ObjToString(ai_zhipu["s_winnertel"]); winnertel != "" {
 		(*update_info)["winnertel"] = winnertel
 		(*ext_ai_record)["winnertel"] = tmp["winnertel"]
 	}

+ 1 - 1
ul/init.go

@@ -314,7 +314,7 @@ func PostPurchasingList(data map[string]interface{}) map[string]interface{} {
 	// 设置请求头
 	req.Header.Set("Content-Type", "application/json")
 	client := &http.Client{}
-	client.Timeout = 120 * time.Second
+	client.Timeout = 180 * time.Second
 	resp, err := client.Do(req)
 	if err != nil {
 		return map[string]interface{}{}