Browse Source

服务期限优先级选择

znj 3 years ago
parent
commit
4ec93f31cb
2 changed files with 9 additions and 7 deletions
  1. 8 6
      BiddingKG/dl/interface/getAttributes.py
  2. 1 1
      BiddingKG/dl/time/re_servicetime.py

+ 8 - 6
BiddingKG/dl/interface/getAttributes.py

@@ -2830,7 +2830,7 @@ def getOtherAttributes(list_entity):
                   "product":[],
                   "total_tendereeMoney":0,
                   "total_tendereeMoneyUnit":''}
-
+    list_serviceTime = []
     for entity in list_entity:
         if entity.entity_type == 'bidway':
             dict_other["bidway"] = turnBidWay(entity.entity_text)
@@ -2838,11 +2838,7 @@ def getOtherAttributes(list_entity):
             dict_other["moneysource"] = entity.entity_text
         elif entity.entity_type=='serviceTime':
             if re.search("[^之]日|天|年|月|周|星期", entity.entity_text) or re.search("\d{4}[\-\./]\d{1,2}", entity.entity_text):
-                if not entity.in_attachment:
-                    dict_other["serviceTime"] = entity.entity_text
-                else:
-                    if not dict_other["serviceTime"]:
-                        dict_other["serviceTime"] = entity.entity_text
+                list_serviceTime.append(entity)
         elif entity.entity_type=="person" and entity.label ==4:
             dict_other["person_review"].append(entity.entity_text)
         elif entity.entity_type=='product':
@@ -2850,6 +2846,12 @@ def getOtherAttributes(list_entity):
         elif entity.entity_type=='money' and entity.notes=='总投资' and dict_other["total_tendereeMoney"]<float(entity.entity_text):
             dict_other["total_tendereeMoney"] = float(entity.entity_text)
             dict_other["total_tendereeMoneyUnit"] = entity.money_unit
+    if list_serviceTime:
+        list_serviceTime.sort(key=lambda x:x.prob,reverse=True)
+        max_prob = list_serviceTime[0].prob
+        max_prob_serviceTime = [ent for ent in list_serviceTime if ent.prob==max_prob]
+        max_prob_serviceTime.sort(key=lambda x:(x.sentence_index,x.begin_index))
+        dict_other["serviceTime"] = max_prob_serviceTime[0].entity_text
 
     dict_other["product"] = list(set(dict_other["product"]))
     return dict_other

+ 1 - 1
BiddingKG/dl/time/re_servicetime.py

@@ -179,7 +179,7 @@ def re_service_time(text):
                 word_index = match.span()
                 word = match.group()
                 instead = "#" * len(word)
-                print("word, instead, word_index", word, instead, word_index)
+                # print("word, instead, word_index", word, instead, word_index)
                 input_str = input_str[:word_index[0]] + instead + input_str[word_index[1]:]
 
         if TEST_MODE: