Browse Source

优化角色、地址、预处理

lsm 3 ngày trước cách đây
mục cha
commit
d63bf10e6f

+ 3 - 3
BiddingKG/dl/interface/Preprocessing.py

@@ -1829,7 +1829,7 @@ def tableToText(soup, docid=None, return_kv=False):
     # 遍历表格中的每个tbody
     tbodies = []
     in_attachment = False
-    if soup.name=="tbody":
+    if soup.name=="tbody" and soup.get_text().strip() != '': # 20250730 修复 642228216 表格分多个tbody且一三tbody只有tr内容为空导致提取失败
         tbodies.append((soup,in_attachment))
     for _part in soup.find_all():
         if _part.name == 'tbody':
@@ -2547,8 +2547,8 @@ def segment(soup,final=True):
         #     child.insert_after("#sube"+str(child.name)+"#")
         # if child.name in spaceList:
         #     child.insert_after(" ")
-        if child.name in subspaceList and len(child.get_text()) > 5 and re.search('\w$', child.get_text()): # 20250718 补充逗号避免642261504 分隔不了 联系邮箱:2034758276@qq.com中治交通建设集团有限公司北京分公司2025年6月25日,
-            child.insert_after(",")
+        # if child.name in subspaceList and len(child.get_text()) > 5 and re.search('\w$', child.get_text()): # 20250718 补充逗号避免642261504 分隔不了 联系邮箱:2034758276@qq.com中治交通建设集团有限公司北京分公司2025年6月25日, 20250801 注释掉 653089421 等多篇公告公司被span拆分
+        #     child.insert_after(",")
     text = str(soup.get_text())
     #替换英文冒号为中文冒号
     text = re.sub("(?<=[\u4e00-\u9fa5]):|:(?=[\u4e00-\u9fa5])",":",text)

+ 1 - 1
BiddingKG/dl/interface/extract.py

@@ -524,7 +524,7 @@ def predict(doc_id,text,title="",page_time="",web_source_no='',web_source_name="
 
     # data_res = Preprocessing.union_result(Preprocessing.union_result(codeName, prem),list_punish_dic)[0]
     # data_res = Preprocessing.union_result(Preprocessing.union_result(Preprocessing.union_result(codeName, prem),list_punish_dic), list_channel_dic)[0]
-    version_date = {'version_date': '2025-07-29'}
+    version_date = {'version_date': '2025-08-01'}
     data_res = dict(codeName[0], **prem[0], **channel_dic, **product_attrs[0], **product_attrs[1], **payment_way_dic, **fail_reason, **industry, **district, **candidate_dic, **version_date, **all_moneys, **pb_json)
 
     if original_docchannel == 302:

+ 1 - 1
BiddingKG/dl/interface/outline_extractor.py

@@ -98,7 +98,7 @@ def extract_parameters(parse_document):
         # print(_data.keys())
         if _type=="sentence":
             if _data["sentence_title"] is not None:
-                if re.search('[((][一二三四五六七八九十]+[))]|[一二三四五六七八九十]+\s*[..、]|^\d{1,2}[..、][\u4e00-\u9fa5]', _text[:10]):
+                if re.search('[((][一二三四五六七八九十\d]+[))]|[一二三四五六七八九十]+\s*[..、]|^(\d{1,2}[..、]|(\d\.)+\d)[\u4e00-\u9fa5]', _text[:10]):
                     idx = _text.replace(':', ':').find(':')
                     outline_text = _text[:idx] if idx >= 4 else _text
                     # out_lines.append((outline_text, _data['sentence_index'], _data['wordOffset_begin']))

+ 13 - 10
BiddingKG/dl/interface/predictor.py

@@ -881,7 +881,7 @@ class PREMPredict():
             elif label in [2,3,4] and re.search('序号:\d+,\w{,2}候选', front):
                 label = 5
             elif label == 0:
-                if re.search('拟邀请$|受邀谈判方|流入方名称:$|拟选用单位:$|选择(建设|\w{,2})?服务单位:$', front): # 修复 626700009 二、拟选用单位:海南和泰消防技术服务有限公司。 632486555 选择建设服务单位:四川富吉兴工程管理有限公司,
+                if re.search('拟邀请$|受邀谈判方|流入方名称:$|拟(选用|采用|选取)(单位|公司|企业)(名称)?:$|选择(建设|\w{,2})?服务单位:$', front): # 修复 626700009 二、拟选用单位:海南和泰消防技术服务有限公司。 632486555 选择建设服务单位:四川富吉兴工程管理有限公司,  642115802 拟采用公司:山东久木影视传媒有限公司
                     label = 2
                     values[label] = 0.501
                 elif re.search('(发布(人|方|单位|机构|组织|用户|业主|主体|部门|公司|企业)|组织(单位|人|方|机构)?|(采购|招标|发布)机构)(名称)?[是为:]+', front) and is_agency(entity.entity_text):
@@ -981,7 +981,7 @@ class PREMPredict():
                     label = 5
                 elif re.search('委托$', front) and re.search('^(抽样|送检|看样)', behind):
                     label = 5
-                elif re.search('推荐入围的招标代理单位:$|拟确定的招标代理(服务)?(机构|单位)[为:]$', front): # 20240709 修复302505502预测错为代理
+                elif re.search('推荐入围的招标代理单位:$|(拟确定|被选取)?(招标)?代理(服务)?(机构|单位|公司)(名称)?[为:]$', front): # 20240709 修复302505502预测错为代理
                     label = 2
                     values[label] = 0.501
                 elif re.search('代理公司$', front) and re.search('^销售', behind): # 修复 103462671 且该软件平台由博导前程软件公司在浙江的官方代理公司杭州楚沩教育科技有限公司销售。
@@ -1527,8 +1527,8 @@ class RoleRulePredictor():
         self.pattern_agency_right = "(?P<agency_right>^,?([((](以下简称)?[,\"“]*(代理)(人|单位|机构)(名称)?[,\"”]*[))])|^受.{5,20}委托|^受委?托,)"  # |^受托  会与 受托生产等冲突,代理表达一般会在后面有逗号
         # 2020//11/24 大网站规则 中标关键词添加 选定单位|指定的中介服务机构
         self.pattern_winTenderer_left_50 = "(?P<winTenderer_left_51>" \
-               "(乙|竞得|受让|签约|供货|供应?|合作|承做|承包|承建|承销|承保|承接|承制|承担|承修|承租((包))?|入围|入选|竞买)(候选|投标)?(人|单位|机构|供应商|方|公司|企业|厂商|商|社会资本方?|银行)(:?单位名称|:?名称|盖章)?[::是为]+$" \
-               "|(选定单位|指定的中介服务机构|实施主体|中标银行|中标通知书,致|征集结果|选择中介|选择结果|成交对象|勘察人|(,|审计|处置|勘察|设计)服务单位|受托[人方]|直接采购对象)[::是为]+$" \
+               "(乙|竞得|受让|签约|供货|供应?|合作|承办|承做|承包|承建|承销|承保|承接|承制|承担|承修|承租((包))?|入围|入选|竞买|拟采?用)(候选|投标)?(人|单位|机构|供应商|方|公司|企业|厂商|商|社会资本方?|银行)(:?单位名称|:?名称|盖章)?[::是为]+$" \
+               "|(选定单位|指定的中介服务机构|实施主体|中标银行|中标通知书,致|征集结果|选择中介|选择结果|成交对象|勘察人|(,|审计|处置|勘察|设计)服务单位|受托[人方]|(直接)?采购对象)[::是为]+$" \
                "|((评审结果|名次|排名|中标结果)[::]*第?[一1]名?)[::是为]+$|成交供应商信息[,:]?(序号1)?:?|供应商名称$|竞争性选择申请人名称:$" \
                "|单一来源(采购)?(供应商|供货商|服务商|方式向)$|((中标|成交)(结果|信息))[::是为]+$|(中标|成交)供应商、(中标|成交)(金额|价格),$|合作伙伴名称:$|供应商(乙方)-?$|合作单位:$" \
                "|现(公布|宣布|公示)中标单位如下:$|现将中标单位(公布|公示)如下:$|现宣布以下(企业|单位|公司)中标:$|经讨论,决定采用$|第\d+(包件?|标段?)(中标|中选|成交)候选人:$|入围供应商如下(排名不分先后)[,:]$)"  # 承办单位:不作为中标 83914772  |施工 单位不作为中标人 例:386692187 买受人招标公告可能为招标人,拍卖中应该是中标人
@@ -2464,12 +2464,12 @@ class RoleGrade():
         '''
         bid_info = []
         if outlines:
-            win_pattern = re.compile("^([((][一二三四五六七八九十\d]+[))]|[一二三四五六七八九十]+\s*[..、])[预拟]?((中标|中选|成交)((成交))?(人|单位|供应商)?的?(基本|主要)?(信息|情况|概况|结果)(如下)?|[预拟]?(中标|中选|成交)((成交))?(人|供应商|单位)(名称)?(、地址)?([及和]\w{,2}(价格|报价|金额))?(如下)?|中标公示单位:)[,:]?$")
+            win_pattern = re.compile("^([((][一二三四五六七八九十\d]+[))]|[一二三四五六七八九十]+\s*[..、])[预拟]?((中标|中选|成交|(采购|招标|比选|比价)结果)((成交))?(人|单位|供应商)?的?(基本|主要)?(信息|情况|概况|结果)(如下)?|[预拟]?(中标|中选|成交)((成交))?(人|供应商|单位)(名称)?(、地址)?([及和]\w{,2}(价格|报价|金额))?(如下)?|中标公示单位:)[,:]?$")
             for outline in outlines:
                 text_, title_type, title_index, next_index, scope = outline
                 if re.search(win_pattern, text_) and re.search('(未|没|是否)(中标|成交)|中标单位合同签订主体|业绩|提供', text_)==None:
                     bid_info.append(scope)
-                    log("中标大纲:%s, docid:%s"%(text_, docid))
+                    # log("提取的中标大纲:%s, docid:%s"%(text_, docid))
         have_winner = False
         bid_info_company = []
 
@@ -2621,6 +2621,9 @@ class RoleGrade():
                     entity.label = 2
                     entity.values[entity.label] = 0.55
                     log('大纲规则补充中标人:%s, docid:%s'%(entity.entity_text, docid))
+                elif entity.label == 0 and entity.values[entity.label]>0.5 and re.search('(采购|招标)(单位|人)', text[max(0, b-span-2):b])==None:
+                    entity.values[entity.label] = 0.5
+                    log('中标大纲下招标人概率降低:%s, docid:%s'%(entity.entity_text, docid))
                 # elif len(bid_info_company) == 1 and entity.label != 2:
                 #     entity.label = 2
                 #     entity.values[entity.label] = 0.55
@@ -9019,10 +9022,10 @@ class EntityTypeRulePredictor():
                 if code_investment == '' and re.search(self.pattern_code_investment, sentance_text[max(0, b-12): b]):
                     code_investment = entity.entity_text
 
-        ser1 = re.search('(%s)(?P<addr>[\w():\.-]{5,100})[,。]'%self.pattern_addr_bidopen, list_articles[0].content)
-        ser2 = re.search('(%s)(?P<addr>[\w():\.-]{5,100})[,。]'%self.pattern_addr_bidsend, list_articles[0].content)
-        ser3 = re.search('(%s)(?P<addr>[\w()-]{5,100})[,。]'%self.pattern_addr_delivery, list_articles[0].content)
-        ser4 = re.search('(%s)(?P<addr>[\w()-]{5,100})[,。]'%self.pattern_addr_project, list_articles[0].content)
+        ser1 = re.search('(%s)(?P<addr>[\w():\.-]{5,100}[,。]|(\w{2,8}[省市县])+)'%self.pattern_addr_bidopen, list_articles[0].content)
+        ser2 = re.search('(%s)(?P<addr>[\w():\.-]{5,100}[,。]|(\w{2,8}[省市县])+)'%self.pattern_addr_bidsend, list_articles[0].content)
+        ser3 = re.search('(%s)(?P<addr>[\w()-]{5,100}[,。]|(\w{2,8}[省市县])+)'%self.pattern_addr_delivery, list_articles[0].content)
+        ser4 = re.search('(%s)(?P<addr>[\w()-]{5,100}[,。]|(\w{2,8}[省市县])+)'%self.pattern_addr_project, list_articles[0].content)
         ser5 = re.search('(%s)(?P<code>[\da-zA-Z()-]{5,30})[,。]'%self.pattern_code_investment, list_articles[0].content)
         if ser1 and re.search('\w{2,5}[省市区]|\d号|\w{2,12}自治[区州县旗]|采购网|平台|公司', ser1.group('addr')) and addr_dic.get('addr_bidopen', '') in ser1.group('addr'):
             addr_dic['addr_bidopen'] = ser1.group('addr')