|
|
@@ -1384,7 +1384,105 @@ async def getJiagongcai(client, id):
|
|
|
return result
|
|
|
|
|
|
|
|
|
+async def getSingleDeXilie_(model, client, zhuanye, debh, mc):
|
|
|
+ db = client["dinge"]
|
|
|
+ collection = db["de-collection"]
|
|
|
+ count = 0
|
|
|
+ actual_zhuanye = []
|
|
|
+ mcs = []
|
|
|
+ if "附注" in debh:
|
|
|
+ position = debh.find("附注")
|
|
|
+ debh = debh[:position]
|
|
|
+ if "*" in debh:
|
|
|
+ position = debh.find("*")
|
|
|
+ debh = debh[:position]
|
|
|
+ if debh.endswith("换"):
|
|
|
+ debh = debh[:-1]
|
|
|
+ if "[" in debh:
|
|
|
+ position = debh.find("[")
|
|
|
+ debh = debh[:position-1]
|
|
|
+ for post in collection.find({'DEBH': debh}):
|
|
|
+ ##print(post)
|
|
|
+ actual_zhuanye.append(post['zhuanye'])
|
|
|
+ mcs.append(post['GCLMC'])
|
|
|
+ count = count + 1
|
|
|
+ if count == 0:
|
|
|
+ return None, None, None, None, None, None, None, zhuanye
|
|
|
+ elif count == 1:
|
|
|
+ if actual_zhuanye[0] == '土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_tj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 10
|
|
|
+ elif actual_zhuanye[0] == '市政':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_sz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 20
|
|
|
+ elif actual_zhuanye[0] == '安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_az(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 30
|
|
|
+ elif actual_zhuanye[0] == '园林':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_yl(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 40
|
|
|
+ elif actual_zhuanye[0] == '修缮工程土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xstj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 50
|
|
|
+ elif actual_zhuanye[0] == '修缮工程安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xsaz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 60
|
|
|
+ else:
|
|
|
+ hit = False
|
|
|
+ for i in range(0, count):
|
|
|
+ if mcs[i] == mc:
|
|
|
+ hit = True
|
|
|
+ actual_zhuanye[0] = actual_zhuanye[i]
|
|
|
+ if hit:
|
|
|
+ if actual_zhuanye[0] == '土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_tj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 10
|
|
|
+ elif actual_zhuanye[0] == '市政':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_sz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 20
|
|
|
+ elif actual_zhuanye[0] == '安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_az(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 30
|
|
|
+ elif actual_zhuanye[0] == '园林':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_yl(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 40
|
|
|
+ elif actual_zhuanye[0] == '修缮工程土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xstj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 50
|
|
|
+ elif actual_zhuanye[0] == '修缮工程安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xsaz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 60
|
|
|
+ else:
|
|
|
+ mcs.append(mc)
|
|
|
+ embeddings = model.encode(mcs)
|
|
|
+ similarities = model.similarity( embeddings[-1], embeddings)
|
|
|
+ ##array([1.0000002, 0.7662151, 1.0000002], dtype=float32)
|
|
|
+ ##print(similarities)
|
|
|
+ sim = similarities[0].numpy()[:-1]
|
|
|
+ ##print(sim)
|
|
|
+ index = np.argmax(sim).item()
|
|
|
+ ##print(index)
|
|
|
+ ##print(actual_zhuanye)
|
|
|
|
|
|
+ actual_zhuanye[0] = actual_zhuanye[index]
|
|
|
+ if actual_zhuanye[0] == '土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_tj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 10
|
|
|
+ elif actual_zhuanye[0] == '市政':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_sz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 20
|
|
|
+ elif actual_zhuanye[0] == '安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_az(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 30
|
|
|
+ elif actual_zhuanye[0] == '园林':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_yl(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 40
|
|
|
+ elif actual_zhuanye[0] == '修缮工程土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xstj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 50
|
|
|
+ elif actual_zhuanye[0] == '修缮工程安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xsaz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 60
|
|
|
|
|
|
async def getSingleDeXilie(model, client, zhuanye, debh, mc):
|
|
|
db = client["dinge"]
|
|
|
@@ -1404,7 +1502,7 @@ async def getSingleDeXilie(model, client, zhuanye, debh, mc):
|
|
|
position = debh.find("[")
|
|
|
debh = debh[:position-1]
|
|
|
async for post in collection.find({'DEBH': debh}):
|
|
|
- print(post)
|
|
|
+ ##print(post)
|
|
|
actual_zhuanye.append(post['zhuanye'])
|
|
|
mcs.append(post['GCLMC'])
|
|
|
count = count + 1
|
|
|
@@ -1459,12 +1557,12 @@ async def getSingleDeXilie(model, client, zhuanye, debh, mc):
|
|
|
embeddings = model.encode(mcs)
|
|
|
similarities = model.similarity( embeddings[-1], embeddings)
|
|
|
##array([1.0000002, 0.7662151, 1.0000002], dtype=float32)
|
|
|
- print(similarities)
|
|
|
+ ##print(similarities)
|
|
|
sim = similarities[0].numpy()[:-1]
|
|
|
- print(sim)
|
|
|
+ ##print(sim)
|
|
|
index = np.argmax(sim).item()
|
|
|
- print(index)
|
|
|
- print(actual_zhuanye)
|
|
|
+ ##print(index)
|
|
|
+ ##print(actual_zhuanye)
|
|
|
|
|
|
actual_zhuanye[0] = actual_zhuanye[index]
|
|
|
if actual_zhuanye[0] == '土建':
|