Esempio n. 1
0
def extract_entities(parent):
    from storyweb.queue import index
    for offset, child in extract_multi(parent):
        log.info("Extraced: %r in %r", child, parent)
        data = {
            'offset': offset,
            'child': child
        }
        link = Link.find(parent, child)
        if link is None:
            link = Link()
        else:
            data['status'] = link.status
        link.save(data, parent, child.author)
    
    index.delay(parent.id)
Esempio n. 2
0
def extract(card_id):
    parent = Card.by_id(card_id)
    if parent.category != Card.ARTICLE:
        log.info('Not extracting entities from "%s"...', parent.title)
        return
    log.info('Extracting entities from "%s"...', parent.title)
    try:
        for offset, child in extract_entities(parent.text):
            data = {
                'offset': offset,
                'child': child
            }
            link = Link.find(parent, child)
            if link is None:
                link = Link()
            else:
                data['status'] = link.status
            link.save(data, parent, child.author)
        index.delay(card_id)
        db.session.commit()
    except Exception, e:
        log.exception(e)