|
|
@@ -0,0 +1,1018 @@
|
|
|
+import time
|
|
|
+from tihuan import tihuan
|
|
|
+from tihuan_az import tihuan_az
|
|
|
+from buchong import buchong
|
|
|
+from fuzhu_util import fuzhu_util
|
|
|
+from f_youqi import f_youqi
|
|
|
+import re
|
|
|
+from config import simplemodel
|
|
|
+from template import expression
|
|
|
+from fallback import fallback
|
|
|
+from dianceng import dianceng
|
|
|
+from mianceng import mianceng
|
|
|
+from lingji import lingji
|
|
|
+from jieheceng import jieheceng
|
|
|
+from celery_app import celery_app
|
|
|
+from postprocess import postprocess
|
|
|
+from extra import extra, need_extra
|
|
|
+from huansuan import callzaihuansuan
|
|
|
+import json
|
|
|
+import dedata
|
|
|
+import chromadb
|
|
|
+from feiyong import feiyong_chaogao
|
|
|
+from pymongo import MongoClient
|
|
|
+from anzhuangjsj import anzhuangjsj
|
|
|
+uri="mongodb://owner:Pheecian1@47.101.198.30:27017/baojia"
|
|
|
+mongoclient=MongoClient(uri)
|
|
|
+db = mongoclient['baojia']
|
|
|
+dbcollection=db['qdxm']
|
|
|
+print("chroma")
|
|
|
+client = chromadb.HttpClient(host='47.101.198.30',port=8000)
|
|
|
+collection = client.get_or_create_collection(name="tj_de_bge", metadata={'hnsw:search_ef':15})
|
|
|
+azcollection = client.get_or_create_collection(name="az_de_bge", metadata={'hnsw:search_ef':15})
|
|
|
+cuoshi_collection = client.get_or_create_collection(name="tj_cuoshi_bge")
|
|
|
+menchuang_collection = client.get_or_create_collection(name="tj_menchuang_bge")
|
|
|
+qita_collection = client.get_or_create_collection(name="tj_qita_bge")
|
|
|
+from FlagEmbedding import FlagModel
|
|
|
+print("model")
|
|
|
+azmodel = FlagModel('/mnt/d/Develop/az/az_encoder_only_base_bge-large-zh-v1.5')
|
|
|
+model = FlagModel('/mnt/d/Develop/bge/test2_encoder_only_base_bge-large-zh-v1.5')
|
|
|
+cuoshi_model = FlagModel('cuoshi_encoder_only_base_bge-large-zh-v1.5/cuoshi_encoder_only_base_bge-large-zh-v1.5')
|
|
|
+from sentence_transformers import CrossEncoder
|
|
|
+azce = CrossEncoder('/mnt/d/Develop/az/models/reranker-chinese-macbert-large-gooaq-bce-4/final')
|
|
|
+ce = CrossEncoder('/mnt/d/Develop/celery/final')
|
|
|
+cuoshi_ce = CrossEncoder('cuoshi_reranker/final')
|
|
|
+with open("hunningtu_rule", "r") as f:
|
|
|
+ content = f.read()
|
|
|
+obj = json.loads(content)
|
|
|
+with open("nantong_rule", "r") as f:
|
|
|
+ content = f.read()
|
|
|
+obj2 = json.loads(content)
|
|
|
+with open("basic_rule", "r") as f:
|
|
|
+ content = f.read()
|
|
|
+basic = json.loads(content)
|
|
|
+with open("menchuang_rule", "r") as f:
|
|
|
+ content = f.read()
|
|
|
+menchuang = json.loads(content)
|
|
|
+with open("incremental_rule", "r") as f:
|
|
|
+ content = f.read()
|
|
|
+incremental = json.loads(content)
|
|
|
+with open("label_name", "r") as f:
|
|
|
+ content = f.read()
|
|
|
+label_name = json.loads(content)
|
|
|
+with open("name_label", "r") as f:
|
|
|
+ content = f.read()
|
|
|
+name_label = json.loads(content)
|
|
|
+with open("name_dw", "r") as f:
|
|
|
+ content = f.read()
|
|
|
+name_dw = json.loads(content)
|
|
|
+with open("label_dw", "r") as f:
|
|
|
+ content = f.read()
|
|
|
+label_dw = json.loads(content)
|
|
|
+with open("fuzhu_candidate", "r") as f:
|
|
|
+ content = f.read()
|
|
|
+fuzhu_candidate = json.loads(content)
|
|
|
+with open("az_fuzhu_candidate", "r") as f:
|
|
|
+ content = f.read()
|
|
|
+az_fuzhu_candidate = json.loads(content)
|
|
|
+THRESHOLD=0.8####adjust it
|
|
|
+print("client")
|
|
|
+import os
|
|
|
+from openai import OpenAI
|
|
|
+import requests
|
|
|
+aiclient = OpenAI(
|
|
|
+ #api_key=os.getenv("DASHSCOPE_API_KEY"),
|
|
|
+ api_key=os.getenv("ZAI_API_KEY"),
|
|
|
+ #base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
|
+ base_url="https://open.bigmodel.cn/api/paas/v4/",
|
|
|
+ timeout=60
|
|
|
+)
|
|
|
+qwclient = OpenAI(
|
|
|
+ # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx",
|
|
|
+ #api_key=os.getenv("DASHSCOPE_API_KEY"),
|
|
|
+ api_key=os.getenv("MS_API_KEY"),
|
|
|
+ #base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
|
+ base_url="https://api-inference.modelscope.cn/v1/",
|
|
|
+ timeout=60
|
|
|
+)
|
|
|
+dsclient = OpenAI(
|
|
|
+ # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx",
|
|
|
+ #api_key=os.getenv("DASHSCOPE_API_KEY"),
|
|
|
+ api_key=os.getenv("DS_API_KEY"),
|
|
|
+ #base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
|
+ base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
|
+ timeout=60
|
|
|
+)
|
|
|
+ssclient = OpenAI(
|
|
|
+ api_key=os.getenv("SS_API_KEY"), # 此处传token,不带Bearer
|
|
|
+ base_url="https://chat.intern-ai.org.cn/api/v1/",
|
|
|
+ timeout=60
|
|
|
+)
|
|
|
+simpleclient = ssclient
|
|
|
+
|
|
|
+
|
|
|
+def has_chinese(text):
|
|
|
+ pattern = re.compile(r'[\u4e00-\u9fff]+')
|
|
|
+ result = pattern.search(text)
|
|
|
+ return True if result else False
|
|
|
+def analyze(json_string):
|
|
|
+ obj = json.loads(json_string)
|
|
|
+ bz = None
|
|
|
+ if 'bz_selected' in obj:
|
|
|
+ bz = obj['bz_selected']
|
|
|
+ bh = bz['BZBH']
|
|
|
+ bh_list = []
|
|
|
+ for entry in bh:
|
|
|
+ bh_list.append([entry, bh[entry], bz['SM'][entry]])
|
|
|
+ print(bh_list)
|
|
|
+ return bh_list,obj['bz_selected2']
|
|
|
+def select_fuzhu_az(city,input, label, aiclient, qwclient, client):
|
|
|
+ if label_name[input[0]] in az_fuzhu_candidate:
|
|
|
+ print(input[0])
|
|
|
+ print(input[1][0])
|
|
|
+ print(input[1][1])
|
|
|
+ return fuzhu_util(city,input[0], [x[2] for x in input[1][0]], label, aiclient, qwclient, client),input[1][1],input[1][0]
|
|
|
+ return [],{},[]
|
|
|
+def select_fuzhu(city,input, label, aiclient, qwclient, client):
|
|
|
+ if label_name[input[0]] in fuzhu_candidate:
|
|
|
+ print(input[0])
|
|
|
+ print(input[1][0])
|
|
|
+ print(input[1][1])
|
|
|
+ return fuzhu_util(city,input[0], [x[2] for x in input[1][0]], label, aiclient, qwclient, client),input[1][1],input[1][0]
|
|
|
+ return [],{},[]
|
|
|
+def callzailonggu_0113(data):
|
|
|
+ time.sleep(1)
|
|
|
+ completion = aiclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ model="glm-4.5-flash",
|
|
|
+ #model="ZhipuAI/GLM-4.5",
|
|
|
+ #model="qwen3-4b",
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant."},
|
|
|
+ {"role": "user", "content": " 天棚工程有多种做法,包括单纯抹灰,单纯天棚面层,也可以制作龙骨并在龙骨上安装面层等。龙骨包括方木龙骨,轻钢龙骨,铝合金龙骨等。 现在给定一工作内容如下: " + data['label'] + " " + data['mc'] + " " + data['tz'] + ", 计量单位为" + data['dw'] + ", 请问该工作内容中包括了龙骨吗?"},
|
|
|
+ ],
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ time.sleep(1)
|
|
|
+ completion = simpleclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ model=simplemodel(),
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
|
|
|
+ {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了关于是否包括龙骨的判断,请将该判断输出。 例如:"+'''
|
|
|
+ {
|
|
|
+ '判断':'不包括'
|
|
|
+ }
|
|
|
+ '''},
|
|
|
+ ],
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ return json_string
|
|
|
+def callzaikuailiao_0112(data):
|
|
|
+ time.sleep(1)
|
|
|
+ completion = aiclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ model="glm-4.5-air",
|
|
|
+ #model="ZhipuAI/GLM-4.5",
|
|
|
+ #model="qwen3-4b",
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant."},
|
|
|
+ {"role": "user", "content": " 墙柱面有多种做法,包括单纯抹灰,镶贴块料面层,使用墙板等。块料面层常见的有石材块料面板,瓷砖,面砖,假麻石块等。 现在给定一工作内容如下: " + data['label'] + " " + data['mc'] + " " + data['tz'] + ", 计量单位为" + data['dw'] + ", 请问该工作内容中包括了块料面层施工吗?"},
|
|
|
+ ],
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ time.sleep(1)
|
|
|
+ completion = simpleclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ model=simplemodel(),
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
|
|
|
+ {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了关于是否包括块料面层施工的判断,请将该判断输出。 例如:"+'''
|
|
|
+ {
|
|
|
+ '判断':'不包括'
|
|
|
+ }
|
|
|
+ '''},
|
|
|
+ ],
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ return json_string
|
|
|
+def callzaikuailiao(data):
|
|
|
+ time.sleep(1)
|
|
|
+ completion = aiclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ model="glm-4.5-flash",
|
|
|
+ #model="ZhipuAI/GLM-4.5",
|
|
|
+ #model="qwen3-4b",
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant."},
|
|
|
+ {"role": "user", "content": " 楼地面有多种做法,包括整体面层,块料面层,木地板等。块料面层常见的有石材块料面板,缸砖,马赛克,假麻石块,地砖,橡胶塑料板等。 现在给定一工作内容如下: " + data['label'] + " " + data['mc'] + " " + data['tz'] + ", 计量单位为" + data['dw'] + ", 请问该工作内容中包括了块料面层施工吗?"},
|
|
|
+ ],
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ time.sleep(1)
|
|
|
+ completion = simpleclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ model=simplemodel(),
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
|
|
|
+ {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了关于是否包括块料面层施工的判断,请将该判断输出。 例如:"+'''
|
|
|
+ {
|
|
|
+ '判断':'不包括'
|
|
|
+ }
|
|
|
+ '''},
|
|
|
+ ],
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ return json_string
|
|
|
+def youqi_(tz):
|
|
|
+ completion = aiclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ model="glm-4.5-air",
|
|
|
+ #model="qwen3-4b",
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant.请将结果以json格式输出"},
|
|
|
+ {"role": "user", "content": " 金属结构的油漆一般是多层涂刷,常规的是包括底漆跟面漆。也可能是底漆,中间漆再加面漆。金属结构有时需要涂刷防火涂料。但是防火涂料跟油漆不是一回事。现在给定一工作内容如下: " + tz + ", 请将该工作内容中的油漆相关内容原封不动地抽取出来。请勿抽取防火涂料相关内容。如果工作内容中完全没有提到油漆,则返回”无“"},
|
|
|
+ ],
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ return json_string
|
|
|
+def callzaiclarify(data):
|
|
|
+ completion = aiclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ model="glm-4.5-air",
|
|
|
+ #model="qwen3-4b",
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant."},
|
|
|
+ {"role": "user", "content": " 管桩的清单工作内容描述可以分成两类,一类是打桩、压桩,属于桩基工程的一种,其工作内容计量的单位一般是米(m)或根。另一类是填芯,一般是向桩芯内浇混凝土,属于土建工程的一种,其配套的计量单位一般是立方米(m3),即浇混凝土的体积量。现在给定一工作内容如下: " + data['label'] + " " + data['mc'] + " " + data['tz'] + ", 计量单位为" + data['dw'] + ", 请问该工作内容属于填芯吗?"},
|
|
|
+ ],
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ completion = simpleclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ model=simplemodel(),
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
|
|
|
+ {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了关于是不是填芯的判断,请将该判断输出。请输出是或者否"},
|
|
|
+ ],
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ return json_string
|
|
|
+def callzaidw(A,B):
|
|
|
+ time.sleep(1)
|
|
|
+ completion = aiclient.chat.completions.create(
|
|
|
+ model='glm-4.5-air',
|
|
|
+ ##stream=True,
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant."},
|
|
|
+ {"role": "user", "content": " 计量单位可以用名称或者符号表示,常用的符号包括表示米的符号m,表示千米的符号km,表示吨的符号t,表示千克的符号kg,表示平方米的符号m2,表示立方米的符号m3。也有计量单位很宽泛,比如“项”、“次”. 给定一个工作量计量单位,内容为" + A + ",记作A,再给定一个工作量计量单位,内容为" + B + ",记作B。若两个单位相等,请返回A=B。例如,“项”跟“次”是等价的,应返回A=B。若两个单位不相等,但是存在比例换算关系,请返回比例换算关系,例如A单位是m,B单位是10m, 则返回A=0.1*B。再例如,A单位是10m2,B单位是m2,则返回A=10*B。再例如,A单位是m3, B单位是1000m3,则返回A=0.001*B。若两个单位不相等,且不存在比例换算关系,请返回A<>B,例如A单位是m,B单位是m2,一个表示长度,一个表示面积,不存在比例关系,则返回A<>B。 "},
|
|
|
+ ],
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ time.sleep(1)
|
|
|
+ completion = simpleclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ #model="THUDM/GLM-4-9B-0414",
|
|
|
+ model=simplemodel(),
|
|
|
+ #model="glm-4.5-flash",
|
|
|
+ messages=expression(json_string),
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ return json_string
|
|
|
+
|
|
|
+
|
|
|
+def callzai(A,B,C):
|
|
|
+ completion = qwclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ #model="glm-4.5-flash",
|
|
|
+ model="Qwen/Qwen3-32B",
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant."},
|
|
|
+ {"role": "user", "content": " 给定一条主定额,内容为" + A + ",记作A,再给定一条配套定额,内容为" + B + ",记作B。可以通过简单的组合,来表达对应的工作内容的数量,比如A+B可以表达,主定额的工作量加上配套定额的工作量;再比如,A+B*2可以表达, 主定额的工作量加上两倍的配套定额的工作量;再比如,A+B*(-2)可以表达, 主定额减去两倍的配套定额的工作量;再比如,A可以表示,不使用配套定额,仅表示主定额的工作量。现在给你一条工程量清单,内容为" + C + ",该条清单包含了主定额描述的工作内容,但是数量并不一定一致。请你找到清单中对应的描述(不需要考虑龙骨类型是否完全一致,不需要考虑混凝土强度等级是否完全一致,需要区分面层和找平找坡层),辨识出工作数量(砂浆保护层厚度跟砂浆找平层厚度不可合并),并组合A与B,表示出清单描述的对应工作数量。请给出分析过程,并请最终输出类似A+B、A+B*2、A-B*2的格式,不要输出A+2*B、A-2*B的格式。如果清单里相应工作量的描述不明确,请输出A作为答案 "},
|
|
|
+ ],
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ extra_body={"enable_thinking": False},
|
|
|
+ #extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ print(json_string)
|
|
|
+ if len(json_string) < 4:
|
|
|
+ return "result:" + json_string
|
|
|
+ completion = simpleclient.chat.completions.create(
|
|
|
+ # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
+ model=simplemodel(),
|
|
|
+ #model="THUDM/GLM-4-9B-0414",
|
|
|
+ messages=[
|
|
|
+ {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
|
|
|
+ {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一个类似于A+B的表达式作为答案,请将该最终答案输出.如果文字中指出可能有两种答案,则只需要输出其中一种。例如" +'''
|
|
|
+ [
|
|
|
+ 'result' : 'A+B*-2'
|
|
|
+ }
|
|
|
+ 注意,只需要输出最终答案,不需要中间过程或者其他细节,只需要输出一种答案
|
|
|
+ '''
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
+ # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
+ )
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
+ return json_string
|
|
|
+
|
|
|
+def transform(answer, input, entry):
|
|
|
+ answers = answer.split("\n")
|
|
|
+ answers = [x for x in answers if ':' in x and "A" in x]
|
|
|
+ if len(answers) == 0:
|
|
|
+ return input
|
|
|
+ answers[0] = answers[0].split(',')[0]
|
|
|
+ answer2 = answers[0].split(":")[1].replace(" ", "")
|
|
|
+ if 'B' in answer2:
|
|
|
+ answer2 = answer2.replace("B", 'BBB')
|
|
|
+ answer2 = answer2.replace("A", input)
|
|
|
+ answer2 = answer2.replace("BBB", "["+entry+"]")
|
|
|
+ else:
|
|
|
+ answer2 = answer2.replace("A", input)
|
|
|
+ answer2 = answer2.replace("\'", "")
|
|
|
+ answer2 = answer2.replace("\"", "")
|
|
|
+ return answer2
|
|
|
+
|
|
|
+def zuhe(input, content, bianma):
|
|
|
+ if bianma.startswith('01') and input in incremental and input != '17-176' and input != '17-177' and input != '17-179' and input != '17-180' and input != '17-181' and input != '15-33' and input != '1534' and input != '15-35' and input != '15-36' and input != '15-37' and input != '15-38' and input != '15-39' and input != '15-40' and input != '15-41':
|
|
|
+ option = incremental[input]
|
|
|
+ for entry in option:
|
|
|
+ answer = callzai(name_label[input], name_label[entry], content)
|
|
|
+ print("answer of callai for zuhe")
|
|
|
+ print(answer)
|
|
|
+ if 'B' in answer:
|
|
|
+ return transform(answer, input, entry)
|
|
|
+ return input
|
|
|
+ else:
|
|
|
+ return input
|
|
|
+def huansuan_highlevel(bianma, label, input,dw, tz):
|
|
|
+ time.sleep(1)
|
|
|
+ t = huansuan(input, dw, label)
|
|
|
+ if t == 0 or bianma.startswith('030901013'):## 灭火器
|
|
|
+ dw1 = input
|
|
|
+ dw1 = dw1.lower()
|
|
|
+ dw1 = dw1.replace("水平投影面积", "")
|
|
|
+ dw1 = dw1.replace("每1m2建筑面积", "m2")
|
|
|
+ dw2 = label_dw[label]
|
|
|
+ dw2 = dw2.lower()
|
|
|
+ dw2 = dw2.replace("水平投影面积", "")
|
|
|
+ dw2 = dw2.replace("每1m2建筑面积", "m2")
|
|
|
+ answer = callzaihuansuan(bianma, label, dw1,dw2,tz, aiclient, qwclient, simpleclient)
|
|
|
+ answers = answer.split("\n")
|
|
|
+ answers = [x for x in answers if ':' in x and "A" in x]
|
|
|
+ answers = [x for x in answers if '=' in x or '<>' in x]
|
|
|
+ print("answer of callzaihuansuan")
|
|
|
+ print(answers)
|
|
|
+ if len(answers) == 0:
|
|
|
+ return 0
|
|
|
+ answer2 = answers[0].split(":")[1].replace(" ", "")
|
|
|
+ if "<>" in answer2:
|
|
|
+ return 0
|
|
|
+ answer2 = answer2.replace("\'", "")
|
|
|
+ answer2 = answer2.replace("\"", "")
|
|
|
+ answer2 = answer2.split("=")[1]
|
|
|
+ if answer2 == "B":
|
|
|
+ return 1
|
|
|
+ answer2=answer2.replace("B", "")
|
|
|
+ answer2=answer2.replace("*", "")
|
|
|
+ answer2=answer2.replace("x", "")
|
|
|
+ answer2=answer2.replace(",", "")
|
|
|
+ answer2=answer2.replace(",", "")
|
|
|
+ answer2=answer2.replace("×", "")
|
|
|
+ print(answer2)
|
|
|
+ return float(answer2)
|
|
|
+ else:
|
|
|
+ if '人工修边坡' in label:
|
|
|
+ return t * 0.1
|
|
|
+ else:
|
|
|
+ return t
|
|
|
+
|
|
|
+
|
|
|
+def huansuan(input, dw, label):
|
|
|
+ dw1 = input
|
|
|
+ dw1 = dw1.lower()
|
|
|
+ dw1 = dw1.replace("水平投影面积", "")
|
|
|
+ dw1 = dw1.replace("每1m2建筑面积", "m2")
|
|
|
+ dw2 = label_dw[label]
|
|
|
+ dw2 = dw2.lower()
|
|
|
+ dw2 = dw2.replace("水平投影面积", "")
|
|
|
+ dw2 = dw2.replace("每1m2建筑面积", "m2")
|
|
|
+ if dw1 == dw2:
|
|
|
+ return 1
|
|
|
+ if dw1 == 'm2' and dw2 == '10m2':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == 'm2' and dw2 == '100m2':
|
|
|
+ return 0.01
|
|
|
+ if dw1 == 'm2' and dw2 == '1000m2':
|
|
|
+ return 0.001
|
|
|
+ if dw1 == 'm' and dw2 == '10m':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == 'm' and dw2 == '100m':
|
|
|
+ return 0.01
|
|
|
+ if dw1 == 'm3' and dw2 == '10m3':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == 'm3' and dw2 == '100m3':
|
|
|
+ return 0.01
|
|
|
+ if dw1 == 'm3' and dw2 == '1000m3':
|
|
|
+ return 0.001
|
|
|
+ if dw1 == '个' and dw2 == '10个':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == '套' and dw2 == '10套':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == '具' and dw2 == '10具':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == 'kg' and dw2 == '100kg':
|
|
|
+ return 0.01
|
|
|
+ if dw1 == '个' and dw2 == '套':
|
|
|
+ return 1
|
|
|
+ if dw1 == '个' and dw2 == '10套':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == '个' and dw2 == '台':
|
|
|
+ return 1
|
|
|
+ if dw1 == '个' and dw2 == '10台':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == '台' and dw2 == '个':
|
|
|
+ return 1
|
|
|
+ if dw1 == '台' and dw2 == '10个':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == '台' and dw2 == '套':
|
|
|
+ return 1
|
|
|
+ if dw1 == '台' and dw2 == '10套':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == '组' and dw2 == '10组':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == '组' and dw2 == '套':
|
|
|
+ return 1
|
|
|
+ if dw1 == '组' and dw2 == '10套':
|
|
|
+ return 0.1
|
|
|
+ if dw1 == 'm' and dw2 == '100m单线':
|
|
|
+ return 0.01
|
|
|
+ if dw1 == '项' and dw2 == '次':
|
|
|
+ return 1
|
|
|
+
|
|
|
+ else:
|
|
|
+ answer = callzaidw(dw1,dw2)
|
|
|
+ answers = answer.split("\n")
|
|
|
+ answers = [x for x in answers if ':' in x and "A" in x]
|
|
|
+ answers = [x for x in answers if '=' in x or '<>' in x]
|
|
|
+ answers = [x for x in answers if not has_chinese(x)]
|
|
|
+ print(answers)
|
|
|
+ if len(answers) == 0:
|
|
|
+ return 0
|
|
|
+ answer2 = answers[0].split(":")[1].replace(" ", "")
|
|
|
+ if "<>" in answer2:
|
|
|
+ return 0
|
|
|
+ answer2 = answer2.replace("\'", "")
|
|
|
+ answer2 = answer2.replace("\"", "")
|
|
|
+ answer2 = answer2.replace(",", "")
|
|
|
+ answer2 = answer2.split("=")[1]
|
|
|
+ if answer2 == "B":
|
|
|
+ return 1
|
|
|
+ answer2=answer2.replace("B", "")
|
|
|
+ answer2=answer2.replace("*", "")
|
|
|
+ answer2=answer2.replace("x", "")
|
|
|
+ answer2=answer2.replace("×", "")
|
|
|
+ try:
|
|
|
+ return float(answer2)
|
|
|
+ except:
|
|
|
+ return 1
|
|
|
+
|
|
|
+def clarify(data):
|
|
|
+ data['tz'] = data['tz'].replace('DTG', '')
|
|
|
+ data['tz'] = data['tz'].replace("聚合物水泥砂浆修补墙面", "")
|
|
|
+ data['tz'] = data['tz'].replace('DTA', '')
|
|
|
+ data['tz'] = data['tz'].replace('DS M15', '1:3水泥砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DSM15', '1:3水泥砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DP M15', '1:3水泥砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DPM15', '1:3水泥砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DS M20', '1:2.5水泥砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DSM20', '1:2.5水泥砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DP M20', '1:2.5水泥砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DPM20', '1:2.5水泥砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DP(DCA)M20', '1:2.5水泥砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DP(DCA) M20', '1:2.5水泥砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DP(DCA)M5', '1:1:6混合砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DP(DCA) M5', '1:1:6混合砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DP M5', '1:1:6混合砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DPM5', '1:1:6混合砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DP MS', '1:1:6混合砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DPMS', '1:1:6混合砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DP(DCA)M10', '1:0.5:3混合砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DP(DCA) M10', '1:0.5:3混合砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DP M10', '1:0.5:3混合砂浆')
|
|
|
+ data['tz'] = data['tz'].replace('DPM10', '1:0.5:3混合砂浆')
|
|
|
+ data['tz'] = data['tz'].replace("水泥基防水涂料", "水泥基渗透结晶防水涂料")
|
|
|
+ data['tz'] = data['tz'].replace("回光灯带", "回光灯槽")
|
|
|
+ data['mc'] = data['mc'].replace("回光灯带", "回光灯槽")
|
|
|
+ data['tz'] = data['tz'].replace("自流平", "自流平地面")
|
|
|
+ data['tz'] = data['tz'].replace("JS防水涂料", "聚合物水泥防水涂料")
|
|
|
+ data['tz'] = data['tz'].replace("聚合物水泥砂浆", "防水砂浆")
|
|
|
+ data['tz'] = data['tz'].replace("丝杆", "丝杆吊筋")
|
|
|
+ data['tz_bak'] = data['tz']
|
|
|
+ if data['bianma'].startswith("010301"):##打桩
|
|
|
+ print("clarify")
|
|
|
+ result = callzaiclarify(data)
|
|
|
+ if "是" in result:
|
|
|
+ data['mc'] = data['mc'] + '填芯'
|
|
|
+ return data, False
|
|
|
+ elif data['bianma'].startswith("010606012"): ##钢支架
|
|
|
+ if '镀锌方管' in data['tz'] or '镀锌圆管' in data['tz'] or '镀锌钢管' in data['tz'] or '镀锌角钢' in data['tz']:
|
|
|
+ data['tz'] = data['tz'].replace('支架', '骨架')
|
|
|
+ data['tz'] = data['tz'].replace('基架', '骨架')
|
|
|
+ data['mc'] = '钢骨架'
|
|
|
+ return data, False
|
|
|
+ elif data['bianma'].startswith("010507001"): ##散水、坡道
|
|
|
+ data['tz'] = lingji(data['tz'], aiclient, qwclient)
|
|
|
+ data['tz'] = dianceng(data['tz'], aiclient, qwclient)
|
|
|
+ data['tz'] = mianceng(data['tz'], aiclient, qwclient)
|
|
|
+ data['tz'] = jieheceng(data['tz'], aiclient, qwclient)
|
|
|
+ return data, False
|
|
|
+ elif data['bianma'].startswith("0109"): ##防水
|
|
|
+ data['tz'] = lingji(data['tz'], aiclient, qwclient)
|
|
|
+ data['tz'] = dianceng(data['tz'], aiclient, qwclient)
|
|
|
+ data['tz'] = jieheceng(data['tz'], aiclient, qwclient)
|
|
|
+ return data, False
|
|
|
+ elif data['bianma'].startswith("0111"):
|
|
|
+ data['tz'] = data['tz'].replace("卷材面层", "面层")
|
|
|
+ if data['bianma'].startswith("011107"):##台阶
|
|
|
+ data['mc'] = '台阶面'
|
|
|
+
|
|
|
+ data['tz'] = jieheceng(data['tz'], aiclient, qwclient)
|
|
|
+ result = callzaikuailiao(data)
|
|
|
+ if '不' in result:
|
|
|
+ return data, False
|
|
|
+ return data, True
|
|
|
+ elif data['bianma'].startswith("0112"):
|
|
|
+ if '镀锌方管' in data['tz'] or '镀锌圆管' in data['tz'] or '镀锌钢管' in data['tz'] or '镀锌角钢' in data['tz']:
|
|
|
+ data['tz'] = data['tz'].replace('支架', '骨架')
|
|
|
+ data['tz'] = data['tz'].replace('基架', '骨架')
|
|
|
+ data['tz'] = data['tz'].replace("铝单板", "铝单板幕墙")
|
|
|
+ data['tz'] = data['tz'].replace("阻燃板", "细木工板")
|
|
|
+ data['tz'] = data['tz'].replace("阻燃基层板", "细木工板")
|
|
|
+ data['tz'] = data['tz'].replace("岩棉板", "岩棉吸音板")
|
|
|
+ data['tz'] = data['tz'].replace("吸音材料", "岩棉吸音板")
|
|
|
+ data['tz'] = data['tz'].replace("水泥纤维板", "水泥压力板")
|
|
|
+ if '防潮层' in data['tz'] or '防水砂浆' in data['tz']:
|
|
|
+ data['mc']='墙柱面防水(防潮)'
|
|
|
+ result = callzaikuailiao_0112(data)
|
|
|
+ if '不' in result:
|
|
|
+ return data, False
|
|
|
+ return data, True
|
|
|
+ elif data['bianma'].startswith("0113"):
|
|
|
+ result = callzailonggu_0113(data)
|
|
|
+ if '不' in result:
|
|
|
+ return data, False
|
|
|
+ if not '上人' in data['tz']:
|
|
|
+ data['tz']=data['tz'].replace('龙骨','不上人型龙骨')
|
|
|
+ data['tz']=data['tz'].replace('铝格栅','铝格栅吊顶')
|
|
|
+ data['tz']=data['tz'].replace('纸面石膏板','纸面石膏板面层')
|
|
|
+ return data, True
|
|
|
+ elif data['bianma'].startswith("0117"):
|
|
|
+ data['mc']=data['mc'].replace('线条','檐沟')
|
|
|
+ data['tz']=data['tz'].replace('线条','檐沟')
|
|
|
+ return data, False
|
|
|
+ elif data['bianma'].startswith('0308'):
|
|
|
+ data['tz'] = data['tz'].replace('增强柔性石墨板', '增强柔性石墨板制作三通补强圈')
|
|
|
+ return data, False
|
|
|
+ else:
|
|
|
+ return data, False
|
|
|
+
|
|
|
+from redis.exceptions import TimeoutError
|
|
|
+@celery_app.task(autoretry_for=(TimeoutError,))
|
|
|
+def process_data(data:dict)-> dict:
|
|
|
+ placeholder, kuailiao = clarify(data)
|
|
|
+ label = data['mc'] + ' ' + data['tz']
|
|
|
+ if data['bianma'].startswith("0117"):
|
|
|
+ label = data['label'] + " " + data['mc'] + " " + data['tz']
|
|
|
+ sentences = [label]
|
|
|
+ if data['bianma'].startswith("0117"):
|
|
|
+ embeddings = cuoshi_model.encode(sentences)
|
|
|
+ elif data['bianma'].startswith('03'):
|
|
|
+ embeddings = azmodel.encode(sentences)
|
|
|
+ else:
|
|
|
+ embeddings = model.encode(sentences)
|
|
|
+ if data['bianma'].startswith("0117"):
|
|
|
+ result = cuoshi_collection.query(query_embeddings=embeddings,n_results=25)
|
|
|
+ elif data['bianma'].startswith('030810'):
|
|
|
+ result = azcollection.query(query_embeddings=embeddings, n_results=10, where_document={"$contains": "低压法兰"})
|
|
|
+ elif data['bianma'].startswith('030412'):
|
|
|
+ result = azcollection.query(query_embeddings=embeddings, n_results=10, where_document={"$contains": "照明器具"})
|
|
|
+ elif data['bianma'].startswith('030108'):
|
|
|
+ result = azcollection.query(query_embeddings=embeddings, n_results=10, where_document={"$contains": "风机"})
|
|
|
+ elif data['bianma'].startswith('030502007') or data['bianma'].startswith('030502008'):
|
|
|
+ result = azcollection.query(query_embeddings=embeddings, n_results=10, where_document={"$contains": "布放光缆"})
|
|
|
+ elif data['bianma'].startswith('03'):
|
|
|
+ result = azcollection.query(query_embeddings=embeddings,n_results=25)
|
|
|
+ else:
|
|
|
+ result = collection.query(query_embeddings=embeddings,n_results=25)
|
|
|
+ yqspecial=[]
|
|
|
+ if data['bianma'].startswith('0106'):
|
|
|
+ youqi = youqi_(data['tz'])
|
|
|
+ if '无' not in youqi:
|
|
|
+ yqspecial= f_youqi(data, youqi,collection,model,ce,name_label)
|
|
|
+ d = result['documents'][0]
|
|
|
+ print(d)
|
|
|
+ if data['bianma'].startswith("0117"):
|
|
|
+ ranks = cuoshi_ce.rank(label, d)
|
|
|
+ elif data['bianma'].startswith('03'):
|
|
|
+ ranks = azce.rank(label, d)
|
|
|
+ else:
|
|
|
+ ranks = ce.rank(label, d)
|
|
|
+ if data['bianma'].startswith("0117"):
|
|
|
+ cutoff = 0.6
|
|
|
+ else:
|
|
|
+ cutoff = THRESHOLD
|
|
|
+
|
|
|
+ ranks = ranks[:10]
|
|
|
+ match = [("6.2.1.1","6.3.1.1"),
|
|
|
+ ("6.2.1.2", "6.3.1.2"),
|
|
|
+ ("6.2.1.3", "6.3.1.3"),
|
|
|
+ ("6.2.1.4", "6.3.1.4"),
|
|
|
+ ("6.2.1.5", "6.3.1.5"),
|
|
|
+ ("6.2.1.6", "6.3.1.6"),
|
|
|
+ ("6.2.2.1", "6.3.2.1"),
|
|
|
+ ("6.2.2.2", "6.3.2.2"),
|
|
|
+ ("6.2.3.1", "6.3.3.1"),
|
|
|
+ ("6.2.3.2", "6.3.3.2"),
|
|
|
+ ("6.2.3.3", "6.3.3.3"),
|
|
|
+ ("6.2.3.4", "6.3.3.4"),
|
|
|
+ ("6.2.3.5", "6.3.3.5"),
|
|
|
+ ("6.2.3.6", "6.3.3.6")]
|
|
|
+ match2=[
|
|
|
+ ("1.1.7", "nantong1.1.7"),
|
|
|
+ ("nantong2.1.2", "2.1.2"),
|
|
|
+ ("nantong3.1.2", "3.1.2"),
|
|
|
+ ("nantong3.1.4", "3.1.4"),
|
|
|
+ ("nantong3.1.5", "3.1.5"),
|
|
|
+ ("3.2.10", "nantong3.2.10"),
|
|
|
+ ("nantong4.1.1", "4.1.1"),
|
|
|
+ ("nantong4.1.2", "4.1.2"),
|
|
|
+ ("nantong4.1.3", "4.1.3"),
|
|
|
+ ("4.1.4", "nantong4.1.4"),
|
|
|
+ ("4.1.5", "nantong4.1.5"),
|
|
|
+ ("4.1.7", "nantong4.1.7"),
|
|
|
+ ("4.4", "nantong4.4"),
|
|
|
+ ("nantong6", "6"),
|
|
|
+ ("7.5", "nantong7.5"),
|
|
|
+ ("nantong7.8", "7.8"),
|
|
|
+ ("10.1.5", "nantong10.1.5"),
|
|
|
+ ("10.1.2", "nantong10.1.2"),
|
|
|
+ ("10.1.1", "nantong10.1.1"),
|
|
|
+ ("nantong10.1.1.2", "10.1.1.2"),
|
|
|
+ ("10.1.1.3", "nantong10.1.1.3"),
|
|
|
+ ("nantong11.1.2.1", "11.1.2.1"),
|
|
|
+ ("nantong11.1.2.2", "11.1.2.2"),
|
|
|
+ ("nantong11.1.1", "11.1.1"),
|
|
|
+ ("12.7", "nantong12.7"),
|
|
|
+ ("12.6", "nantong12.6"),
|
|
|
+ ("nantong12.5", "12.5"),
|
|
|
+ ("nantong13.1.1", "13.1.1"),
|
|
|
+ ("nantong13.1.2" , "13.1.2"),
|
|
|
+ ("nantong13.1.3", "13.1.3"),
|
|
|
+ ("nantong13.2.2", "13.2.2"),
|
|
|
+ ("nantong13.3.1", "13.3.1"),
|
|
|
+ ("nantong13.3.2", "13.3.2"),
|
|
|
+ ("13.3.3" ,"nantong13.3.3"),
|
|
|
+ ("13.4.4", "nantong13.4.4"),
|
|
|
+ ("nantong13.5.1", "13.5.1"),
|
|
|
+ ("13.5.4", "nantong13.5.4"),
|
|
|
+ ("nantong14.3.8", "14.3.8"),
|
|
|
+ ("14.4.4", "nantong14.4.4"),
|
|
|
+ ("14.4.6", "nantong14.4.6"),
|
|
|
+ ("nantong15.3.1", "15.3.1"),
|
|
|
+ ("16.2", "nantong16.2"),
|
|
|
+ ("17.1.3.2", "nantong17.1.3.2"),
|
|
|
+ ("17.1.3.3","nantong17.1.3.3"),
|
|
|
+ ("17.1.3.4","nantong17.1.3.4"),
|
|
|
+ ("18.3.3","nantong18.3.3"),
|
|
|
+ ("18.3.2","nantong18.3.2"),
|
|
|
+ ("18.5","nantong18.5"),
|
|
|
+ ("18.6","nantong18.6"),
|
|
|
+ ("18.15","nantong18.15"),
|
|
|
+ ("20.1.1","nantong20.1.1"),
|
|
|
+ ("20.1.2.1","nantong20.1.2.1"),
|
|
|
+ ("20.1.2.3","nantong20.1.2.3"),
|
|
|
+ ("20.1.2.5","nantong20.1.2.5"),
|
|
|
+ ("21.1.1.1","nantong21.1.1.1"),
|
|
|
+ ("21.1.1.2","nantong21.1.1.2"),
|
|
|
+ ("21.1.3.1","nantong21.1.3.1"),
|
|
|
+ ("21.1.3.2","nantong21.1.3.2"),
|
|
|
+ ("21.1.3.3","nantong21.1.3.3"),
|
|
|
+ ("21.1.5","nantong21.1.5"),
|
|
|
+ ("21.1.6","nantong21.1.6"),
|
|
|
+ ("21.1.7","nantong21.1.7"),
|
|
|
+ ("23.1.2","nantong23.1.2")
|
|
|
+ ]
|
|
|
+ match3=[('16.1', '16.2'), ('16.1.1', '16.2.1')]
|
|
|
+ selected=[]
|
|
|
+ notselected=[]
|
|
|
+ #if data['bianma'].startswith('0108'): ##门窗
|
|
|
+ # score = -1
|
|
|
+ # for rank in ranks:
|
|
|
+ # if label_name[d[rank['corpus_id']]].startswith('16-') and int(label_name[d[rank['corpus_id']]].split('-')[1]) < 308:
|
|
|
+ # score = rank['score']
|
|
|
+ # break
|
|
|
+ # if score > -1 and score < cutoff:
|
|
|
+ # cutoff = score - 0.1
|
|
|
+ # if cutoff < 0.3:
|
|
|
+ # cutoff = 0.3
|
|
|
+ if data['bianma'].startswith('0106') and '钢丝网' not in data['mc']:##金属结构
|
|
|
+ score = -1
|
|
|
+ for rank in ranks:
|
|
|
+ if label_name[d[rank['corpus_id']]].startswith('7-') and label_name[d[rank['corpus_id']]] != '7-62' and label_name[d[rank['corpus_id']]] !='7-63':
|
|
|
+ score = rank['score']
|
|
|
+ break
|
|
|
+ if score > -1 and score < cutoff:
|
|
|
+ cutoff = score - 0.01
|
|
|
+ if cutoff < 0.3:
|
|
|
+ cutoff = 0.3
|
|
|
+ if data['bianma'].startswith('0111'):##楼地面
|
|
|
+ score = -1
|
|
|
+ for rank in ranks:
|
|
|
+ if ('13.4' in d[rank['corpus_id']] or '14.3' in d[rank['corpus_id']]) and '块料面层' in d[rank['corpus_id']]:
|
|
|
+ score = rank['score']
|
|
|
+ break
|
|
|
+ if score > -1 and score < cutoff and kuailiao:
|
|
|
+ cutoff = score - 0.01
|
|
|
+ if cutoff < 0.3:
|
|
|
+ cutoff = 0.3
|
|
|
+ if data['bianma'].startswith('0112'):##墙柱面
|
|
|
+ score = -1
|
|
|
+ for rank in ranks:
|
|
|
+ if ('14.3' in d[rank['corpus_id']]) and '块料面层' in d[rank['corpus_id']]:
|
|
|
+ score = rank['score']
|
|
|
+ break
|
|
|
+ if score > -1 and score < cutoff and kuailiao:
|
|
|
+ cutoff = score - 0.01
|
|
|
+ if cutoff < 0.3:
|
|
|
+ cutoff = 0.3
|
|
|
+ if data['bianma'].startswith('0113'):##天棚
|
|
|
+ score = -1
|
|
|
+ for rank in ranks:
|
|
|
+ if '15.1.1' in d[rank['corpus_id']] or '15.1.2' in d[rank['corpus_id']] or '15.1.3' in d[rank['corpus_id']] or '15.1.4' in d[rank['corpus_id']] or '15.1.5' in d[rank['corpus_id']]:
|
|
|
+ score = rank['score']
|
|
|
+ break
|
|
|
+ if score > -1 and score < cutoff and kuailiao:
|
|
|
+ cutoff = score - 0.01
|
|
|
+ if cutoff < 0.3:
|
|
|
+ cutoff = 0.3
|
|
|
+ #if data['bianma'].startswith('030408001'):##电力电缆
|
|
|
+ # score = -1
|
|
|
+ # for rank in ranks:
|
|
|
+ # if '电缆' in d[rank['corpus_id']]:
|
|
|
+ # score = rank['score']
|
|
|
+ # break
|
|
|
+ # if score > -1 and score < cutoff:
|
|
|
+ # cutoff = score - 0.01
|
|
|
+ # if cutoff < 0.3:
|
|
|
+ # cutoff = 0.3
|
|
|
+ if data['bianma'].startswith('030408006'):##电力电缆头
|
|
|
+ score = -1
|
|
|
+ for rank in ranks:
|
|
|
+ if '电缆头' in d[rank['corpus_id']]:
|
|
|
+ score = rank['score']
|
|
|
+ break
|
|
|
+ if score > -1 and score < cutoff:
|
|
|
+ cutoff = score - 0.01
|
|
|
+ if cutoff < 0.3:
|
|
|
+ cutoff = 0.3
|
|
|
+ ranks = [x for x in ranks if '电缆头' in d[x['corpus_id']]]
|
|
|
+ #if data['bianma'].startswith('030108'):##风机安装
|
|
|
+ # score = -1
|
|
|
+ # for rank in ranks:
|
|
|
+ # if '风机' in d[rank['corpus_id']]:
|
|
|
+ # score = rank['score']
|
|
|
+ # break
|
|
|
+ # if score > -1 and score < cutoff:
|
|
|
+ # cutoff = score - 0.01
|
|
|
+ # if cutoff < 0.3:
|
|
|
+ # cutoff = 0.3
|
|
|
+ #if data['bianma'].startswith('030411'):##配管
|
|
|
+ # score = -1
|
|
|
+ # for rank in ranks:
|
|
|
+ # if '第四册' in d[rank['corpus_id']]:
|
|
|
+ # score = rank['score']
|
|
|
+ # break
|
|
|
+ # if score > -1 and score < cutoff:
|
|
|
+ # cutoff = score - 0.01
|
|
|
+ # if cutoff < 0.3:
|
|
|
+ # cutoff = 0.3
|
|
|
+ #if data['bianma'].startswith('031001006'):##水管
|
|
|
+ # score = -1
|
|
|
+ # for rank in ranks:
|
|
|
+ # if '水管' in d[rank['corpus_id']]:
|
|
|
+ # score = rank['score']
|
|
|
+ # break
|
|
|
+ # if score > -1 and score < cutoff:
|
|
|
+ # cutoff = score - 0.01
|
|
|
+ # if cutoff < 0.3:
|
|
|
+ # cutoff = 0.3
|
|
|
+ #if data['bianma'].startswith('030502007') or data['bianma'].startswith('030502008'):##光缆
|
|
|
+ # score = -1
|
|
|
+ # for rank in ranks:
|
|
|
+ # if '敷设光缆' in d[rank['corpus_id']]:
|
|
|
+ # score = rank['score']
|
|
|
+ # break
|
|
|
+ # if score > -1 and score < cutoff:
|
|
|
+ # cutoff = score - 0.01
|
|
|
+ # if cutoff < 0.3:
|
|
|
+ # cutoff = 0.3
|
|
|
+ #if data['bianma'].startswith('030801'):##低压管道
|
|
|
+ # score = -1
|
|
|
+ # for rank in ranks:
|
|
|
+ # if '低压管道' in d[rank['corpus_id']]:
|
|
|
+ # score = rank['score']
|
|
|
+ # break
|
|
|
+ # if score > -1 and score < cutoff:
|
|
|
+ # cutoff = score - 0.01
|
|
|
+ # if cutoff < 0.3:
|
|
|
+ # cutoff = 0.3
|
|
|
+ #if data['bianma'].startswith('030804'):##低压管件
|
|
|
+ # score = -1
|
|
|
+ # for rank in ranks:
|
|
|
+ # if '低压管件' in d[rank['corpus_id']]:
|
|
|
+ # score = rank['score']
|
|
|
+ # break
|
|
|
+ # if score > -1 and score < cutoff:
|
|
|
+ # cutoff = score - 0.01
|
|
|
+ # if cutoff < 0.3:
|
|
|
+ # cutoff = 0.3
|
|
|
+ #if '三通补强圈' in data['tz']:##三通补强圈
|
|
|
+ # score = -1
|
|
|
+ # for rank in ranks:
|
|
|
+ # if '三通补强圈' in d[rank['corpus_id']]:
|
|
|
+ # score = rank['score']
|
|
|
+ # break
|
|
|
+ # if score > -1 and score < cutoff:
|
|
|
+ # cutoff = score - 0.01
|
|
|
+ # if cutoff < 0.3:
|
|
|
+ # cutoff = 0.3
|
|
|
+ print("cutoff=" + str(cutoff))
|
|
|
+ for entry in incremental:
|
|
|
+ notselected = notselected + incremental[entry]
|
|
|
+ notselected=[name_label[x] for x in notselected]
|
|
|
+ for rank in ranks:
|
|
|
+ print(f"{rank['score']} {d[rank['corpus_id']]}")
|
|
|
+ if rank['score']<cutoff:
|
|
|
+ continue
|
|
|
+ if d[rank['corpus_id']] in notselected:
|
|
|
+ if d[rank['corpus_id']] != '盐城补充定额 盐城补充定额2018 平面立面及其它防水 涂刷油类 水泥基渗透结晶防水每增减0.5mm厚':
|
|
|
+ continue
|
|
|
+ else:
|
|
|
+ d[rank['corpus_id']]= '第十章 屋面及防水工程 10.2 平面立面及其它防水 10.2.1 涂刷油类 水泥基渗透结晶 防水材料 二~三遍(厚2mm)'
|
|
|
+ if d[rank['corpus_id']] in notselected:
|
|
|
+ continue
|
|
|
+ print(f"select {rank['score']} {d[rank['corpus_id']]}")
|
|
|
+ selected.append(d[rank['corpus_id']])
|
|
|
+ hunningtu_group = []
|
|
|
+ for entry in obj:
|
|
|
+ if d[rank['corpus_id']] in obj[entry]:
|
|
|
+ hunningtu_group=[entry]
|
|
|
+ if len(hunningtu_group) > 0:
|
|
|
+ for entry in match:
|
|
|
+ if entry[0]==hunningtu_group[0] or entry[1] == hunningtu_group[0]:
|
|
|
+ notselected = notselected + obj[entry[0]]
|
|
|
+ notselected = notselected + obj[entry[1]]
|
|
|
+ menchuang_group = []
|
|
|
+ for entry in menchuang:
|
|
|
+ if d[rank['corpus_id']] in menchuang[entry]:
|
|
|
+ menchuang_group=[entry]
|
|
|
+ if len(menchuang_group) > 0:
|
|
|
+ for entry in match3:
|
|
|
+ if entry[0]==menchuang_group[0] or entry[1] == menchuang_group[0]:
|
|
|
+ notselected = notselected + menchuang[entry[0]]
|
|
|
+ notselected = notselected + menchuang[entry[1]]
|
|
|
+ nantong_group = []
|
|
|
+ for entry in obj2:
|
|
|
+ if d[rank['corpus_id']] in obj2[entry]:
|
|
|
+ nantong_group=[entry]
|
|
|
+ if len(nantong_group) > 0:
|
|
|
+ for entry in match2:
|
|
|
+ if entry[0]==nantong_group[0] or entry[1] == nantong_group[0]:
|
|
|
+ notselected = notselected + obj2[entry[0]]
|
|
|
+ notselected = notselected + obj2[entry[1]]
|
|
|
+ for entry in basic:
|
|
|
+ if d[rank['corpus_id']] in basic[entry]:
|
|
|
+ notselected = notselected + basic[entry]
|
|
|
+ notselected = [x for x in notselected if x not in selected]
|
|
|
+ selected = list(set(selected))
|
|
|
+ candidates=[]
|
|
|
+ notselected=[]
|
|
|
+ for rank in ranks:
|
|
|
+ if d[rank['corpus_id']] in notselected:
|
|
|
+ continue
|
|
|
+ candidates.append(d[rank['corpus_id']])
|
|
|
+ for entry in basic:
|
|
|
+ if d[rank['corpus_id']] in basic[entry]:
|
|
|
+ notselected = notselected + basic[entry]
|
|
|
+ notselected = [x for x in notselected if x not in candidates]
|
|
|
+ if len(selected) == 0 and not data['bianma'].startswith('0115'):
|
|
|
+ selected = fallback(candidates, data, aiclient, qwclient, simpleclient, menchuang_collection, model)
|
|
|
+ selected = postprocess(selected, data, aiclient, qwclient,simpleclient, label_name, name_dw, candidates,yqspecial)
|
|
|
+ print("final selected")
|
|
|
+ print(selected)
|
|
|
+ result = [(label_name[x], huansuan_highlevel(data['bianma'], x, data['dw'], label_name[x], data['mc']+data['tz'])) for x in selected]
|
|
|
+ print("after haunsuan")
|
|
|
+ print(result)
|
|
|
+ result = [(zuhe(x[0], label, data['bianma']).replace(',',''), x[1]) for x in result]
|
|
|
+ print("after zuhe")
|
|
|
+ print(result)
|
|
|
+ if not data['bianma'].startswith('03'):
|
|
|
+ result = [(x[0], x[1], dedata.read_singledexilie2(10, x[0])) for x in result]
|
|
|
+ result = [(x[0], x[1], x[2], tihuan(x[0], x[2], label, aiclient, qwclient, simpleclient, data)) for x in result]
|
|
|
+ else:
|
|
|
+ result = [(x[0], x[1], buchong(aiclient, dedata.read_singledexilie2(30, x[0]), x[0], data['tz'])) for x in result]
|
|
|
+ result = [(x[0], x[1], x[2], tihuan_az(x[0], x[2], label, aiclient, qwclient, simpleclient, data)) for x in result]
|
|
|
+ fuzhu = [analyze(x[2]) for x in result]
|
|
|
+ fuzhu = zip(selected, fuzhu)
|
|
|
+ fuzhu = [x for x in fuzhu]
|
|
|
+ if not data['bianma'].startswith('03'):
|
|
|
+ fuzhu_selected = [select_fuzhu(data['city'],x, label, aiclient, qwclient, simpleclient) for x in fuzhu]
|
|
|
+ else:
|
|
|
+ fuzhu_selected = [select_fuzhu_az(data['city'], x, label, aiclient, qwclient, simpleclient) for x in fuzhu]
|
|
|
+
|
|
|
+ need = need_extra(data, aiclient, qwclient, simpleclient, result, name_label)
|
|
|
+ replace={}
|
|
|
+ if need:
|
|
|
+ extra_info = extra(data, aiclient, qwclient, simpleclient, menchuang_collection, model, qita_collection)
|
|
|
+ replace['04290241']=extra_info##桩
|
|
|
+ replace['04290303']=extra_info
|
|
|
+ else:
|
|
|
+ extra_info = "无"
|
|
|
+ fy=[]
|
|
|
+ if data['bianma'].startswith('03') and '超高' in data['tz']:
|
|
|
+ fy=feiyong_chaogao(data, [label_name[x] for x in selected], aiclient, qwclient, simpleclient)
|
|
|
+ if len(fy) > 0:
|
|
|
+ fy = dedata.read_singledexilie2(30, fy[0])
|
|
|
+ else:
|
|
|
+ fy = '{}'
|
|
|
+ if data['bianma'].startswith('031301017'):##安装脚手架搭拆
|
|
|
+ print(data['bh'])
|
|
|
+ print(data['name'])
|
|
|
+ qd=anzhuangjsj(data['name'], data['bh'], dbcollection)
|
|
|
+ response = requests.post("http://localhost:3000/api/transform", json={'bianma': data['bianma'], 'mc': data['mc'], 'tz': data['tz'], 'dw': data['dw'], 'sl': data['sl'], 'n': data['n'], "extra": extra_info, 'result':qd, 'fuzhu': [], 'replace': replace, 'fy': fy})
|
|
|
+ return {"result": response.json()}
|
|
|
+ if '高强螺栓' in extra_info:
|
|
|
+ response = requests.post("http://localhost:3000/api/transform", json={'bianma': data['bianma'], 'mc': data['mc'], 'tz': data['tz'], 'dw': data['dw'], 'sl': data['sl'], 'n': data['n'], "extra": extra_info, 'result': [], 'fuzhu': fuzhu_selected, 'replace': replace, 'fy': '{}'})
|
|
|
+ return {"result": response.json()}
|
|
|
+ else:
|
|
|
+ response = requests.post("http://localhost:3000/api/transform", json={'bianma': data['bianma'], 'mc': data['mc'], 'tz': data['tz'], 'dw': data['dw'], 'sl': data['sl'], 'n': data['n'], "extra": extra_info, 'result': result, 'fuzhu': fuzhu_selected, 'replace': replace, 'fy': fy})
|
|
|
+ return {"result": response.json()}
|
|
|
+
|