测试整个要素提取流程.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. '''
  2. Created on 2019年1月4日
  3. @author: User
  4. '''
  5. from bs4 import BeautifulSoup, Comment
  6. import copy
  7. import re
  8. import sys
  9. import os
  10. import codecs
  11. import requests
  12. import time
  13. _time1 = time.time()
  14. sys.path.append(os.path.abspath("../.."))
  15. sys.path.append(os.path.abspath('../../'))
  16. print('当前路径为:',os.getcwd())
  17. print('sys.path',sys.path)
  18. import fool
  19. from BiddingKG.dl.interface.Connection import *
  20. from BiddingKG.dl.common.Utils import *
  21. from BiddingKG.dl.interface.Connection import getConnection
  22. import BiddingKG.dl.interface.predictor as predictor
  23. import BiddingKG.dl.interface.Preprocessing as Preprocessing
  24. import BiddingKG.dl.interface.getAttributes as getAttributes
  25. import BiddingKG.dl.entityLink.entityLink as entityLink
  26. import json
  27. '''
  28. doc_id = '3537ed94-9c7e-11e8-aed5-44a84246dbba'
  29. conn = psycopg2.connect(dbname="BiddingKG",user="postgres",password="postgres",host="192.168.2.101")
  30. cursor = conn.cursor()
  31. cursor.execute(" select content from articles where id='"+doc_id+"' ")
  32. row = cursor.fetchall()[0]
  33. #text = codecs.open("C:\\Users\\User\\Desktop\\1.html","r",encoding="utf8").read()
  34. #content = segment(tableToText(BeautifulSoup(row[0],"lxml")))
  35. '''
  36. ''''''
  37. codeNamePredict = predictor.CodeNamePredict()
  38. premPredict = predictor.PREMPredict()
  39. epcPredict = predictor.EPCPredict()
  40. roleRulePredict = predictor.RoleRulePredictor()
  41. #自定义jsonEncoder
  42. class MyEncoder(json.JSONEncoder):
  43. def default(self, obj):
  44. if isinstance(obj, np.ndarray):
  45. return obj.tolist()
  46. elif isinstance(obj, bytes):
  47. return str(obj, encoding='utf-8')
  48. elif isinstance(obj, (np.float_, np.float16, np.float32,
  49. np.float64)):
  50. return float(obj)
  51. elif isinstance(obj,str):
  52. return obj
  53. return json.JSONEncoder.default(self, obj)
  54. def predict(doc_id,text):
  55. list_articles,list_sentences,list_entitys,_ = Preprocessing.get_preprocessed([[doc_id,text,"","",""]],useselffool=True)
  56. for articles in list_articles:
  57. print('预处理后文本信息')
  58. print(articles.content)
  59. for sentences in list_sentences:
  60. for sentence in sentences:
  61. print(sentence.tokens)
  62. ''''''
  63. codeName = codeNamePredict.predict(list_sentences,list_entitys=list_entitys)
  64. # print(codeName)
  65. premPredict.predict(list_sentences,list_entitys)
  66. # for entitys in list_entitys:
  67. # for entity in entitys:
  68. # if entity.entity_type in ['org','company']:
  69. # print("公司->联系人2:", end=' ')
  70. # print(entity.entity_text, entity.pointer_person,entity.label,entity.values)
  71. # pass
  72. roleRulePredict.predict(list_articles,list_sentences, list_entitys,codeName)
  73. # print("epcPredict")
  74. epcPredict.predict(list_sentences,list_entitys)
  75. # print("entityLink")
  76. entityLink.link_entitys(list_entitys)
  77. # print("getPREMs")
  78. prem = getAttributes.getPREMs(list_sentences,list_entitys,list_articles)
  79. # print("getPREMs")
  80. print("公司——联系人:", end=' ')
  81. print(prem[0])
  82. print(prem[0]['prem']['Project']['roleList'])
  83. ''''''
  84. entitys_all = [[[entity.entity_text,entity.entity_type,entity.label,entity.values,entity.sentence_index,entity.begin_index,entity.end_index] for entity in entitys] for entitys in list_entitys]
  85. # for entitys in entitys_all:
  86. # print(entitys)
  87. # en_types = set([it[1] for it in entitys])
  88. # print([(it[0],it[1], it[2],it[3][it[2]],it[4],it[5],it[6]) for it in entitys if it[1] in ('org', 'company', 'person')])
  89. # print([it for it in entitys if it[1] in ('org','company','person')])
  90. # for en_type in en_types:
  91. # print('***************************************')
  92. # print(en_type)
  93. # print([(it[0],it[2],it[3]) for it in entitys if it[1]==en_type])
  94. for entitys in list_entitys:
  95. entitys = sorted(entitys, key=lambda x: (x.sentence_index, x.wordOffset_begin))
  96. for entity in entitys:
  97. # print('**********实体信息****************')
  98. if entity.entity_type=='person':
  99. print("联系方式:",end=' ')
  100. print(entity.entity_text,[i.entity_text for i in entity.person_phone] if entity.person_phone else None,entity.label,entity.values)
  101. print(entity.sentence_index)
  102. elif entity.entity_type in ['org','company']:
  103. _sentence = list_sentences[0][entity.sentence_index]
  104. if entity.pointer_person:
  105. print("公司->联系人1:",end=' ')
  106. print(entity.entity_text,[i.entity_text for i in entity.pointer_person],entity.label,entity.values)
  107. # print(entity.entity_text,entity.label,entity.values)
  108. # print(_sentence.sentence_text,_sentence.tokens[entity.begin_index:entity.end_index+1])
  109. else:
  110. print("公司->联系人2:", end=' ')
  111. print(entity.entity_text, entity.pointer_person,entity.label,entity.values)
  112. # print(_sentence.sentence_text,_sentence.tokens[entity.begin_index:entity.end_index+1])
  113. pass
  114. # print(entity.pointer_pack)
  115. # if entity.pointer_pack:
  116. # print('pointer_pack_name:',entity.pointer_pack.entity_text)
  117. # elif entity.entity_type in ['package']:
  118. # print('pack_entity:',entity.entity_text)
  119. # elif entity.entity_type=='time':
  120. # print("时间:", end=' ')
  121. # print(entity.entity_text, entity.label, entity.values)
  122. # print(entity.entity_text,entity.entity_type,entity.label,entity.values,entity.sentence_index,entity.wordOffset_begin,entity.wordOffset_end)
  123. #print(prem)
  124. return json.dumps(Preprocessing.union_result(codeName, prem)[0][1],cls=MyEncoder,sort_keys=True,indent=4,ensure_ascii=False)
  125. # def test(name,content):
  126. # user = {
  127. # "content": content,
  128. # "id":name
  129. # }
  130. # myheaders = {'Content-Type': 'application/json'}
  131. # _resp = requests.post("http://192.168.2.101:15015" + '/article_extract', json=user, headers=myheaders, verify=True)
  132. # resp_json = _resp.content.decode("utf-8")
  133. # print(resp_json)
  134. # return resp_json
  135. def get_result_online(docid):
  136. import psycopg2
  137. conn = psycopg2.connect(dbname='iepy', user='postgres', password='postgres', host='192.168.2.101')
  138. cursor = conn.cursor()
  139. sql = """select human_identifier,sourcetext from corpus_iedocument where human_identifier in ('{0}');""".format(docid)
  140. cursor.execute(sql)
  141. rows = cursor.fetchall()
  142. user = {
  143. "content": rows[0][1],
  144. "id":docid
  145. }
  146. myheaders = {'Content-Type': 'application/json'}
  147. _resp = requests.post("http://192.168.2.101:15030" + '/article_extract', json=user, headers=myheaders, verify=True) # 15015 #最新模型15030
  148. resp_json = _resp.content.decode("utf-8")
  149. return json.loads(resp_json)
  150. def get_result(docid):
  151. import psycopg2
  152. conn = psycopg2.connect(dbname='iepy', user='postgres', password='postgres', host='192.168.2.101')
  153. cursor = conn.cursor()
  154. sql = """select human_identifier,sourcetext from corpus_iedocument where human_identifier in ('{0}');""".format(docid)
  155. cursor.execute(sql)
  156. rows = cursor.fetchall()
  157. return(json.loads(predict(docid, rows[0][1])))
  158. def analys_person_phone():
  159. import pandas as pd
  160. import time
  161. t1 = time.time()
  162. df = pd.read_excel(r'E:\workspace\BiddingKG\BiddingKG\dl\person\实习生标注信息角色联系人电话.xlsx', encoding='utf-8')
  163. lab_num = pos_num = pre_num = 0
  164. lab_num2 = pos_num2 = pre_num2 = 0
  165. lab_person = pos_person = pre_person = 0
  166. lab_role = pos_role = pre_role = 0
  167. person_errors = []
  168. phone_errors = []
  169. join_errors = []
  170. person_name_errors =[]
  171. role_name_errors =[]
  172. for docid in set(df['doc_id']):
  173. print('开始处理 : ',docid)
  174. df_tmp = df[df.loc[:, 'doc_id'] == docid]
  175. values = list(df_tmp['value'])
  176. a = [it.split() for it in values]
  177. rel_person = [it for it in a if it[1] == 'rel_person']
  178. rel_phone = [it for it in a if it[1] == 'rel_phone']
  179. r1 = get_result(str(docid))
  180. # r1 = get_result_online(str(docid))
  181. label_role_person = [] # 标注角色+联系人
  182. for rel in rel_person:
  183. role = [it for it in a if it[0] == rel[2].split(':')[-1]]
  184. person = [it for it in a if it[0] == rel[3].split(':')[-1]]
  185. if person != [] and role != []:
  186. label_role_person.append(role[0][-1] +'+'+ person[0][-1])
  187. label_person_phone = [] # 标注角色+联系人
  188. for rel in rel_phone:
  189. person = [it for it in a if it[0] == rel[2].split(':')[-1]]
  190. phone = [it for it in a if it[0] == rel[3].split(':')[-1]]
  191. if person != [] and phone != []:
  192. label_person_phone.append(person[0][-1] +'+'+ phone[0][-1])
  193. role_person = []
  194. person_phone = []
  195. if r1.get('success','')==False:
  196. print(docid, '接口返回失败 ')
  197. else:
  198. for v in r1['prem'].values():
  199. roleList = v['roleList']
  200. for role in roleList:
  201. for it in role[3]:
  202. role_person.append(role[1] +'+'+ it[0])
  203. for role in roleList:
  204. for it in role[3]:
  205. person_phone.append(it[0] +'+'+ it[1])
  206. # print(set(label_person_phone))
  207. # print(set(person_phone))
  208. pos_num += len(set(role_person) & set(label_role_person))
  209. lab_num += len(set(label_role_person))
  210. pre_num += len(set(role_person))
  211. if set(role_person)&set(label_role_person) != set(label_role_person):
  212. person_errors.append([docid, set(label_role_person), set(role_person)])
  213. # 判断角色联系人是否正确逻辑:1、先看预测角色是否都在标签角色里,2判断预测联系人是否在标签联系人,
  214. # print(set(role_person))
  215. # print(set(label_role_person))
  216. if set(label_person_phone) & set(person_phone)!=set(label_person_phone):
  217. phone_errors.append([docid, set(label_person_phone), set(person_phone)])
  218. pos_num2 += len(set(label_person_phone) & set(person_phone))
  219. lab_num2 += len(set(label_person_phone))
  220. pre_num2 += len(set(person_phone))
  221. lab_person += len(set([it.split('+')[1] for it in label_role_person]))
  222. pos_person += len(set([it.split('+')[1] for it in label_role_person])&set([it.split('+')[1] for it in role_person]))
  223. pre_person += len(set([it.split('+')[1] for it in role_person]))
  224. lab_role += len(set([it.split('+')[0] for it in label_role_person]))
  225. pos_role += len(set([it.split('+')[0] for it in label_role_person])&set([it.split('+')[0] for it in role_person]))
  226. pre_role += len(set([it.split('+')[0] for it in role_person]))
  227. if set([it.split('+')[0] for it in label_role_person]) != set([it.split('+')[0] for it in role_person]):
  228. if set([it.split('+')[1] for it in label_role_person]) != set([it.split('+')[1] for it in role_person]):
  229. person_name_errors.append([docid,set(label_role_person), set(role_person)])
  230. else:
  231. role_name_errors.append([docid, set(label_role_person), set(role_person)])
  232. else:
  233. if set([it.split('+')[1] for it in label_role_person]) != set([it.split('+')[1] for it in role_person]):
  234. person_name_errors.append([docid, set(label_role_person), set(role_person)])
  235. elif set(label_role_person)!= set(role_person):
  236. print(docid,set(label_role_person), set(role_person))
  237. join_errors.append([docid,set(label_role_person), set(role_person)])
  238. print('单独角色召回率:%.4f,准确率:%.4f'%(pos_role/lab_role, pos_role/pre_role))
  239. print('单独联系人召回率:%.4f, 准确率:%.4f'%(pos_person/lab_person, pos_person/pre_person))
  240. print('联系人召回率:%.4f, 准确率:%.4f' % (pos_num / lab_num, pos_num / pre_num))
  241. print('电话召回率:%.4f,准确率:%.4f' % (pos_num2 / lab_num2, pos_num2 / pre_num2))
  242. print('总耗时:',time.time()-t1)
  243. return person_errors, phone_errors, join_errors, role_name_errors, person_name_errors
  244. def predict_fromdb(docid, dbname="sys_document_23"):
  245. # import pymysql
  246. # conn = pymysql.Connect(host='rm-bp1quo50k0q2ok73gi.mysql.rds.aliyuncs.com', port=3306, db='bxkc', user='bxkc_read', passwd='bxkc_20RE18AD') #新账号密码
  247. # cursor = conn.cursor()
  248. # sql = "SELECT docid as id, dochtmlcon as content from {1} WHERE DOCID='{0}';".format(docid, dbname)
  249. import psycopg2
  250. conn = psycopg2.connect(dbname='iepy', user='postgres', password='postgres', host='192.168.2.101')
  251. cursor = conn.cursor()
  252. sql = """select human_identifier as id,sourcetext as content from corpus_iedocument where human_identifier in ('{0}');""".format(docid)
  253. cursor.execute(sql)
  254. rows = cursor.fetchall()
  255. doc_id = rows[0][0]
  256. text = rows[0][1]
  257. # text = '竟然很明显的表达没识别为代理,代理机构名称:国信国采(北京)招标咨询有限责任公司,代理机构地址:北京市海淀区首体南路22号国兴大厦11层, 1.采购人信息名 称:北京市植物园。'
  258. list_articles, list_sentences, list_entitys, _ = Preprocessing.get_preprocessed([[doc_id, text, "", "", ""]],useselffool=True)
  259. codeName = codeNamePredict.predict(list_sentences, list_entitys=list_entitys)
  260. # print(codeName)
  261. premPredict.predict(list_sentences, list_entitys)
  262. roleRulePredict.predict(list_articles, list_sentences, list_entitys, codeName)
  263. # print("epcPredict")
  264. epcPredict.predict(list_sentences, list_entitys)
  265. # print("entityLink")
  266. entityLink.link_entitys(list_entitys)
  267. # print("getPREMs")
  268. prem = getAttributes.getPREMs(list_sentences, list_entitys, list_articles)
  269. return list_articles, list_sentences, list_entitys, codeName, prem
  270. if __name__=="__main__":
  271. # import pandas as pd
  272. # import math
  273. # import pymysql
  274. # conn = pymysql.Connect(host='rm-bp1quo50k0q2ok73gi.mysql.rds.aliyuncs.com', port=3306, db='bxkc', user='bxkc_read', passwd='bxkc_20RE18AD') #新账号密码
  275. # cursor = conn.cursor()
  276. # df = pd.read_excel('G:/大网站规则识别/1027统计入库top100编号.xlsx')
  277. # docs_list = []
  278. # for i in range(100):
  279. # web_no = df.loc[i, '编号']
  280. # # num = math.ceil(int(df.loc[i, '1019-1023入库公告数量']) * 0.01)
  281. # num = 10
  282. # sql = "SELECT DOCID,DOCCHANNEL,DOCHTMLCON,WEB_SOURCE_NO from sys_document_23 where WEB_SOURCE_NO='{0}' and DOCCHANNEL='101' and DOCID%9=1 limit {1}".format(
  283. # web_no, num)
  284. # # rows = cursor.execute(sql) 此处代码错误 rows 需要用 cursor.fetchall方法获取
  285. # cursor.execute(sql)
  286. # rows = cursor.fetchall()
  287. # docs_list.extend(list(rows))
  288. # df_doc = pd.DataFrame(docs_list, columns=['docid', 'channel', 'html', 'web_no'])
  289. # codenames = []
  290. # prems = []
  291. # for docid,text in zip(df_doc['docid'], df_doc['html']):
  292. # list_articles, list_sentences, list_entitys, _ = Preprocessing.get_preprocessed([[docid, text, "", "", ""]],
  293. # useselffool=True)
  294. # codeName = codeNamePredict.predict(list_sentences, list_entitys=list_entitys)
  295. # # print(codeName)
  296. # premPredict.predict(list_sentences, list_entitys)
  297. # roleRulePredict.predict(list_articles, list_sentences, list_entitys, codeName)
  298. # # print("epcPredict")
  299. # epcPredict.predict(list_sentences, list_entitys)
  300. # # print("entityLink")
  301. # entityLink.link_entitys(list_entitys)
  302. # # print("getPREMs")
  303. # prem = getAttributes.getPREMs(list_sentences, list_entitys, list_articles)
  304. # if codeName:
  305. # codenames.append(codeName[0][1])
  306. # else:
  307. # codenames.append(" ")
  308. # if prem:
  309. # prems.append(prem[0][1])
  310. # else:
  311. # prems.append(" ")
  312. # df_doc['codename'] = pd.Series(codenames)
  313. # df_doc['prem'] = pd.Series(prems)
  314. # df_doc.to_excel('G:/大网站规则识别/大网站规则调整后预测结果20201124.xlsx', columns=['docid', 'channel', 'html', 'prem', 'codename', 'web_no'])
  315. # list_articles, list_sentences, list_entitys, codeName, prem = predict_fromdb('82862794',dbname="sys_document_25") #sys_document_23
  316. # print(prem)
  317. # print(codeName)
  318. # entitys_all = [[[entity.entity_text,entity.entity_type,entity.label,entity.values,entity.sentence_index,entity.begin_index,entity.end_index] for entity in entitys] for entitys in list_entitys]
  319. # for entitys in entitys_all:
  320. # # print(entitys)
  321. # # en_types = set([it[1] for it in entitys])
  322. # print([(it[0],it[1], it[2],it[3][it[2]],it[4],it[5],it[6]) for it in entitys if it[1] in ('org', 'company', 'person')])
  323. # print(list_articles[0].content)
  324. # print(get_result('100000203'))
  325. # person_errors, phone_errors, join_errors, role_name_errors, person_name_errors = analys_person_phone()
  326. # import pickle
  327. # with open('phone_errors.pkl','wb') as f:
  328. # pickle.dump(phone_errors, f)
  329. # filename = "比地_52_79929693.html"
  330. # #text = codecs.open("C:\\Users\\User\\Desktop\\数据20191014\\"+filename,"r",encoding="utf8").read()
  331. # # text = codecs.open("C:\\Users\\User\\Desktop\\2.html","r",encoding="utf8").read()
  332. # # text = codecs.open('F:/工作文档/实体识别实体对其/20190320/比地_101_58511386.html', encoding='utf-8').read()
  333. # docid = '100000203'
  334. # r1 = get_result(docid)
  335. # r2 = get_result_online(docid)
  336. # rolperson = []
  337. # person_phone = []
  338. # for v in r1['prem'].values():
  339. # roleList = v['roleList']
  340. # for role in roleList:
  341. # for it in role[3]:
  342. # rolperson.append(role[1] + it[0])
  343. # for role in roleList:
  344. # for it in role[3]:
  345. # person_phone.append(it[0]+it[1])
  346. # print(r1['prem'])
  347. # print(r2['prem'])
  348. #
  349. # import psycopg2
  350. # conn = psycopg2.connect(dbname='iepy', user='postgres', password='postgres', host='192.168.2.101')
  351. # cursor = conn.cursor()
  352. # sql = """select human_identifier,sourcetext from corpus_iedocument where human_identifier in ('95008163');"""
  353. # cursor.execute(sql)
  354. # rows = cursor.fetchall()
  355. # # print(len(rows), rows)
  356. # content = rows[0][1]
  357. # content = str(BeautifulSoup(text).find("div",id="pcontent"))
  358. # # content = text
  359. # # print('content: ',content)
  360. # #text = codecs.open("C:\\Users\\User\\Desktop\\a.html","r",encoding="utf8").read()
  361. # text = '''
  362. # 招标人:常州市金坛区直溪镇迪庄村村民委员会,地址:直溪镇迪庄村,电话:18798916198电话:17798916098,
  363. # '''
  364. text = '''
  365. 招标人:湖南财信金融控股集团有限公司,招标代理机构:湖南省招标有限责任公司。联系人:曾君联系人:夏女士,电话:0731-84556896电话:0731-85196661
  366. '''
  367. # text=''',东莞市粤隆招标有限公司受东莞市道滘镇教育管理中心的委托,于2020年05月20日就2020年道滘镇公办中小学增加多媒体教学平台
  368. # 采购项目(441900-10-202003-1606000137-0006)采用公开招标进行采购。现就本次采购的中标(成交)结果公告如下:
  369. # 一、采购项目编号:441900-10-202003-1606000137-0006二、采购项目名称:2020年道滘镇公办中小学增加多媒体教学平台采购项目三、
  370. # 采购项目预算金额(元):3,505,265.00四、采购方式:公开招标五、中标供应商,1:A包中标供应商名称东莞市靖恩智能科技有限公司法人代表王地址
  371. # 东莞市高埗镇高埗大道93号301房,六、报价明细,备注。主要中标、成交标的名称:2020年道滘镇公办中小学增加多媒体教学平台采购项目,
  372. # 中标供应商:东莞市靖恩智能科技有限公司,包编号:A,规格型号:\,数量:1,预算(元):3,505,265.00,服务要求:详见招标文件,
  373. # 中标、成交金额(元):3,478,120.00。报价明细附件七、评审日期:2020-05-20评审地点:广东省东莞市道滘镇道厚路创新岛2号四楼,评审委员会
  374. # (谈判小组、询价小组、磋商小组或单一来源采购小组):负责人:廖云峰,成员:叶润宁、莫立基、李松涛和吴树根,八、本项目代理收费标准:国家发展
  375. # 和改革委员会“发改价格[2011]534号文”及国家发展计划委员会“计价格[2002]1980号文”相关规定,收费金额:人民币肆万贰仟贰佰伍拾玖元整(¥42,259.00元)九、
  376. # 评审意见(非标采购方式或竞争性磋商采购方式采用书面推荐供应商参加采购活动的,还应当公告采购人和评审专家的推荐意见),经评标委员会一致决定,
  377. # 推荐2020年道滘镇公办中小学增加多媒体教学平台采购项目为第一中标候选人,十、本公告期限1个工作日。十一、联系事项:
  378. # (一),采购项目联系人(代理机构):翟先生,联系电话:0769-88839111,采购项目联系人(采购人):李先生,联系电话:0769-81332303。
  379. # (二),采购代理机构:东莞市粤隆招标有限公司,地址:东莞市南城街道体育路2号鸿禧中心B902号,联系人:翟先生,联系电话:0769-88839111,
  380. # 传真:0769-81216222,邮编:523000。(三),采购人:东莞市道滘镇教育管理中心,地址:广东省东莞市道滘镇花园街1号,联系人:李先生,联系电话:0769-81332303,传真:/,邮编:523000,各有关当事人对中标、成交结果有异议的,可以在中标、成交公告发布之日起7个工作日内以书面形式向(政府采购代理机构)(或采购人)提出质疑,逾期将依法不予受理,'''
  381. text = codecs.open("C:\\Users\\Administrator\\Desktop\\test12354.txt", "r", encoding="utf8").read()
  382. content = str(BeautifulSoup(text).find("div", id="pcontent"))
  383. # text = '''
  384. # 采购代理机构:山东立行建设项目管理有限公司地址:山东省临沂市兰山县(区)柳青广州路与蒙河路交汇大官苑社区西沿街A区三楼南侧号,联系方式:17862288900,
  385. # '''
  386. # text = '''
  387. # (二),采购人信息,名称:四川省绵阳市平武县卫生健康局,地址:东莞市南城街道体育路2号鸿禧中心B902号,(三),采购代理机构信息,名称:四川省蜀汉硕创工程项目管理有限公司,地址:体育路2号鸿禧中心B,联系人:翟先生,联系电话:0769-88839111,
  388. # 采购项目,联系电话:0769-81332303/0769-81332903,联系人姓名和电话:李先生/廖云峰\叶润宁,
  389. # '''
  390. a = time.time()
  391. print("start")
  392. # print(predict("12",content))
  393. # result = predict("12",text)
  394. result = predict("12",content)
  395. # print(json.loads(result))
  396. #test("12",text)
  397. print("takes",time.time()-a)
  398. _time2 = time.time()
  399. # print(predict("12",content))
  400. _time3 = time.time()
  401. print("init takes:%d"%((_time2-_time1)-(_time3-_time2)))
  402. pass