Skip to content

Commit 614af4e

Browse files
committed
修改bug
1 parent 6542191 commit 614af4e

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding//src/parse.py=utf-8

parseData/src/log.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,15 @@
148148

149149

150150

151+
数据库连接成功!
152+
153+
154+
155+
156+
157+
数据库连接成功!
158+
159+
160+
161+
162+

parseData/src/parse.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding=utf-8 -*-
12
'''
23
Created on 2017年3月30日
34
@@ -246,19 +247,19 @@ def extractPerson(self,entityInfo,level = 1):
246247
# for key in entityInfo.keys():
247248
person = Person()
248249
if 'entity_name' in entityInfo:
249-
person.setName(entityInfo['entity_name'])
250+
person.setName(entityInfo['entity_name'].replace("'","''"))
250251
if 'url' in entityInfo:
251252
person.setUrl(entityInfo['url'])
252253
if 'entity_image' in entityInfo:
253254
person.setImageUrl(entityInfo['entity_image'])
254255
if 'catalog_name' in entityInfo:
255256
person.setCatalog(entityInfo['catalog_name'])
256257
if 'introduction' in entityInfo:
257-
person.setIntroduction(entityInfo['introduction'])
258+
person.setIntroduction(entityInfo['introduction'].replace("'","''"))
258259
if 'entity_detail' in entityInfo:
259-
person.setBasicInfo(entityInfo['entity_detail'])
260+
person.setBasicInfo(entityInfo['entity_detail'].replace("'","''"))
260261
if 'text_file' in entityInfo:
261-
person.setDetail(entityInfo['text_file'])
262+
person.setDetail(entityInfo['text_file'].replace("'","''"))
262263
if 'entity_tag' in entityInfo:
263264
person.setTag(entityInfo['entity_tag'])
264265

@@ -284,11 +285,11 @@ def extractInstitution(self,entityInfo):
284285
if 'catalog_name' in entityInfo:
285286
institution.setCatalog(entityInfo['catalog_name'])
286287
if 'introduction' in entityInfo:
287-
institution.setIntroduction(entityInfo['introduction'])
288+
institution.setIntroduction(entityInfo['introduction'].replace("'","''"))
288289
if 'entity_detail' in entityInfo:
289-
institution.setBasicInfo(entityInfo['entity_detail'])
290+
institution.setBasicInfo(entityInfo['entity_detail'].replace("'","''"))
290291
if 'text_file' in entityInfo:
291-
institution.setDetail(entityInfo['text_file'])
292+
institution.setDetail(entityInfo['text_file'].replace("'","''"))
292293
if 'entity_tag' in entityInfo:
293294
institution.setTag(entityInfo['entity_tag'])
294295

@@ -335,6 +336,9 @@ def getEntityType(self,entityName,entityTag):
335336

336337
if not self.organizeString:
337338
self.readOrganizedict()
339+
if entityName == "":
340+
return None
341+
338342

339343
entityNT = entityName + entityTag
340344
PTag = '人物'
@@ -363,7 +367,8 @@ def insertPerson(self,tableName,person,cur,conn):
363367
print(last_id)
364368
return last_id
365369
except:
366-
pass
370+
raise
371+
367372
def insertRelation(self,tableName,relation,cur,conn):
368373
str = "INSERT INTO %s(ID1,ID2,Type,Name,Strength) VALUES('%s','%s','%s','%s','%s')"%(tableName,relation.getId1(),relation.getId2(),relation.getType(),relation.getName(),relation.getStrength())
369374
print(str)

parseData/src/test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
#
151151
# print(entityInfoDict)
152152

153-
url = 'dsada'
154-
print(list(url))
153+
# url = 'dsada'
154+
# print(list(url))
155155

156+
print("zhang'hao".replace("'", "''"))

0 commit comments

Comments
 (0)