莺声燕语 5 місяців тому
батько
коміт
64728c53a0
4 змінених файлів з 13 додано та 6 видалено
  1. 2 1
      configs.py
  2. 1 1
      structure/danti_structure.py
  3. 5 3
      structure/structure_main.py
  4. 5 1
      utils/washutil.py

+ 2 - 1
configs.py

@@ -114,7 +114,8 @@ class ProductionCfg:  # production
     kps_phy_ip = "http:/49.232.72.198:11088/phy_mark_and_connect"
     kps_Hmath_ip = "http://172.16.2.5:13356/auto_labels"
     repeat_ip = "http://10.19.1.18:8866/api/repeat/subject"
-    topic_segment_ip = "http://10.19.1.14:10622/math_phy_TopicSegment_predict"
+    # topic_segment_ip = "http://10.19.1.14:10622/math_phy_TopicSegment_predict"  #CPU
+    topic_segment_ip = "http://10.19.1.10:10622/math_phy_TopicSegment_predict"  #GPU
     phy_topicType_ip = "http://10.19.1.6:10611/phy_topicType_predict"
     callback_url_taskcheck = "http://api.tk.zhixinhuixue.com/v1/interior-api/record"
 

+ 1 - 1
structure/danti_structure.py

@@ -93,7 +93,7 @@ def single_parse(one_item, item_type, wordid, source="zxhx", subject="数学"):
     else:
         new_item_struct = get_slave(new_item_struct, new_item_struct["stem"], new_item_struct["parse"], new_item_struct["key"])
 
-    new_item_struct = wash_after([new_item_struct], subject)[0]
+    new_item_struct = wash_after([new_item_struct], wordid, subject)[0]
     # 换行符替换
     convert_huanhang(new_item_struct)
     # new_item_struct["stem"] = new_item_struct["stem"].strip().replace("\n\n", "\n").replace("\n", "<br/>")  # 2020/4/10 gai

+ 5 - 3
structure/structure_main.py

@@ -14,6 +14,7 @@ from structure.three_parse_structure import *
 from utils.pic_pos_judge import img_regroup
 from func_timeout import func_set_timeout
 import requests
+import time
 from structure.ans_structure import get_ans_match
 
 from utils.xuanzuoti2slave import toslave_bef, toslave_aft
@@ -37,11 +38,12 @@ class WordParseStructure:
         self.subject = subject
 
     def __call__(self):
+        t1 = time.time()
         if self.source in ["school", "qtk"]: #  "school" "xue_guan", "teacher"
             res = self.structure_combine_DL()
             if not res[0]:
                 return self.structure()
-            logger.info("----【paper_id:{}】采用切题服务".format(self.wordid))
+            logger.info("----【paper_id:{}】采用切题服务花费时间:{}".format(self.wordid, time.time()-t1))
             return res
         else:
             return self.structure()
@@ -137,7 +139,7 @@ class WordParseStructure:
             res = list(map(one_item_structure, xyz))  # 和多进程相比,这样速度也很快
             # pprint(res)
             # ==========最后的清洗=========
-            res = wash_after(res, self.subject)
+            res = wash_after(res, self.wordid, self.subject)
             # 针对模型可能切错的地方纠正,放在切割模型预测中纠正了
             # for i, one_item in enumerate(res):
             #     if i>0 and one_item['topic_num'] is None and res[i-1]['topic_num'] is not None and res[i+1]['topic_num'] is not None \
@@ -269,7 +271,7 @@ class WordParseStructure:
                 res = list(map(one_item_structure, xyz))  # 和多进程相比,这样速度也很快
                 # pprint(res)
             # ==========最后的清洗=========
-                res = wash_after(res)
+                res = wash_after(res, self.wordid, self.subject)
                 # if have_slave and not to_slave:
                 #     res = list(map(toslave_aft, res))
             # 结果返回

+ 5 - 1
utils/washutil.py

@@ -24,6 +24,8 @@ from utils.field_eq2latex import get_latex
 from utils.html_again_parse import css_label_wash
 # from structure.structure_main import WordParseStructure
 
+logger = configs.myLog(__name__, log_cate="ruku_log").getlog()
+
 
 def table_label_cleal(con):
     """
@@ -489,7 +491,7 @@ def get_md5(image_id):
     return str(md.hexdigest())
 
 
-def wash_after(res_dict, subject="数学"):
+def wash_after(res_dict, paperid,subject="数学"):
     """
     1.处理最终结果多余的换行符;2.对题文中已给答案的选择填空进行替换;3.选择题的细分
     :param res_dict:
@@ -756,6 +758,7 @@ def wash_after(res_dict, subject="数学"):
         # ----------------------------------------------------------------
     # 物理题型批量调接口:节约时间
     if "物理" in subject:
+        t1 = time.time()
         epoches = int(len(all_content_str_list) / 10)
         pred_topic_types = []
         if epoches > 0:
@@ -790,6 +793,7 @@ def wash_after(res_dict, subject="数学"):
                     if pred_type == "简答题":
                         pred_type = "解答题"
                     res_dict[idx]['type'] = pred_type
+        logger.info("----【paper_id:{}】采用题型预测服务花费time:{}".format(paperid, time.time() - t1))
     # --------------------------------------------------------------
     # 换行符替换
     convert_huanhang(res_dict)