Browse Source

解决上下文无法识别为招标人却判断为招标人的问题

rogel 4 years ago
parent
commit
9dff223bd1
2 changed files with 10 additions and 6 deletions
  1. 9 5
      BiddingKG/dl/interface/predictor.py
  2. 1 1
      BiddingKG/dl/test/test4.py

+ 9 - 5
BiddingKG/dl/interface/predictor.py

@@ -935,11 +935,15 @@ class RoleRulePredictor():
                         find_flag = False
                         for _name in _list_name:
                             if str(_name).find(p_entity.entity_text)>=0:
-                                find_flag = True
-                                _label = 0
-                                p_entity.label = _label
-                                p_entity.values[int(_label)] = on_value
-                                break
+                                tokens = list_sentence[p_entity.sentence_index].tokens
+                                spans = spanWindow(tokens, p_entity.begin_index, p_entity.end_index, size=15, center_include=True, word_flag=True, use_text=False)
+                                _span_text = "".join(spans)
+                                if str(_span_text).find(_name)>=0:
+                                    find_flag = True
+                                    _label = 0
+                                    p_entity.label = _label
+                                    p_entity.values[int(_label)] = on_value
+                                    break
                         #若是实体在标题中,默认为招标人,不进行以下的规则匹配
                         if find_flag:
                             continue

+ 1 - 1
BiddingKG/dl/test/test4.py

@@ -79,7 +79,7 @@ def predict(doc_id,text):
     codeName = codeNamePredict.predict(list_sentences,list_entitys=list_entitys)
     print(codeName)
     premPredict.predict(list_sentences,list_entitys)
-    roleRulePredict.predict(list_articles,list_sentences, list_entitys,codeName)
+    # roleRulePredict.predict(list_articles,list_sentences, list_entitys,codeName)
     print("epcPredict")
     epcPredict.predict(list_sentences,list_entitys)
     print("entityLink")