root 1 week ago
parent
commit
f068009cf2

BIN
ai-slibra-assistant/data/location.xlsx


+ 9 - 4
ai-slibra-assistant/util/request_utils.py

@@ -5,14 +5,14 @@
 @File    : request_utils.py.py
 @Desc    : 
 """
-#import sys
-#sys.path.append("/Users/caoyongchuang/PycharmProjects/predict/ai-slibra-assistant")
+# import sys
+# sys.path.append("..")
 import re
 import os
 import shutil
 import json
 import time
-
+from datetime import datetime
 from config import get_logger
 import requests
 import base64
@@ -278,6 +278,11 @@ def aibot_service(ip ="192.168.100.159",port="40072", nodeId="start", userId='no
 
 if __name__ == "__main__":
     text="欢迎致电“佳木斯龙江环保供水服务热线”。我们最新推出智能语音服务,说话就能查询业务, 抢先体验请按1, 传统服务请按2"
-    print(voice_service(text))
+    #print(voice_service(text))
+    start = datetime.now()
+    business_service('c1001000', '10001', "2.00", "water_info",
+                     "我们家没有水了,春天我回来就一直没有水,是不是你们那边把水给停了")
+    cost = (datetime.now() - start).total_seconds()
+    print(cost)
     #intent_service("1", "没听清", "2200", "1", "10", "1")
     #aibot_service()

+ 10 - 7
ai-slibra-assistant/util/utils.py

@@ -5,8 +5,8 @@
 @File    : utils.py
 @Desc    : 
 """
-import sys
-sys.path.append("..")
+# import sys
+# sys.path.append("..")
 from datetime import datetime
 from functools import wraps
 from typing import (Any,
@@ -169,11 +169,11 @@ CREATE TABLE botrecords (
                                 intent = opt[-1].get("firstclass")
                             else:
                                 intent =opt[-1].get("title", '')
-                            if intent in ["未听清", "打招呼", "准备结束"]:
+                            if intent in ["未听清", "打招呼", "准备结束", "others"]:
                                 intent = "未知意图"
                             if intent in ["", " "]:
                                 intent = "用户未说话"
-                            if code in ["98.00", "1.30"] and intent=="others":
+                            if code in ["98.00", "1.30"] and intent in ["准备结束", "others"]:
                                 intent = "未知意图"
                     elif code == "1.20":
                         tags = {"1": "1_停水咨询", "2":"1_漏水保修", "3":"1_户号查询","4":"1_水费查询", "5":"1_水价咨询","6":"1_水质水价保修", "7":"1_投诉建议", "0":"1_转人工"}
@@ -242,14 +242,17 @@ def norm_community(asr):
     if text in user_dict['pinyin']:
         return user_dict['pinyin'][text]
     words = jieba.lcut(asr)[::-1]
+    if len(words)<=1:
+        return asr
     for word in words:
         if word in user_dict['zh']:
             return user_dict['zh'].get(word)
         term = "|".join([term[0] for term in pinyin(word, style=Style.NORMAL)])
         if term in user_dict['pinyin']:
             return user_dict['pinyin'][term]
-    for r in range(1, min(len(words) + 1, 6)):
-        combinations_list = list(itertools.combinations(words, r))
+    for r in range(2, len(words)):
+        #combinations_list = list(itertools.combinations(words, r))
+        combinations_list =[words[i:i+r] for i in range(1+len(words)-r)]
         features = [executor.submit(match_loc, combo) for combo in combinations_list]
         result =[feature.result() for feature in as_completed(features)]
         res = [i for i in filter(lambda x: x is not None, result)]
@@ -267,7 +270,7 @@ def norm_community(asr):
 
 
 if __name__ == "__main__":
-    asr="宝升三号楼漏水了"
+    asr="嘉熙四合小区"
     print(f"asr:{asr}")
     loc = norm_community(asr)
     print(f"命中小区:{loc}")