|
@@ -4,10 +4,10 @@ Created on 2019年5月21日
|
|
|
|
|
|
@author: User
|
|
|
'''
|
|
|
-import csv
|
|
|
import re
|
|
|
import os
|
|
|
import time
|
|
|
+import pandas as pd
|
|
|
_time = time.time()
|
|
|
from BiddingKG.dl.common.Utils import *
|
|
|
from BiddingKG.dl.interface.Entitys import *
|
|
@@ -38,35 +38,30 @@ def jaccard_score(source,target):
|
|
|
|
|
|
|
|
|
def get_place_list():
|
|
|
- with open(os.path.abspath(__file__) + '/../../place_info.csv', 'r') as f:
|
|
|
- reader = csv.reader(f)
|
|
|
- place_list = []
|
|
|
- for r in reader:
|
|
|
- place_list.append(r[1:3])
|
|
|
- place_list = place_list[1:]
|
|
|
- place_list.append(['台湾', '台湾'])
|
|
|
- place_list.append(['澳门', '澳门'])
|
|
|
- place_list.append(['香港', '香港'])
|
|
|
- place_list.append(['東莞', '東莞'])
|
|
|
- place_list.append(['廣州', '廣州'])
|
|
|
- place_list.append(['韩国', '韩国'])
|
|
|
- place_list.append(['德国', '德国'])
|
|
|
- place_list.append(['英国', '英国'])
|
|
|
- place_list.append(['日本', '日本'])
|
|
|
- place_list.append(['意大利', '意大利'])
|
|
|
- place_list.append(['新加坡', '新加坡'])
|
|
|
- place_list.append(['加拿大', '加拿大'])
|
|
|
- place_list.append(['西班牙', '西班牙'])
|
|
|
- place_list.append(['澳大利亚', '澳大利亚'])
|
|
|
- place_list.append(['美国', '美国'])
|
|
|
- # 去重
|
|
|
- place_list_str = []
|
|
|
- for place in place_list:
|
|
|
- place_list_str.append(str(place))
|
|
|
- place_list_str = list(set(place_list_str))
|
|
|
+ path = os.path.abspath(__file__) + '/../../place_info.csv'
|
|
|
+ place_df = pd.read_csv(path)
|
|
|
+
|
|
|
place_list = []
|
|
|
- for place in place_list_str:
|
|
|
- place_list.append(eval(place))
|
|
|
+ for index, row in place_df.iterrows():
|
|
|
+ place_list.append(row[1])
|
|
|
+
|
|
|
+ place_list.append('台湾')
|
|
|
+ place_list.append('澳门')
|
|
|
+ place_list.append('香港')
|
|
|
+ place_list.append('東莞')
|
|
|
+ place_list.append('廣州')
|
|
|
+ place_list.append('韩国')
|
|
|
+ place_list.append('德国')
|
|
|
+ place_list.append('英国')
|
|
|
+ place_list.append('日本')
|
|
|
+ place_list.append('意大利')
|
|
|
+ place_list.append('新加坡')
|
|
|
+ place_list.append('加拿大')
|
|
|
+ place_list.append('西班牙')
|
|
|
+ place_list.append('澳大利亚')
|
|
|
+ place_list.append('美国')
|
|
|
+
|
|
|
+ place_list = list(set(place_list))
|
|
|
return place_list
|
|
|
|
|
|
|
|
@@ -114,19 +109,17 @@ def link_entitys(list_entitys,on_value=0.8):
|
|
|
# 判断两个公司地区相同
|
|
|
match_list_1, match_list_2 = [], []
|
|
|
for place in place_list:
|
|
|
- if place[0] in _entity.entity_text:
|
|
|
- match_list_1.append(place[0])
|
|
|
- if place[0] in _ent.entity_text:
|
|
|
- match_list_2.append(place[0])
|
|
|
+ if place in _entity.entity_text:
|
|
|
+ match_list_1.append(place)
|
|
|
+ if place in _ent.entity_text:
|
|
|
+ match_list_2.append(place)
|
|
|
|
|
|
if str(match_list_1) == str(match_list_2):
|
|
|
# print("字典替换", _entity.entity_text, "->", _ent.entity_text)
|
|
|
_entity.origin_entity_text = _entity.entity_text
|
|
|
_entity.entity_text = _ent.entity_text
|
|
|
used_linked_entitys.append(_ent)
|
|
|
- # print(_entity.entity_text, _entity.if_dict_match, _ent.entity_text, _ent.if_dict_match)
|
|
|
-
|
|
|
-
|
|
|
+ # print(_entity.entity_text, _entity.if_dict_match, _ent.entity_text, _ent.if_dict_match)
|
|
|
|
|
|
|
|
|
def getEnterprisePath():
|