|
@@ -3845,6 +3845,85 @@ def get_win_joint(prem, list_entitys, list_sentences, list_articles):
|
|
except Exception as e:
|
|
except Exception as e:
|
|
print('获取联合体抛出异常', e)
|
|
print('获取联合体抛出异常', e)
|
|
|
|
|
|
|
|
+def get_multi_winner_and_money(channel_dic, prem, list_entitys,list_sentences):
|
|
|
|
+ '''
|
|
|
|
+ 获取多中标人及正文、附件所有金额,多中标人multi_winner写入prem,返回金额列表
|
|
|
|
+ :param channel_dic:
|
|
|
|
+ :param prem:
|
|
|
|
+ :param list_entitys:
|
|
|
|
+ :param list_sentences:
|
|
|
|
+ :return:
|
|
|
|
+ '''
|
|
|
|
+ moneys = []
|
|
|
|
+ moneys_attachment = []
|
|
|
|
+ if channel_dic['docchannel']['docchannel']=='中标信息' and 'win_tenderer' in str(prem):
|
|
|
|
+ sentences = sorted(list_sentences[0], key=lambda x: x.sentence_index)
|
|
|
|
+ finalists = [] # 入围供应商
|
|
|
|
+ i = 0
|
|
|
|
+ while i < len(list_entitys[0])-1:
|
|
|
|
+ ent = list_entitys[0][i]
|
|
|
|
+ b_idx_fr = ent.wordOffset_begin
|
|
|
|
+ e_idx_fr = ent.wordOffset_end
|
|
|
|
+ multi_winner_l = [ent.entity_text]
|
|
|
|
+ i += 1
|
|
|
|
+ if ent.entity_type in ['money']:
|
|
|
|
+ money = float(ent.entity_text)
|
|
|
|
+ if ent.in_attachment:
|
|
|
|
+ moneys_attachment.append(money)
|
|
|
|
+ else:
|
|
|
|
+ moneys.append(money)
|
|
|
|
+ if ent.entity_type in ['org', 'company'] and ent.label == 2 and ent.values[ent.label]>0.5:
|
|
|
|
+ sentence_text = sentences[ent.sentence_index].sentence_text
|
|
|
|
+ pre_text = sentence_text[max(0, b_idx_fr-10):b_idx_fr]
|
|
|
|
+ if re.search('入围', pre_text) and re.search('未入围', pre_text)==None and ent.entity_text not in finalists:
|
|
|
|
+ finalists.append(ent.entity_text)
|
|
|
|
+ for j in range(i, len(list_entitys[0])):
|
|
|
|
+ ent_bh = list_entitys[0][j]
|
|
|
|
+ b_idx_bh = ent_bh.wordOffset_begin
|
|
|
|
+ e_idx_bh = ent_bh.wordOffset_end
|
|
|
|
+ if ent_bh.entity_type in ['org', 'company'] and ent_bh.label == 5 and ent_bh.sentence_index == ent.sentence_index and b_idx_bh-e_idx_fr==1:
|
|
|
|
+ sentence_text = sentences[ent_bh.sentence_index].sentence_text
|
|
|
|
+ if sentence_text[e_idx_fr:b_idx_bh] in [';','、'] and sentence_text[e_idx_bh] in ['、', ',', '。']:
|
|
|
|
+ multi_winner_l.append(ent_bh.entity_text)
|
|
|
|
+ e_idx_fr = e_idx_bh
|
|
|
|
+ i = j + 1
|
|
|
|
+ else:
|
|
|
|
+ break
|
|
|
|
+ else:
|
|
|
|
+ break
|
|
|
|
+ if len(multi_winner_l)>=2:
|
|
|
|
+ for project in prem[0].values():
|
|
|
|
+ if not isinstance(project, dict):
|
|
|
|
+ continue
|
|
|
|
+ for v in project.values():
|
|
|
|
+ for d in v['roleList']:
|
|
|
|
+ if d.get('role_name', '') == 'win_tenderer':
|
|
|
|
+ winner = d.get('role_text')
|
|
|
|
+ if winner == multi_winner_l[0]:
|
|
|
|
+ d['multi_winner'] = ','.join(multi_winner_l)
|
|
|
|
+ break
|
|
|
|
+
|
|
|
|
+ if len(finalists)>=2:
|
|
|
|
+ for project in prem[0].values():
|
|
|
|
+ if not isinstance(project, dict):
|
|
|
|
+ continue
|
|
|
|
+ for v in project.values():
|
|
|
|
+ for d in v['roleList']:
|
|
|
|
+ if d.get('role_name', '') == 'win_tenderer':
|
|
|
|
+ winner = d.get('role_text')
|
|
|
|
+ if winner in finalists:
|
|
|
|
+ d['multi_winner'] = ','.join(finalists)
|
|
|
|
+ else:
|
|
|
|
+ for i in range(len(list_entitys[0])):
|
|
|
|
+ ent = list_entitys[0][i]
|
|
|
|
+ if ent.entity_type in ['money']:
|
|
|
|
+ money = float(ent.entity_text)
|
|
|
|
+ if ent.in_attachment:
|
|
|
|
+ moneys_attachment.append(money)
|
|
|
|
+ else:
|
|
|
|
+ moneys.append(money)
|
|
|
|
+ return {'moneys': list(set(moneys)), 'moneys_attachment': list(set(moneys_attachment))}
|
|
|
|
+
|
|
def update_prem(old_prem, new_prem):
|
|
def update_prem(old_prem, new_prem):
|
|
'''
|
|
'''
|
|
根据新旧对比,更新数据
|
|
根据新旧对比,更新数据
|