Exemplo n.º 1
0
 def processor(loaded_ids, session, columns):
     # move entity_id over into id
     row = [columns[3], 'unk']
     if row[0] in loaded_ids:
         return
     loaded_ids.add(row[0])
     values = map_column_values(row, mappings, Media)
     session.add(Media(**values))
Exemplo n.º 2
0
 def processor(loaded_ids, session, columns):
     if columns[1] is None:
         print('Null topic_id for %s' % columns[0])
         columns[1] = 'NIL'
     if columns[0] in loaded_ids:
         return
     loaded_ids.add(columns[0])
     values = map_column_values(
         columns, ['id', 'topic_id', 'category', 'handle', 'description'],
         KB)
     session.add(KB(**values))
Exemplo n.º 3
0
 def processor(session, columns):
     values = map_column_values(columns, ['username', 'password'], User)
     values['password'] = User.generate_hash(values['password'])
     if update:
         user = session.query(User).filter(
             User.username == values['username']).first()
         if user is not None:
             user.password = values['password']
         session.merge(user)
         return
     session.add(User(**values))
Exemplo n.º 4
0
 def processor(loaded_ids, session, columns):
     # move entity_id over into id
     columns[1] = columns[2]
     if columns[2] in loaded_ids:
         return
     loaded_ids.add(columns[2])
     if columns[7] is None or len(columns[7]) == 0:
         columns[7] = columns[6]
     if columns[3] not in loaded_p:
         print('%s %s' % (columns[1], columns[3]))
     values = map_column_values(columns, mappings, Entity)
     session.add(Entity(**values))
Exemplo n.º 5
0
 def processor(loaded_ids, session, columns):
     # move entity_id over into id
     if columns[7] is None or len(columns[7]) == 0:
         columns[7] = columns[6]
     row = [
         columns[-1], 'NIL', 'entity', columns[7][:128], columns[7][:512]
     ]
     if row[0] in loaded_ids:
         return
     loaded_ids.add(row[0])
     values = map_column_values(row, mappings, KB)
     session.add(KB(**values))
Exemplo n.º 6
0
 def processor(session, columns):
     values = map_column_values(
         columns, ['id', 'topic_name', 'text_query', 'hypothesis'],
         Hypothesis)
     session.add(Hypothesis(**values))
Exemplo n.º 7
0
 def processor(session, columns):
     values = map_column_values(columns, mappings, ParentChildDetail)
     values['id'] = uuid.uuid4().urn
     session.add(ParentChildDetail(**values))
Exemplo n.º 8
0
 def processor(session, columns):
     values = map_column_values(columns, ['id', 'media_type'], Media)
     session.add(Media(**values))
Exemplo n.º 9
0
 def processor(session, columns):
     values = map_column_values(columns, mappings, RelativeMention)
     session.add(RelativeMention(**values))
Exemplo n.º 10
0
 def processor(session, columns):
     values = map_column_values(columns, mappings, EntityMention)
     session.add(EntityMention(**values))
Exemplo n.º 11
0
 def processor(session, columns):
     values = map_column_values(columns, Segment.columns, EntityMention)
     session.add(Segment(**values))
Exemplo n.º 12
0
 def processor(session, columns):
     values = map_column_values(columns, CanonicalMention.columns,
                                EntityMention)
     session.add(CanonicalMention(**values))