extract.py 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Created on 2019年1月4日
  4. @author: User
  5. '''
  6. import os
  7. from bs4 import BeautifulSoup, Comment
  8. import copy
  9. import re
  10. import sys
  11. import os
  12. import codecs
  13. import requests
  14. import time
  15. from unicodedata import normalize
  16. _time1 = time.time()
  17. sys.path.append(os.path.abspath("../.."))
  18. from BiddingKG.dl.common.Utils import *
  19. import BiddingKG.dl.entityLink.entityLink as entityLink
  20. import BiddingKG.dl.interface.predictor as predictor
  21. import BiddingKG.dl.interface.Preprocessing as Preprocessing
  22. import BiddingKG.dl.interface.getAttributes as getAttributes
  23. import BiddingKG.dl.complaint.punish_predictor as punish_rule
  24. import json
  25. from BiddingKG.dl.money.re_money_total_unit import extract_total_money, extract_unit_money
  26. from BiddingKG.dl.ratio.re_ratio import extract_ratio
  27. from BiddingKG.dl.interface.outline_extractor import ParseDocument, extract_parameters, extract_sentence_list, extract_addr
  28. from BiddingKG.dl.interface.get_label_dic import get_all_label
  29. from BiddingKG.dl.channel.channel_bert import merge_channel
  30. from BiddingKG.dl.interface.kvtree_search import get_kvtree_value
  31. from BiddingKG.dl.interface.special_debt_extract import get_debt_info
  32. from BiddingKG.dl.fingerprint.documentFingerprint import getFingerprint
  33. import BiddingKG.dl.template_extract.template_extractor as template_extractor
  34. import BiddingKG.dl.template_extract.common_table_prem_extractor as common_table_prem_extractor
  35. from BiddingKG.dl.interface.error_attachments_filter import delete_error_attachment
  36. from BiddingKG.dl.predictors.role_context import build_role_contexts
  37. # 自定义jsonEncoder
  38. class MyEncoder(json.JSONEncoder):
  39. def default(self, obj):
  40. if isinstance(obj, np.ndarray):
  41. return obj.tolist()
  42. elif isinstance(obj, bytes):
  43. return str(obj, encoding='utf-8')
  44. elif isinstance(obj, (np.float_, np.float16, np.float32,
  45. np.float64)):
  46. return float(obj)
  47. elif isinstance(obj,str):
  48. return obj
  49. return json.JSONEncoder.default(self, obj)
  50. def get_login_web_set():
  51. file = os.path.join(os.path.dirname(__file__),"login_weblist.txt")
  52. list_web = []
  53. try:
  54. if os.path.exists(file):
  55. with open(file,"r",encoding="utf8") as f:
  56. while 1:
  57. line = f.readline()
  58. if not line:
  59. break
  60. line = line.strip()
  61. if line:
  62. list_web.append(line)
  63. except Exception as e:
  64. traceback.print_exc()
  65. _set = set(list_web)
  66. log("get_login_web_set length %d"%(len(_set)))
  67. return _set
  68. set_login_web = get_login_web_set()
  69. def extractCount(extract_dict,page_attachments,web_source_name,page_time):
  70. # time_pattern = "\d{4}\-\d{2}\-\d{2}.*"
  71. if len(extract_dict):
  72. _extract = extract_dict
  73. else:
  74. _extract = {}
  75. # print(_extract)
  76. dict_pack = _extract.get("prem",{})
  77. extract_count = 0
  78. list_code = _extract.get("code",[])
  79. word_count = _extract.get("word_count",{})
  80. if word_count.get("正文",0)>500:
  81. extract_count += 3
  82. if len(list_code)>0:
  83. project_code = list_code[0]
  84. else:
  85. project_code = ""
  86. project_name = _extract.get("name","")
  87. bidding_budget = ""
  88. win_tenderer = ""
  89. win_bid_price = ""
  90. linklist_count = 0
  91. time_getFileEnd = _extract.get("time_getFileEnd","")
  92. time_bidopen = _extract.get("time_bidopen","")
  93. time_bidclose = _extract.get("time_bidclose","")
  94. time_publicityEnd = _extract.get("time_publicityEnd","")
  95. docchannel_dict = _extract.get("docchannel",{})
  96. if page_time!="":
  97. if docchannel_dict.get("docchannel","") in ["招标公告","招标预告","招标文件","采购意向"] and docchannel_dict.get("doctype","")=="采招数据":
  98. if time_getFileEnd!="" and time_getFileEnd[:10]<page_time:
  99. extract_count -= 5
  100. if time_bidopen!="" and time_bidopen[:10]<page_time:
  101. extract_count -= 5
  102. if time_bidclose!="" and time_bidclose[:10]<page_time:
  103. extract_count -= 5
  104. if time_publicityEnd!="" and time_publicityEnd[:10]<page_time:
  105. extract_count -= 5
  106. for _key in dict_pack.keys():
  107. if "tendereeMoney" in dict_pack[_key] and dict_pack[_key]["tendereeMoney"]!='' and float(dict_pack[_key]["tendereeMoney"])>0:
  108. extract_count += 1
  109. if bidding_budget=="":
  110. bidding_budget = str(float(dict_pack[_key]["tendereeMoney"]))
  111. for _role in dict_pack[_key]["roleList"]:
  112. if isinstance(_role,list):
  113. extract_count += 1
  114. if _role[2]!='' and float(_role[2])>0:
  115. extract_count += 1
  116. if _role[0]=="tenderee":
  117. tenderee = _role[1]
  118. if _role[0]=="win_tenderer":
  119. if _role[1] is not None and _role[1]!="":
  120. extract_count += 2
  121. if win_tenderer=="":
  122. win_tenderer = _role[1]
  123. if _role[2]!='' and float(_role[2])>0:
  124. extract_count += 2
  125. if win_bid_price=="":
  126. win_bid_price = str(float(_role[2]))
  127. if _role[0]=="agency":
  128. agency = _role[1]
  129. if isinstance(_role,dict):
  130. extract_count += 1
  131. if "role_money" in _role:
  132. if str(_role["role_money"].get("money",""))!='' and float(_role["role_money"].get("money",""))>0:
  133. extract_count += 1
  134. if _role.get("role_name")=="tenderee":
  135. tenderee = _role["role_text"]
  136. if _role.get("role_name")=="win_tenderer":
  137. if _role["role_text"] is not None and _role["role_text"]!="":
  138. extract_count += 2
  139. if win_tenderer=="":
  140. win_tenderer = _role["role_text"]
  141. if "role_money" in _role:
  142. if str(_role["role_money"]["money"])!='' and float(_role["role_money"]["money"])>0:
  143. extract_count += 2
  144. if win_bid_price=="":
  145. win_bid_price = str(float(_role["role_money"]["money"]))
  146. if _role["role_name"]=="agency":
  147. agency = _role["role_text"]
  148. linklist = _role.get("linklist",[])
  149. for link in linklist:
  150. for l in link:
  151. if l!="":
  152. linklist_count += 1
  153. extract_count += linklist_count//2
  154. if project_code!="":
  155. extract_count += 1
  156. if project_name!="":
  157. extract_count += 1
  158. if page_attachments is not None and page_attachments!='':
  159. try:
  160. _attachments = json.loads(page_attachments)
  161. set_md5 = set()
  162. has_zhaobiao = False
  163. has_qingdan = False
  164. if len(_attachments)>0:
  165. for _atta in _attachments:
  166. classification = _atta.get("classification","")
  167. set_md5.add(_atta.get("fileMd5"))
  168. if str(classification)=='招标文件':
  169. has_zhaobiao = True
  170. if str(classification)=='采购清单':
  171. has_qingdan = True
  172. extract_count += len(set_md5)//2+1
  173. if has_zhaobiao:
  174. extract_count += 2
  175. if has_qingdan:
  176. extract_count += 1
  177. except Exception as e:
  178. traceback.print_exc()
  179. pass
  180. list_approval_dict = _extract.get("approval",[])
  181. for _dict in list_approval_dict:
  182. for k,v in _dict.items():
  183. if v is not None and v!='' and v!="未知":
  184. extract_count += 1
  185. punish_dict = _extract.get("punish",{})
  186. for k,v in punish_dict.items():
  187. if v is not None and v!='' and v!="未知":
  188. extract_count += 1
  189. if web_source_name in set_login_web:
  190. extract_count -= 3
  191. product = _extract.get("product","")
  192. extract_count += len(str(product).split(","))//5
  193. product_attrs = _extract.get("product_attrs",{})
  194. product_attrs_data = product_attrs.get("data",[])
  195. product_attrs_len = 0
  196. for _product in product_attrs_data:
  197. if _product.get("brand","") or _product.get("specs",""):
  198. # 有品牌型号的产品
  199. product_attrs_len += 1
  200. if product_attrs_len>0:
  201. extract_count += max((product_attrs_len//5)//2,1)
  202. return extract_count
  203. def time_entity_check(prem,channel_dic,page_time):
  204. # print('time_dict:',[(k,v) for k,v in prem[0].items() if re.search("^time_",k) and v])
  205. time_bidclose = prem[0].get("time_bidclose","")
  206. time_bidopen = prem[0].get("time_bidopen","")
  207. time_getFileStart = prem[0].get("time_getFileStart","")
  208. time_registrationEnd = prem[0].get("time_registrationEnd","")
  209. if page_time:
  210. if channel_dic['docchannel']['docchannel'] in ["招标公告","招标预告","招标文件","采购意向"]:
  211. if time_bidclose and time_bidclose[:10]<=page_time:
  212. prem[0]["time_bidclose"] = ""
  213. time_bidclose = ""
  214. if time_bidopen and time_bidopen[:10]<=page_time:
  215. prem[0]["time_bidopen"] = ""
  216. time_bidopen = ""
  217. if time_getFileStart and time_getFileStart[:10]<=page_time:
  218. prem[0]["time_getFileStart"] = ""
  219. time_getFileStart = ""
  220. if time_registrationEnd and time_registrationEnd[:10]<=page_time:
  221. prem[0]["time_registrationEnd"] = ""
  222. time_registrationEnd = ""
  223. if time_bidopen and (time_bidclose or time_registrationEnd):
  224. if time_bidclose:
  225. if time_bidclose[:10]>=time_registrationEnd[:10] and time_bidopen[:10]<time_bidclose[:10]:
  226. prem[0]["time_bidopen"] = ""
  227. time_bidopen = ""
  228. elif time_registrationEnd:
  229. if time_bidopen[:10]<time_registrationEnd[:10]:
  230. prem[0]["time_bidopen"] = ""
  231. time_bidopen = ""
  232. return prem
  233. # 字符编码标准化
  234. def str_normalize(text):
  235. # time1 = time.time()
  236. cn_punctuation = "¥,。:;{}!?()<ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳"
  237. text_split = re.split("([{}])+".format(cn_punctuation),text)
  238. # print(text_split)
  239. new_text = ""
  240. for s in text_split:
  241. if re.search("^[{}]+$".format(cn_punctuation),s):
  242. new_text += s
  243. else:
  244. new_text += normalize('NFKD', s)
  245. # print("str_normalize cost time %s"%str(time.time()-time1))
  246. # print(new_text)
  247. return new_text
  248. # 修复prem中地区前缀不完整实体
  249. def repair_entity(prem,district_dict,list_articles):
  250. district_dict = district_dict['district']
  251. province = district_dict['province'] if district_dict['province'] and district_dict['province'] not in ['未知','全国'] else ""
  252. city = district_dict['city'] if district_dict['city'] and district_dict['city']!='未知' else ""
  253. district = district_dict['district'] if district_dict['district'] and district_dict['district']!='未知' else ""
  254. content_text = list_articles[0].content
  255. autonomous_region_dict = {
  256. "新疆":"新疆维吾尔",
  257. "西藏":"西藏",
  258. "内蒙古":"内蒙古",
  259. "广西":"广西壮族",
  260. "宁夏":"宁夏回族"
  261. }
  262. for package,_prem in prem[0]['prem'].items():
  263. for role in _prem['roleList']:
  264. if role['role_name'] in ['tenderee','agency']:
  265. role_text = role['role_text']
  266. if re.search("^[省市县区]",role_text):
  267. if role_text[0]=='省' and role_text[:2] not in ['省道']:
  268. role['role_text'] = province + role_text
  269. elif role_text[0]=='市' and role_text[:2] not in ['市政','市场']:
  270. if district+'市' in content_text:
  271. # 县级市
  272. role['role_text'] = district + role_text
  273. else:
  274. role['role_text'] = city + role_text
  275. elif role_text[0] in ['县','区']:
  276. role['role_text'] = district + role_text
  277. elif re.search("^自治[区州县]",role_text):
  278. if role_text[:3]=='自治区':
  279. role['role_text'] = autonomous_region_dict.get(province,"") + role_text
  280. elif role_text[:3] in ['自治县',"自治州"]:
  281. if re.search("自治[县州]?$",district):
  282. role['role_text'] = re.sub("自治[县州]?","",district) + role_text
  283. elif re.search("族$",district):
  284. role['role_text'] = district + role_text
  285. elif re.search("自治[县州]?$",city):
  286. role['role_text'] = re.sub("自治[县州]?","",city) + role_text
  287. elif re.search("族$",city):
  288. role['role_text'] = city + role_text
  289. def fix_table_structure_preserve_order(html):
  290. """
  291. 修复table结构中tr与tbody平级的问题
  292. 保持原有行顺序不变
  293. """
  294. soup = BeautifulSoup(html, 'html.parser')
  295. for table in soup.find_all('table'):
  296. if table.find_all('tr', recursive=False) != []:
  297. # 获取table下所有直接子节点
  298. children = list(table.children)
  299. tbody_new = soup.new_tag('tbody')
  300. table.append(tbody_new)
  301. for child in children:
  302. if child.name:
  303. if child.name == 'tbody':
  304. for tag in list(child.children):
  305. tbody_new.append(tag.extract())
  306. child.extract()
  307. else:
  308. tbody_new.append(child.extract())
  309. return str(soup)
  310. def clean_binary_chars(text):
  311. """
  312. 移除可能被识别为二进制的字符,包括:
  313. - 八进制转义控制字符(\00-\377)
  314. - 十六进制转义控制字符(\x00-\x1F、\x7F-\xFF)
  315. - ASCII 不可见控制字符(0-31、127)
  316. - 无效的多字节编码字符(如�)
  317. """
  318. if not isinstance(text, str):
  319. text = str(text) # 确保输入为字符串
  320. # 组合正则规则,覆盖更多场景
  321. pattern = re.compile(r'''
  322. # 八进制转义符(\ddd,如\037)
  323. \\[0-7]{1,3}
  324. |
  325. # 十六进制转义符(\xhh,如\x0B、\xFF)
  326. \\x[0-9A-Fa-f]{2}
  327. |
  328. # ASCII控制字符(0-31、127)
  329. [\x00-\x1F\x7F]
  330. |
  331. # Unicode替换字符(�,表示编码错误)
  332. \ufffd
  333. |
  334. # 高字节非文本字符(\x80-\xFF,排除常见符号)
  335. [\x80-\xFF](?![\x80-\xFF]) # 单独出现的高字节(非多字节序列)
  336. |
  337. ?+ # 多个重复问号异常数据
  338. ''', re.VERBOSE)
  339. cleaned_text = pattern.sub('', text)
  340. # 附件中标签参数转义内容,例如:<td colspan='\"1\"' rowspan='\"2\"'>
  341. cleaned_text = cleaned_text.replace("'\\\"",'"').replace("\\\"'",'"')
  342. return cleaned_text
  343. def predict(doc_id,text,title="",page_time="",web_source_no='',web_source_name="",original_docchannel='',page_attachments='[]',**kwargs):
  344. cost_time = dict()
  345. if web_source_no == None:
  346. web_source_no = ''
  347. if web_source_name == None:
  348. web_source_name = ''
  349. page_time = page_time[:10] if page_time else ""
  350. start_time = time.time()
  351. log("start process doc %s"%(str(doc_id)))
  352. # 字符编码标准化
  353. title = clean_binary_chars(title) # 去除异常编码字符 修复 244125382 标题有异常转义字符
  354. text = clean_binary_chars(text) # 去除异常编码字符 修复 653086830 内容有转义字符
  355. text = str_normalize(text)
  356. text = re.sub("<html>|</html>|<body>|</body>","",text) # 20260205 删除多个重复标签,避免解析获取节点异常
  357. text = fix_table_structure_preserve_order(text) # 20250331 修复表格tr tbody平级问题
  358. text = merge_single_row_tables(text) # 20260123 修复站源14132表头内容拆分多个表格 例子:685993450, 620634112
  359. original_text = text
  360. fingerprint = getFingerprint(title+original_text)
  361. text = delete_error_attachment(text, page_attachments) # 删除无关附件内容
  362. list_articles,list_sentences,list_entitys,list_outlines,_cost_time = Preprocessing.get_preprocessed([[doc_id,text,"","",title,page_time, web_source_no]],useselffool=True)
  363. log("get preprocessed done of doc_id%s"%(doc_id))
  364. cost_time["preprocess"] = round(time.time()-start_time,2)
  365. cost_time.update(_cost_time)
  366. '''大纲提取及大纲内容相关提取'''
  367. start_time = time.time()
  368. sentence2_list, sentence2_list_attach = extract_sentence_list(list_sentences[0])
  369. parse_document = ParseDocument(text, True,list_obj=sentence2_list)
  370. tup_main = extract_parameters(parse_document)
  371. if sentence2_list_attach!=[] and tup_main[0] == '' and tup_main[1] == '' and tup_main[2] =="":
  372. parse_document = ParseDocument(text, True, list_obj=sentence2_list_attach)
  373. tup_att = extract_parameters(parse_document)
  374. requirement_text, aptitude_text, addr_bidopen_text, addr_bidsend_text, out_lines, requirement_scope, pinmu_name, list_policy, winter_scope, correction_content = tuple(v1 if v1 else v2 for v1, v2 in zip(tup_main, tup_att))
  375. else:
  376. requirement_text, aptitude_text, addr_bidopen_text, addr_bidsend_text, out_lines, requirement_scope, pinmu_name, list_policy, winter_scope, correction_content = tup_main
  377. # print('out_lines',out_lines)
  378. # if addr_bidopen_text == '':
  379. # addr_bidopen_text = extract_addr(list_articles[0].content)
  380. addr_dic, time_dic, code_investment = predictor.getPredictor('entity_type_rule').predict(list_entitys, list_sentences, list_articles)
  381. if addr_bidopen_text != '' and 'addr_bidopen' not in addr_dic:
  382. addr_dic['addr_bidopen'] = addr_bidopen_text
  383. if addr_bidsend_text != '' and 'addr_bidsend' not in addr_dic:
  384. addr_dic['addr_bidsend'] = addr_bidsend_text
  385. log("get outline done of doc_id%s"%(doc_id))
  386. cost_time["outline"] = round(time.time()-start_time,2)
  387. '''从 kvtree 正则匹配要素'''
  388. start_time = time.time()
  389. kv_single_dic, kv_addr_dic = get_kvtree_value(text)
  390. log("get kvtree done of doc_id%s"%(doc_id))
  391. cost_time["kvtree"] = round(time.time()-start_time,2)
  392. # 过滤掉Redis里值为0的错误实体
  393. # list_entitys[0] = entityLink.enterprise_filter(list_entitys[0])
  394. # #依赖句子顺序
  395. # start_time = time.time() # 公告类型/生命周期提取 此处作废 换到后面预测 2022/4/29
  396. # channel_dic = predictor.getPredictor("channel").predict(title=title, list_sentence=list_sentences[0],
  397. # web_source_no=web_source_no,original_docchannel=original_docchannel)
  398. # cost_time["channel"] = round(time.time()-start_time,2)
  399. start_time = time.time() # 项目编号、名称提取
  400. codeName = predictor.getPredictor("codeName").predict(list_sentences,MAX_AREA=5000,list_entitys=list_entitys, doctitle = title)
  401. if re.search('破产清算案', title):
  402. end = re.search('破产清算案', title).end()
  403. codeName[0]['name'] = title[:end]
  404. log("get codename done of doc_id%s"%(doc_id))
  405. cost_time["codename"] = round(time.time()-start_time,2)
  406. start_time = time.time() # 公告类别预测
  407. channel_dic, msc = predictor.getPredictor("channel").predict_merge(title, list_sentences[0], text,original_docchannel, web_source_no)
  408. if channel_dic['docchannel']['docchannel'] == "":
  409. channel_dic = merge_channel(list_articles, channel_dic, original_docchannel,page_time,web_source_no=web_source_no)
  410. cost_time["rule_channel"] = round(time.time() - start_time, 2)
  411. start_time = time.time() # 角色金额模型提取
  412. # Phase A:角色链路入口构建一次预计算上下文(实体-句子配对 + 切片缓存),
  413. # prem 角色/金额两个模型共享同一份,消除原来各自的重复配对与切片构建。
  414. role_contexts = build_role_contexts(list_sentences, list_entitys)
  415. predictor.getPredictor("prem").predict(list_sentences,list_entitys, contexts=role_contexts)
  416. log("get prem done of doc_id%s"%(doc_id))
  417. cost_time["prem"] = round(time.time()-start_time,2)
  418. # start_time = time.time() # 产品名称及废标原因提取 此处作废 换到后面预测 2022/4/29
  419. # fail = channel_dic['docchannel']['docchannel'] == "废标公告"
  420. # fail_reason = predictor.getPredictor("product").predict(list_sentences,list_entitys,list_articles, fail) #只返回失败原因,产品已加入到Entity类
  421. # # predictor.getPredictor("product").predict(list_sentences, list_entitys)
  422. # log("get product done of doc_id%s"%(doc_id))
  423. # cost_time["product"] = round(time.time()-start_time,2)
  424. start_time = time.time() # 产品相关要素正则提取 单价、数量、品牌规格 ; 项目、需求、预算、时间
  425. product_attrs, total_product_money, total_budget = predictor.getPredictor("product_attrs").predict(doc_id, text, page_time)
  426. log("get product attributes done of doc_id%s"%(doc_id))
  427. cost_time["product_attrs"] = round(time.time()-start_time,2)
  428. # 是否为存款类项目
  429. deposit_project = is_deposit_project(title, codeName[0]['name'], requirement_text)
  430. start_time = time.time() #正则角色提取
  431. # Phase E:roleRule / tendereeRuleRecall 复用入口构建的 RoleContext(与 prem 共享)
  432. all_tenderer = predictor.getPredictor("roleRule").predict(list_articles,list_sentences, list_entitys,codeName, channel_dic, title,all_winner=is_all_winner(title), req_scope=requirement_scope, deposit_project=deposit_project, contexts=role_contexts)
  433. cost_time["rule"] = round(time.time()-start_time,2)
  434. '''正则补充最后一句实体日期格式为招标或代理 2021/12/30;正则最后补充角色及去掉包含 公共资源交易中心 的招标人'''
  435. start_time = time.time() #正则角色提取
  436. predictor.getPredictor("roleRuleFinal").predict(list_articles,list_sentences,list_entitys, codeName)
  437. cost_time["roleRuleFinal"] = round(time.time()-start_time,2)
  438. start_time = time.time() #正则招标人召回
  439. predictor.getPredictor("tendereeRuleRecall").predict(list_articles,list_sentences,list_entitys, codeName, contexts=role_contexts)
  440. cost_time["tendereeRuleRecall"] = round(time.time()-start_time,2)
  441. '''规则调整角色概率'''
  442. start_time = time.time() #
  443. predictor.getPredictor("rolegrade").predict(list_sentences,list_entitys,doc_id, original_docchannel, title, outlines = out_lines)
  444. cost_time["rolegrade"] = round(time.time()-start_time,2)
  445. '''规则调整金额概率'''
  446. start_time = time.time() #
  447. predictor.getPredictor("moneygrade").predict(list_sentences,list_entitys)
  448. cost_time["moneygrade"] = round(time.time()-start_time,2)
  449. start_time = time.time() #联系人模型提取
  450. predictor.getPredictor("epc").predict(list_sentences,list_entitys)
  451. log("get epc done of doc_id%s"%(doc_id))
  452. cost_time["person"] = round(time.time()-start_time,2)
  453. start_time = time.time() # 时间类别提取
  454. predictor.getPredictor("time").predict(list_sentences, list_entitys)
  455. log("get time done of doc_id%s"%(doc_id))
  456. cost_time["time"] = round(time.time()-start_time,2)
  457. start_time = time.time() # 保证金支付方式
  458. payment_way_dic = predictor.getPredictor("deposit_payment_way").predict(content=list_articles[0].content)
  459. cost_time["deposit"] = round(time.time()-start_time,2)
  460. # 需在getPredictor("prem").predict后 getAttributes.getPREMs 前 规则调整 监理|施工|设计|勘察类别公告的费用 为招标或中标金额
  461. predictor.getPredictor("prem").correct_money_by_rule(title, list_entitys, list_articles)
  462. # 2021-12-29新增:提取:总价,单价
  463. start_time = time.time() # 总价单价提取
  464. predictor.getPredictor("total_unit_money").predict(list_sentences, list_entitys)
  465. cost_time["total_unit_money"] = round(time.time()-start_time, 2)
  466. # 依赖句子顺序
  467. start_time = time.time() # 实体链接
  468. entityLink.link_entitys(list_entitys)
  469. doctitle_refine = entityLink.doctitle_refine(title)
  470. nlp_enterprise,nlp_enterprise_attachment, dict_enterprise = entityLink.get_nlp_enterprise(list_entitys[0])
  471. prem = getAttributes.getPREMs(list_sentences,list_entitys,list_articles,list_outlines,page_time,winter_scope)
  472. log("get attributes done of doc_id%s"%(doc_id))
  473. cost_time["attrs"] = round(time.time()-start_time,2)
  474. # if original_docchannel != 302: # 审批项目不做下面提取
  475. # '''表格要素提取'''
  476. # table_prem, in_attachment = predictor.getPredictor("tableprem").predict(text, nlp_enterprise+nlp_enterprise_attachment, web_source_name, is_all_winner(title), doc_id)
  477. # print('表格提取中标人:', table_prem)
  478. # print('原提取角色:', prem[0]['prem'])
  479. # if table_prem:
  480. # getAttributes.update_prem(old_prem=prem[0]['prem'], new_prem=table_prem, in_attachment=in_attachment)
  481. #
  482. # '''候选人提取'''
  483. # candidate_top3_prem, candidate_dic, in_attachment = predictor.getPredictor("candidate").predict(text, list_sentences, list_entitys, nlp_enterprise+nlp_enterprise_attachment,doc_id)
  484. # # print('表格提取候选人:', candidate_top3_prem)
  485. # getAttributes.update_prem(old_prem=prem[0]['prem'], new_prem=candidate_top3_prem, in_attachment=in_attachment)
  486. '''合并中标人、候选人表格提取''' # 20260311取消上面表格要素提取及候选人提取,合并为此方法提取
  487. common_prem, in_attachment = common_table_prem_extractor.table_prem_extract(text, page_time=page_time, enterprise=dict_enterprise, all_winner = is_all_winner(title), docid=doc_id)
  488. # print('公共表格提取:', in_attachment, common_prem)
  489. # print('非表格提取:', prem[0]['prem'])
  490. getAttributes.update_prem(old_prem=prem[0]['prem'], new_prem=common_prem, in_attachment=in_attachment)
  491. # print('表格非表格合并后:', prem[0]['prem'])
  492. '''获取联合体信息'''
  493. getAttributes.get_win_joint(prem, list_entitys, list_sentences, list_articles)
  494. '''修正采购公告表格形式多种采购产品中标价格;中标金额小于所有产品总金额则改为总金额'''
  495. getAttributes.correct_rolemoney(doc_id, prem, total_product_money, total_budget, list_articles)
  496. '''模板提取要素内容'''
  497. result_template = template_extractor.template_predict(text, web_source_no, enterprise = dict_enterprise, page_time=page_time, docid=doc_id)
  498. if result_template:
  499. product_attrs, codeName, prem = template_extractor.update_template_result(product_attrs, codeName, prem, result_template, doc_id)
  500. '''修正channel预测类别为招标公告却有中标人及预测为中标信息却无中标关键词的类别''' # 依赖 prem
  501. start_time = time.time()
  502. # content = list_articles[0].content
  503. # channel_dic = predictor.getPredictor("channel").predict_rule(title, content, channel_dic, prem_dic=prem[0]['prem'])
  504. if original_docchannel == 302:
  505. channel_dic = {"docchannel":
  506. { "docchannel": "审批项目", "doctype": "审批项目", "life_docchannel": "审批项目" }
  507. }
  508. else:
  509. channel_dic, msc = predictor.getPredictor("channel").final_change(channel_dic, prem[0], original_docchannel,nlp_enterprise,nlp_enterprise_attachment, msc)
  510. # print('msc', msc)
  511. if channel_dic['docchannel'].get('docchannel') == '':
  512. channel_dic = merge_channel(list_articles,channel_dic,original_docchannel,page_time,prem=prem[0],web_source_no=web_source_no,is_finnal=True) # channel_dic 根据新模型预测结合判断,整合结果
  513. channel_dic, msc = predictor.getPredictor("channel").final_change(channel_dic, prem[0], original_docchannel, nlp_enterprise, nlp_enterprise_attachment, msc)
  514. else:
  515. channel_dic = merge_channel(list_articles,channel_dic,original_docchannel,page_time,prem=prem[0],web_source_no=web_source_no,is_finnal=True) # channel_dic 根据新模型预测结合判断,整合结果
  516. cost_time["rule_channel2"] = round(time.time()-start_time,2)
  517. '''时间类提取结果校验'''
  518. prem = time_entity_check(prem,channel_dic,page_time)
  519. '''一包多中标人提取及所有金额提取'''
  520. all_moneys = getAttributes.get_multi_winner_and_money(channel_dic, prem, list_entitys,list_sentences, is_all_winner(title))
  521. start_time = time.time() # 产品名称及废标原因提取 #依赖 docchannel结果
  522. fail = channel_dic['docchannel']['docchannel'] == "废标公告"
  523. fail_reason, product_list = predictor.getPredictor("product").predict(list_sentences,list_entitys,list_articles, fail,out_lines=out_lines) #只返回失败原因,产品已加入到Entity类 #2022/7/29补充返回产品,方便行业分类调用
  524. # predictor.getPredictor("product").predict(list_sentences, list_entitys)
  525. log("get product done of doc_id%s"%(doc_id))
  526. cost_time["product"] = round(time.time()-start_time,2)
  527. prem[0].update(getAttributes.getOtherAttributes(list_entitys[0],page_time,prem,channel_dic))
  528. '''更新单一来源招标公告中标角色为预中标'''
  529. getAttributes.fix_single_source(prem[0], channel_dic, original_docchannel)
  530. '''公告无表格格式时,采购意向预测''' #依赖 docchannel结果 依赖产品及prem
  531. '''把产品要素提取结果在项目名称的添加到 采购需求,预算时间,采购时间 要素中'''
  532. predictor.getPredictor("product_attrs").add_product_attrs(channel_dic, product_attrs, list_sentences,list_entitys,list_outlines,product_list,codeName,prem,text,page_time)
  533. '''行业分类提取,需要用标题、项目名称、产品、及prem 里面的角色'''
  534. industry = predictor.getPredictor('industry').predict(title, project=codeName[0]['name'], product=','.join(product_list), prem=prem, product_attrs=product_attrs)
  535. '''根据数据源最后召回招标人角色'''
  536. prem = predictor.getPredictor('websource_tenderee').get_websource_tenderee(doc_id, web_source_no, web_source_name, prem)
  537. '''地区获取'''
  538. start_time = time.time()
  539. # district = predictor.getPredictor('district').predict(project_name=codeName[0]['name'], prem=prem,title=title, list_articles=list_articles, web_source_name=web_source_name, list_entitys=list_entitys)
  540. district = predictor.getPredictor('district').predict_area(doc_id, title, list_articles[0].content, web_source_name, prem=prem[0]['prem'], addr_dic=addr_dic, list_entity=list_entitys[0])
  541. cost_time["district"] = round(time.time() - start_time, 2)
  542. '''根据district提取结果修复实体'''
  543. repair_entity(prem,district,list_articles)
  544. '''规则补充招标无招标人中标无中标人角色'''
  545. getAttributes.rule_add_role(doc_id,prem[0]['prem'], channel_dic, list_articles[0].content, web_source_no, nlp_enterprise)
  546. '''最终验证prem'''
  547. candidate_dic = getAttributes.confirm_prem(doc_id, prem[0]['prem'], channel_dic, list_articles[0].content, deposit_project, prem[0]['total_tendereeMoney'], all_tenderer)
  548. '''通过产品补充标段包名20241203'''
  549. getAttributes.add_package_name(prem[0]['prem'], list_entitys[0], product_list, name=codeName[0]['name'])
  550. # 提取拟在建所需字段
  551. start_time = time.time()
  552. pb_json = predictor.getPredictor('pb_extract').predict(prem, list_articles, list_sentences, list_entitys, title, codeName[0], text, web_source_name, industry, original_text)
  553. log("pb_extract done of doc_id%s"%(doc_id))
  554. cost_time["pb_extract"] = round(time.time() - start_time, 2)
  555. '''打标签'''
  556. label_dic = get_all_label(title, list_articles[0].content, prem[0]['prem'])
  557. '''评标评分提取'''
  558. bid_score = predictor.getPredictor('bid_score').predict(text, nlp_enterprise+nlp_enterprise_attachment)
  559. # data_res = Preprocessing.union_result(Preprocessing.union_result(codeName, prem),list_punish_dic)[0]
  560. # data_res = Preprocessing.union_result(Preprocessing.union_result(Preprocessing.union_result(codeName, prem),list_punish_dic), list_channel_dic)[0]
  561. version_date = {'version_date': '2026-08-13'}
  562. 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)
  563. if original_docchannel == 302:
  564. approval = predictor.getPredictor("approval").predict(list_sentences, list_entitys, text, nlp_enterprise=nlp_enterprise+nlp_enterprise_attachment)
  565. approval = predictor.getPredictor("approval").add_ree2approval(approval , prem[0]['prem'])
  566. approval = predictor.getPredictor("approval").add_codename2approval(approval , codeName)
  567. data_res['prem'] = {} # 审批项目不要这项
  568. data_res['approval'] = approval[:100] # 20250217 限制获取最多100个项目
  569. if web_source_no == 'XM6486':
  570. debt_dic = get_debt_info(text) # 专项债信息提取
  571. if debt_dic.get('district', '') != '':
  572. district = predictor.getPredictor('district').predict_area(doc_id, debt_dic['district'], '', web_source_name)
  573. debt_dic['district'] = district['district']
  574. data_res['district'] = district['district']
  575. # 提取专项债信息
  576. data_res['debt_dic'] = debt_dic
  577. data_res['docchannel'] = { "docchannel": "审批项目", "doctype": "审批项目", "life_docchannel": "审批项目" }
  578. if channel_dic['docchannel']['doctype'] == '处罚公告': # 20240627 处罚公告进行失信要素提取
  579. start_time = time.time() #失信数据要素提取
  580. punish_dic = predictor.getPredictor("punish").get_punish_extracts(list_articles,list_sentences, list_entitys)
  581. cost_time["punish"] = round(time.time()-start_time,2)
  582. data_res['punish'] = punish_dic
  583. if "Project" in data_res['prem']:
  584. for d in data_res['prem']['Project']['roleList']:
  585. if d['role_name'] == 'tenderee' and d.get('role_prob', 0.6) < 0.6: # 处罚公告 去掉低概率招标人
  586. data_res['prem']['Project']['roleList'] = [d for d in data_res['prem']['Project']['roleList'] if d['role_name'] != 'tenderee']
  587. break
  588. if len(data_res['prem']['Project']['roleList']) == 0 and data_res['prem']['Project'].get('tendereeMoney', 0) in [0, '0']: # 删除空包
  589. data_res['prem'].pop('Project')
  590. # 把产品属性里面的产品补充到产品列表
  591. if len(data_res['product_attrs']['data']) > 0: # 20241108 如果产品单价数量提取到产品的,原来提取的产品只保留标题中的
  592. data_res['product'] = [it for it in data_res['product'] if it in title]
  593. for d in data_res['product_attrs']['data']:
  594. if isinstance(d['product'], str) and d['product'] not in data_res['product']:
  595. data_res['product'].append(d['product'])
  596. # 标签生成,使用data_res['product']更新后的字段
  597. '''根据关键词表生成项目标签'''
  598. project_label, main_content_text = predictor.getPredictor('project_label').predict(title,product=','.join(data_res['product']),
  599. project_name=codeName[0]['name'],prem=prem,all_text=list_articles[0].content)
  600. # 额外需求的标签
  601. project_label = predictor.getPredictor('project_label').predict_other(project_label, industry, title,codeName[0]['name'],
  602. ','.join(data_res['product']),list_articles,main_content_text)
  603. '''行业关键词标签'''
  604. industry_label,tenderee_label = predictor.getPredictor('industry_label').predict(title, list_articles[0],product=','.join(data_res['product']), prem=prem)
  605. '''产权分类二级标签'''
  606. property_label = predictor.getPredictor('property_label').predict(title, product=','.join(data_res['product']),project_name=codeName[0]['name'],
  607. prem=prem,channel_dic=channel_dic)
  608. '''最终检查修正招标、中标金额'''
  609. getAttributes.limit_maximum_amount(data_res, list_entitys[0])
  610. '''添加候选人项目负责人、经理等'''
  611. getAttributes.add_manager(doc_id, prem[0]['prem'],list_entitys, list_sentences)
  612. '''利用采购意向需求信息补充项目'''
  613. if channel_dic['docchannel']['docchannel'] == '采购意向':
  614. getAttributes.demand_to_prem(data_res.get('demand_info', {}), prem[0]['prem'])
  615. '''提取标题包号及实体表招标金额、中标金额,项目合并用'''
  616. ree_moneys, win_moneys, title_packages = predictor.get_package_moneys(title, list_entitys)
  617. data_res['packages_title'] = list(set(title_packages))
  618. data_res['moneys_tenderee'] = list(set(ree_moneys))
  619. data_res['moneys_tenderer'] = list(set(win_moneys))
  620. data_res["project_label"] = project_label
  621. data_res["main_content_text"] = main_content_text
  622. data_res["industry_label"] = industry_label
  623. data_res["tenderee_label"] = tenderee_label
  624. data_res["property_label"] = property_label
  625. data_res["doctitle_refine"] = doctitle_refine
  626. data_res["nlp_enterprise"] = nlp_enterprise
  627. data_res["nlp_enterprise_attachment"] = nlp_enterprise_attachment
  628. data_res["dict_enterprise"] = dict_enterprise
  629. data_res["fingerprint"] = fingerprint
  630. # 要素的个数
  631. data_res['extract_count'] = extractCount(data_res,page_attachments,web_source_name,page_time)
  632. # 是否有表格
  633. data_res['exist_table'] = 1 if re.search("<td",text) else 0
  634. data_res["cost_time"] = cost_time
  635. data_res["success"] = True
  636. # 拟在建需建索引字段
  637. data_res["proportion"] = pb_json.get('pb').get('proportion', '')
  638. data_res["pb_project_name"] = pb_json.get('pb').get('project_name_refind', '')
  639. data_res["industry_codes"] = pb_json.get('pb').get('industry_codes', '')
  640. # 更正内容
  641. data_res['change_content'] = correction_content[:500]
  642. # 资质要求
  643. data_res['aptitude'] = aptitude_text[:1500]
  644. # 采购内容
  645. data_res['requirement'] = requirement_text[:1500]
  646. # 打标签
  647. data_res['label_dic'] = label_dic
  648. # 开标、投标、项目、收货等地址
  649. data_res['addr_dic'] = addr_dic
  650. # 字数
  651. text_main, text_attn = 0, 0
  652. for sentence in list_sentences[0]:
  653. if sentence.in_attachment:
  654. text_attn += len(re.sub("##attachment##[,。]?", "", sentence.sentence_text))
  655. else:
  656. text_main += len(sentence.sentence_text)
  657. data_res['word_count'] = {'正文': text_main, '附件': text_attn}
  658. # 限制产品数量
  659. data_res['product'] = data_res['product'][:500]
  660. data_res['product_attrs']['data'] = data_res['product_attrs']['data'][:500]
  661. # 是否为存款项目
  662. data_res['is_deposit_project'] = deposit_project
  663. data_res['pinmu_name'] = pinmu_name # 品目名称
  664. data_res['policies'] = list_policy # 政策法规
  665. data_res['bid_score'] = bid_score # 评标得分
  666. data_res['time_planned'] = time_dic.get('time_planned', '') # 预计招标时间
  667. data_res['code_investment'] = code_investment # 投资项目编号
  668. if data_res['product_attrs'].get('data', []) == []: # 20250619 为空的直接返回空字典
  669. data_res['product_attrs'] = {}
  670. if data_res['demand_info'].get('data', []) == []:
  671. data_res['demand_info'] = {}
  672. for k, v in kv_single_dic.items(): # 没获取到的用kv_tree补充
  673. if data_res.get(k, '') == '':
  674. data_res[k] = v
  675. for k, v in kv_addr_dic.items(): # 没获取到地址的用kv_tree补充
  676. if data_res['addr_dic'].get(k, '') == '' or re.search('时间:', data_res['addr_dic'][k]):
  677. data_res['addr_dic'][k] = v
  678. # for _article in list_articles:
  679. # log(_article.content)
  680. #
  681. # for list_entity in list_entitys:
  682. # for _entity in list_entity:
  683. # log("type:%s,text:%s,label:%s,values:%s,sentence:%s,begin_index:%s,end_index:%s"%
  684. # (str(_entity.entity_type),str(_entity.entity_text),str(_entity.label),str(_entity.values),str(_entity.sentence_index),
  685. # str(_entity.begin_index),str(_entity.end_index)))
  686. _extract_json = json.dumps(data_res,cls=MyEncoder,sort_keys=True,indent=4,ensure_ascii=False)
  687. _extract_json = _extract_json.replace("\x06", "").replace("\x05", "").replace("\x07", "")
  688. return _extract_json#, list_articles[0].content, get_ent_context(list_sentences, list_entitys)
  689. def test1(name,content):
  690. user = {
  691. "content": content,
  692. "id":name
  693. }
  694. myheaders = {'Content-Type': 'application/json'}
  695. # Phase 1: URL 走 config/settings.yaml + 环境变量 INTERNAL_ARTICLE_EXTRACT_URL
  696. # 原硬编码:http://192.168.2.102:15030/article_extract
  697. from BiddingKG.dl.infra import config as _infra_config
  698. _url = _infra_config.internal_api_url("article_extract_url")
  699. if not _url:
  700. _url = "http://127.0.0.1:15030/article_extract"
  701. _resp = requests.post(_url, json=user, headers=myheaders, verify=True)
  702. resp_json = _resp.content.decode("utf-8")
  703. # print(resp_json)
  704. return resp_json
  705. def get_ent_context(list_sentences, list_entitys):
  706. rs_list = []
  707. sentences = sorted(list_sentences[0], key=lambda x:x.sentence_index)
  708. for list_entity in list_entitys:
  709. for _entity in list_entity:
  710. if _entity.entity_type in ['org', 'company', 'money']:
  711. s = sentences[_entity.sentence_index].sentence_text
  712. b = _entity.wordOffset_begin
  713. e = _entity.wordOffset_end
  714. # print("%s %d %.4f; %s %s %s"%(_entity.entity_type, _entity.label, _entity.values[_entity.label], s[max(0, b-10):b], _entity.entity_text, s[e:e+10]))
  715. rs_list.append("%s %d %.4f; %s ## %s ## %s"%(_entity.entity_type, _entity.label, _entity.values[_entity.label], s[max(0, b-10):b], _entity.entity_text, s[e:e+10]))
  716. return '\n'.join(rs_list)
  717. def get_role_context(docid, list_sentences, list_entitys):
  718. rs_list = []
  719. sentences = sorted(list_sentences[0], key=lambda x:x.sentence_index)
  720. for list_entity in list_entitys:
  721. for _entity in list_entity:
  722. if _entity.entity_type in ['org', 'company']:
  723. idx = _entity.entity_id
  724. sentence = sentences[_entity.sentence_index]
  725. # _span = spanWindow(tokens=sentence.tokens, begin_index=_entity.begin_index, end_index=_entity.end_index, size=20,
  726. # center_include=False, word_flag=True, text=_entity.entity_text)
  727. _span = get_context(sentence.sentence_text, _entity.wordOffset_begin, _entity.wordOffset_end, size=40, center_include=False)
  728. rs_list.append((docid,idx, _entity.entity_type, _entity.label, '%.4f'%_entity.values[_entity.label], _span[0],
  729. _entity.entity_text, _span[1]))
  730. return rs_list
  731. if __name__=="__main__":
  732. t1 = time.time()
  733. with open('d:/html/2.html', 'r', encoding='utf-8') as f:
  734. html = f.read()
  735. with open('d:/html/要素提取输入要素.json', 'r', encoding='utf-8') as f:
  736. docid, title, page_time, web_source_no, web_source_name, original_docchannel, page_attachments = json.load(f)
  737. # title = ''
  738. # web_source_name = 'DX000002'
  739. # web_source_no = 'XX0182'
  740. # print('title, web_source_name: ', title, web_source_name)
  741. rs = predict(docid, html, title, page_time, web_source_no, web_source_name, original_docchannel, page_attachments)
  742. print('耗时:', time.time()-t1)
  743. print(rs)
  744. # import pandas as pd
  745. # df = pd.read_csv('E:/模版提取/医院大学站源公告.csv')
  746. # df2 = pd.read_csv('E:\模版提取/医院大学站源公告_html.csv')
  747. #
  748. # df = pd.read_csv('E:/模版提取/中国南方电网-站源公告.csv')
  749. # df2 = pd.read_csv('E:/模版提取/中国南方电网-站源公告_html.csv')
  750. #
  751. # # df = pd.read_csv('E:/模版提取/站源数据_易派客1122.csv')
  752. # # df2 = pd.read_csv('E:/模版提取/站源数据_易派客1122_html.csv')
  753. # #
  754. # # # df = pd.read_csv('E:\公告输入要素/待检查_中标人为空,但二三中标人存在数据_站源去重_其他要素.csv') # 待检查_有二三候选人无中标人公告
  755. # # # df2 = pd.read_csv('E:\公告输入要素/待检查_中标人为空,但二三中标人存在数据_站源去重_html.csv')
  756. # #
  757. # # df = pd.read_csv('E:\模版提取/表头AI判断有角色金额目前表格提取情况_html.csv')
  758. # # df2 = pd.read_csv('E:\模版提取/表头AI判断有角色金额目前表格提取情况_其他要素.csv')
  759. #
  760. # df = df.merge(df2, on='docid', how='inner')[:]
  761. # print(df.columns)
  762. # df = df[df['docid'].isin([673800683])]
  763. # # df = df[df['web_source_no'].str.contains('XX0757-')]
  764. # # df.drop_duplicates(subset=['web_source_no','page_time','original_docchannel'], inplace=True)
  765. # print(len(df))
  766. # datas = []
  767. # for docid, html, page_time, web_no, web_name, channel in zip(df['docid'], df['dochtmlcon'],
  768. # # df['doctitle'],
  769. # df['page_time'],
  770. # df['web_source_no'],
  771. # df['web_source_name'],
  772. # df['original_docchannel'],
  773. # ):
  774. # # html = '更正内容:本项目原成交供应商“合肥万展家具有限公司”因被质疑后放弃成交资格,采购人依据中华人民共和国财政部令第94号《政府采购质疑和投诉办法》中第十六条规定,按照评审报告推荐的成交候选人名单排序,确定第二成交候选人“六安万仞科技有限公司”为成交供应商。,'
  775. # # if '-' in web_no:
  776. # # web_no = web_no.split('-')[0]
  777. # # if web_no not in ['00198', '30306', 'DX000002', 'DX006116', 'DX007098', 'DX013702', 'DX016887', 'DX020336', 'shared_template', 'XX0182', 'XX0757', 'XX1068', 'XX7523']:
  778. # # continue
  779. # rs = predict(docid, html, '', page_time, web_no, web_name, channel, '')
  780. # print(rs)
  781. # # # datas.append((docid, rs))
  782. # # # df = pd.DataFrame(datas, columns=['docid', 'rs'])
  783. # # # df.to_csv('E:/模版提取/中国南方电网_模板提取结果.csv', index=False)