|
@@ -1785,7 +1785,8 @@ def findAttributeAfterEntity(PackDict,roleSet,PackageList,PackageSet,list_senten
|
|
# print('loc_relation2',_company.entity_text,_relation.entity_text)
|
|
# print('loc_relation2',_company.entity_text,_relation.entity_text)
|
|
_company.pointer_address = _relation
|
|
_company.pointer_address = _relation
|
|
# "联系人——联系电话" 链接规则补充
|
|
# "联系人——联系电话" 链接规则补充
|
|
- person_phone_EntityList = [ent for ent in pre_entity+ phone_entitys if ent.entity_type not in ['company','org','location']]
|
|
|
|
|
|
+ # person_phone_EntityList = [ent for ent in pre_entity+ phone_entitys if ent.entity_type not in ['company','org','location']]
|
|
|
|
+ person_phone_EntityList = [ent for ent in pre_entity+ phone_entitys if ent.entity_type not in ['location']]
|
|
person_phone_EntityList = sorted(person_phone_EntityList, key=lambda x: (x.sentence_index, x.begin_index))
|
|
person_phone_EntityList = sorted(person_phone_EntityList, key=lambda x: (x.sentence_index, x.begin_index))
|
|
t_match_list = []
|
|
t_match_list = []
|
|
for ent_idx in range(len(person_phone_EntityList)):
|
|
for ent_idx in range(len(person_phone_EntityList)):
|
|
@@ -1815,7 +1816,7 @@ def findAttributeAfterEntity(PackDict,roleSet,PackageList,PackageSet,list_senten
|
|
else:
|
|
else:
|
|
break
|
|
break
|
|
else:
|
|
else:
|
|
- if distance < 40:
|
|
|
|
|
|
+ if distance < 30:
|
|
# value = (-1 / 2 * (distance ** 2)) / 10000
|
|
# value = (-1 / 2 * (distance ** 2)) / 10000
|
|
t_match_list.append(Match(entity, after_entity, value))
|
|
t_match_list.append(Match(entity, after_entity, value))
|
|
match_nums += 1
|
|
match_nums += 1
|
|
@@ -1823,8 +1824,10 @@ def findAttributeAfterEntity(PackDict,roleSet,PackageList,PackageSet,list_senten
|
|
byNotPerson_match_nums += 1
|
|
byNotPerson_match_nums += 1
|
|
else:
|
|
else:
|
|
break
|
|
break
|
|
- else:
|
|
|
|
|
|
+ elif after_entity.entity_type == "person":
|
|
person_nums += 1
|
|
person_nums += 1
|
|
|
|
+ elif after_entity.entity_type in ["company","org"]:
|
|
|
|
+ break
|
|
# 前向查找属性
|
|
# 前向查找属性
|
|
if ent_idx != 0 and (not match_nums or not byNotPerson_match_nums):
|
|
if ent_idx != 0 and (not match_nums or not byNotPerson_match_nums):
|
|
previous_entity = person_phone_EntityList[ent_idx - 1]
|
|
previous_entity = person_phone_EntityList[ent_idx - 1]
|
|
@@ -1832,12 +1835,13 @@ def findAttributeAfterEntity(PackDict,roleSet,PackageList,PackageSet,list_senten
|
|
# if previous_entity.sentence_index == entity.sentence_index:
|
|
# if previous_entity.sentence_index == entity.sentence_index:
|
|
distance = (tokens_num_dict[entity.sentence_index] + entity.begin_index) - (
|
|
distance = (tokens_num_dict[entity.sentence_index] + entity.begin_index) - (
|
|
tokens_num_dict[previous_entity.sentence_index] + previous_entity.end_index)
|
|
tokens_num_dict[previous_entity.sentence_index] + previous_entity.end_index)
|
|
- if distance < 40:
|
|
|
|
|
|
+ if distance < 30:
|
|
# 前向 没有 /10000
|
|
# 前向 没有 /10000
|
|
value = (-1 / 2 * (distance ** 2))
|
|
value = (-1 / 2 * (distance ** 2))
|
|
t_match_list.append(Match(entity, previous_entity, value))
|
|
t_match_list.append(Match(entity, previous_entity, value))
|
|
# km算法分配求解(person-phone)
|
|
# km算法分配求解(person-phone)
|
|
t_match_list = [mat for mat in t_match_list if mat.main_role not in linked_connetPerson and mat.attribute not in linked_phone]
|
|
t_match_list = [mat for mat in t_match_list if mat.main_role not in linked_connetPerson and mat.attribute not in linked_phone]
|
|
|
|
+ # print([(mat.main_role.entity_text,mat.attribute.entity_text) for mat in t_match_list])
|
|
personphone_result = dispatch(t_match_list)
|
|
personphone_result = dispatch(t_match_list)
|
|
personphone_result = sorted(personphone_result, key=lambda x: (x[0].sentence_index, x[0].begin_index))
|
|
personphone_result = sorted(personphone_result, key=lambda x: (x[0].sentence_index, x[0].begin_index))
|
|
for match in personphone_result:
|
|
for match in personphone_result:
|