1
+ # -*- coding=utf-8 -*-
1
2
'''
2
3
Created on 2017年3月30日
3
4
@@ -246,19 +247,19 @@ def extractPerson(self,entityInfo,level = 1):
246
247
# for key in entityInfo.keys():
247
248
person = Person ()
248
249
if 'entity_name' in entityInfo :
249
- person .setName (entityInfo ['entity_name' ])
250
+ person .setName (entityInfo ['entity_name' ]. replace ( "'" , "''" ) )
250
251
if 'url' in entityInfo :
251
252
person .setUrl (entityInfo ['url' ])
252
253
if 'entity_image' in entityInfo :
253
254
person .setImageUrl (entityInfo ['entity_image' ])
254
255
if 'catalog_name' in entityInfo :
255
256
person .setCatalog (entityInfo ['catalog_name' ])
256
257
if 'introduction' in entityInfo :
257
- person .setIntroduction (entityInfo ['introduction' ])
258
+ person .setIntroduction (entityInfo ['introduction' ]. replace ( "'" , "''" ) )
258
259
if 'entity_detail' in entityInfo :
259
- person .setBasicInfo (entityInfo ['entity_detail' ])
260
+ person .setBasicInfo (entityInfo ['entity_detail' ]. replace ( "'" , "''" ) )
260
261
if 'text_file' in entityInfo :
261
- person .setDetail (entityInfo ['text_file' ])
262
+ person .setDetail (entityInfo ['text_file' ]. replace ( "'" , "''" ) )
262
263
if 'entity_tag' in entityInfo :
263
264
person .setTag (entityInfo ['entity_tag' ])
264
265
@@ -284,11 +285,11 @@ def extractInstitution(self,entityInfo):
284
285
if 'catalog_name' in entityInfo :
285
286
institution .setCatalog (entityInfo ['catalog_name' ])
286
287
if 'introduction' in entityInfo :
287
- institution .setIntroduction (entityInfo ['introduction' ])
288
+ institution .setIntroduction (entityInfo ['introduction' ]. replace ( "'" , "''" ) )
288
289
if 'entity_detail' in entityInfo :
289
- institution .setBasicInfo (entityInfo ['entity_detail' ])
290
+ institution .setBasicInfo (entityInfo ['entity_detail' ]. replace ( "'" , "''" ) )
290
291
if 'text_file' in entityInfo :
291
- institution .setDetail (entityInfo ['text_file' ])
292
+ institution .setDetail (entityInfo ['text_file' ]. replace ( "'" , "''" ) )
292
293
if 'entity_tag' in entityInfo :
293
294
institution .setTag (entityInfo ['entity_tag' ])
294
295
@@ -335,6 +336,9 @@ def getEntityType(self,entityName,entityTag):
335
336
336
337
if not self .organizeString :
337
338
self .readOrganizedict ()
339
+ if entityName == "" :
340
+ return None
341
+
338
342
339
343
entityNT = entityName + entityTag
340
344
PTag = '人物'
@@ -363,7 +367,8 @@ def insertPerson(self,tableName,person,cur,conn):
363
367
print (last_id )
364
368
return last_id
365
369
except :
366
- pass
370
+ raise
371
+
367
372
def insertRelation (self ,tableName ,relation ,cur ,conn ):
368
373
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 ())
369
374
print (str )
0 commit comments