|
@@ -1,182 +0,0 @@
|
|
|
-package prompt
|
|
|
-
|
|
|
-import (
|
|
|
- "data_ai/ai"
|
|
|
- "data_ai/clean"
|
|
|
- "data_ai/ul"
|
|
|
- qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
|
|
|
- "strings"
|
|
|
-)
|
|
|
-
|
|
|
-// 获取分类信息...
|
|
|
-func AcquireClassInfo(detail string, title string) (string, string) {
|
|
|
- top_content := PromptToptypeFieldText(detail, title)
|
|
|
- top_zp, ok := PostZhiPuClassInfo(top_content)
|
|
|
- if !ok {
|
|
|
- return "", ""
|
|
|
- }
|
|
|
- //根据一级分类识别,获取toptype和subtype
|
|
|
- var toptype, subtype string //标准化的一级、二级分类
|
|
|
- toptype_ai, _ := top_zp["信息分类"].(string)
|
|
|
- tpInfo := ul.ToptypeDict[toptype_ai]
|
|
|
- if tpInfo != nil {
|
|
|
- toptype = tpInfo.Topetype
|
|
|
- subtype = tpInfo.Subtype
|
|
|
- } else { //匹配结果为非正规toptype,如:询价公告(66993a9d66cf0db42a5597af)
|
|
|
- for top, reg := range ul.ToptypeRegs {
|
|
|
- if reg.MatchString(toptype_ai) {
|
|
|
- if tpInfo = ul.ToptypeDict[top]; tpInfo != nil { //ToptypeRegs中预告公告、验收公告、合同公告直接获取subtype
|
|
|
- toptype = tpInfo.Topetype
|
|
|
- subtype = tpInfo.Subtype
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if toptype == "" || tpInfo == nil {
|
|
|
- return "", ""
|
|
|
- }
|
|
|
- //获取二级分类
|
|
|
- sub_zp := map[string]interface{}{}
|
|
|
- if subtype == "" {
|
|
|
- sub_content := PromptSubtypeFieldText(detail, title, toptype, tpInfo)
|
|
|
- sub_zp, ok = PostZhiPuClassInfo(sub_content)
|
|
|
- if !ok {
|
|
|
- return "", ""
|
|
|
- }
|
|
|
- subtype_ai, _ := sub_zp["信息分类"].(string)
|
|
|
- subtype = tpInfo.SubtypeDict[subtype_ai]
|
|
|
- if subtype == "" && tpInfo.SubtypeRegs != nil { //二级分类校正
|
|
|
- for sub, reg := range tpInfo.SubtypeRegs {
|
|
|
- if reg.MatchString(subtype_ai) {
|
|
|
- subtype = sub
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //subtype到此还可能为空,给默认值
|
|
|
- if subtype == "" {
|
|
|
- subtype = "其它"
|
|
|
- }
|
|
|
- return toptype, subtype
|
|
|
-}
|
|
|
-
|
|
|
-// 根据抽取字段校正分类结果
|
|
|
-func CheckClassByOtherFileds(toptype_ai, subtype_ai string, data map[string]interface{}) (string, string) {
|
|
|
- toptype_rule := qu.ObjToString(data["toptype"])
|
|
|
- subtype_rule := qu.ObjToString(data["subtype"])
|
|
|
- //1、结果类 中标和成交错误校正
|
|
|
- s_winner := qu.ObjToString(data["s_winner"])
|
|
|
- winnerorder, _ := data["winnerorder"].([]interface{})
|
|
|
- if toptype_ai == "结果" && toptype_rule == "结果" {
|
|
|
- if (subtype_ai == "中标" && subtype_rule == "成交") || (subtype_ai == "成交" && subtype_rule == "中标") {
|
|
|
- if len(winnerorder) > 0 { //有中标候选人->中标
|
|
|
- return toptype_ai, "中标"
|
|
|
- }
|
|
|
- if s_winner != "" || data["bidamount"] != nil {
|
|
|
- return toptype_ai, "成交"
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //2、招标、结果错误校正
|
|
|
- if toptype_ai != "结果" && toptype_rule == "结果" {
|
|
|
- //return toptype_rule,subtype_rule//默认规则为准
|
|
|
- if len(winnerorder) > 0 { //有中标候选人->中标
|
|
|
- //return toptype_rule, "中标"//这里subtype是否返回"中标"?
|
|
|
- return toptype_rule, subtype_rule //默认规则是正确的
|
|
|
- } else if s_winner != "" || data["bidamount"] != nil {
|
|
|
- return toptype_rule, subtype_rule
|
|
|
- } else {
|
|
|
- return toptype_ai, subtype_ai
|
|
|
- }
|
|
|
- } else if toptype_ai == "结果" && toptype_rule != "结果" {
|
|
|
- //return toptype_rule,subtype_rule//默认规则为准
|
|
|
- if len(winnerorder) > 0 { //有中标候选人->中标
|
|
|
- return toptype_ai, "中标" //这里subtype返回"中标",避免ai识别错误
|
|
|
- } else if s_winner != "" || data["bidamount"] != nil {
|
|
|
- return toptype_ai, "成交" //这里subtype返回"成交",避免ai识别错误
|
|
|
- } else {
|
|
|
- return toptype_ai, subtype_ai
|
|
|
- }
|
|
|
- }
|
|
|
- return toptype_ai, subtype_ai
|
|
|
-}
|
|
|
-
|
|
|
-// 获取外围抽取字段
|
|
|
-func AcquireExtractFieldInfo(detail string) map[string]interface{} {
|
|
|
- content := PromptFieldText(detail)
|
|
|
- zp := PostZhiPuInfo(content)
|
|
|
- return zp
|
|
|
-}
|
|
|
-
|
|
|
-// 获取是否为分包信息
|
|
|
-func AcquireIsPackageInfo(detail string) bool {
|
|
|
- content := PromptIsPackageText(detail)
|
|
|
- zp := PostZhiPuInfo(content)
|
|
|
- if qu.ObjToString(zp["分包"]) == "是" {
|
|
|
- return true
|
|
|
- }
|
|
|
- return false
|
|
|
-}
|
|
|
-
|
|
|
-// 获取标讯多包信息
|
|
|
-func AcquireMultiplePackageInfo(detail string) map[string]interface{} {
|
|
|
- content := PromptMultiplePackageText(detail)
|
|
|
- zp := PostZhiPuInfo(content)
|
|
|
- return zp
|
|
|
- //后续在转格式...暂时先输出两个值
|
|
|
- pkg := map[string]interface{}{}
|
|
|
- s_winner, s_bidamount := "", 0.0
|
|
|
- win_arr, win_temp := []string{}, map[string]string{}
|
|
|
- if score := qu.Float64All(zp["分包信息score"]); score >= 90.0 {
|
|
|
- pkginfo := ul.IsMarkInterfaceMap(zp["分包信息"])
|
|
|
- for _, v := range pkginfo {
|
|
|
- winner := clean.CleanWinner(qu.ObjToString(v["中标单位"]))
|
|
|
- bidamount := clean.CleanMoney((v["中标金额"]))
|
|
|
- s_bidamount += bidamount
|
|
|
- if win_temp[winner] == "" && winner != "" {
|
|
|
- win_arr = append(win_arr, winner)
|
|
|
- win_temp[winner] = winner
|
|
|
- }
|
|
|
- }
|
|
|
- s_winner = strings.Join(win_arr, ",")
|
|
|
- pkg["s_winner"] = s_winner
|
|
|
- pkg["s_bidamount"] = s_bidamount
|
|
|
- }
|
|
|
- return pkg
|
|
|
-}
|
|
|
-
|
|
|
-// 请求质谱数据外围字段...
|
|
|
-func PostZhiPuInfo(content string) map[string]interface{} {
|
|
|
- zp, ok := map[string]interface{}{}, 0
|
|
|
- for {
|
|
|
- ok++
|
|
|
- if zp = ai.PostZhiPuAI(content); len(zp) > 0 {
|
|
|
- break
|
|
|
- }
|
|
|
- if ok >= 5 {
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- return zp
|
|
|
-}
|
|
|
-
|
|
|
-// 请求质谱数据-分类字段
|
|
|
-func PostZhiPuClassInfo(content string) (map[string]interface{}, bool) {
|
|
|
- zp := map[string]interface{}{}
|
|
|
- times := 0
|
|
|
- ok := false
|
|
|
- for {
|
|
|
- times++
|
|
|
- zp = ai.PostClassZhiPuAI(content)
|
|
|
- if len(zp) > 0 {
|
|
|
- ok = true
|
|
|
- break
|
|
|
- }
|
|
|
- if times >= 5 {
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- return zp, ok
|
|
|
-}
|