def extract(story_id): story = get_story(story_id) try: for card in extract_entities(story.get('text')): if card['card'] == 'entity': save_card(story, card, aliases=True) except Exception, e: log.exception(e)
def cards_create(story_id): story = get_story(story_id) card = dict(request.json) card.pop("_id", None) card.pop("evidences", None) card = save_card(story, card) return cards_get(story_id, unicode(card["_id"]))
def cards_create(story_id): story = get_story(story_id) card = dict(request.json) card.pop('_id', None) card.pop('evidences', None) card = save_card(story, card) return cards_get(story_id, unicode(card['_id']))
def cards_update(story_id, card_id): story = get_story(story_id) card = obj_or_404(get_card(story, card_id)) data = dict(request.json) data.pop("evidences", None) data["_id"] = card["_id"] card = save_card(story, data) return cards_get(story_id, card_id)
def cards_update(story_id, card_id): story = get_story(story_id) card = obj_or_404(get_card(story, card_id)) data = dict(request.json) data.pop('evidences', None) data['_id'] = card['_id'] card = save_card(story, data) return cards_get(story_id, card_id)
'Wikipedia': Wikipedia } def lookup(story, card, spider_name): entity_type = card.get('type') spider_status = card.get('spider_status', {}) cls = SPIDERS.get(spider_name) if spider_status.get(spider_name) == 'done': return try: spider = cls() if entity_type == "Person": card = spider.search_person(story, card) elif entity_type == "Company": card = spider.search_company(story, card) elif entity_type == "Organization": card = spider.search_organization(story, card) else: card = spider.search_generic(story, card) except Exception, e: log.exception(e) ncard = get_card(story, unicode(card['_id'])) spider_status = ncard.get('spider_status', {}) spider_status[spider_name] = 'done' card['spider_status'] = spider_status save_card(story, card, lookup=False)