Beispiel #1
0
def dump_recon(recon):
    session = Session()
    Match.tally(session)
    session.commit()
    for match in Match.all(session):
        if match.judgement is not None:
            obj = Recon(match.subject, match.candidate, match.judgement)
            recon.write(obj.to_json())
            recon.write('\n')
            recon.flush()
Beispiel #2
0
def load_entities(entities):
    session = Session()
    try:
        while True:
            entity = read_entity(entities)
            if entity is None:
                break
            Entity.save(session, entities.name, entity)
    except BrokenPipeError:
        pass
    session.commit()
Beispiel #3
0
def load_votes(votes):
    session = Session()
    try:
        while True:
            data = read_entity(votes)
            if data is None:
                break
            Vote.save(session,
                      data.get('match_id'),
                      data.get('user'),
                      data.get('judgement'))
    except BrokenPipeError:
        pass
    Match.tally(session)
    session.commit()
Beispiel #4
0
def load_results(results):
    session = Session()
    try:
        while True:
            result = read_result(results)
            if result is None:
                break
            if result.subject is None or result.candidate is None:
                continue
            se = Entity.save(session, result.enricher.name, result.subject)
            ce = Entity.save(session, result.enricher.name, result.candidate)
            priority = max((se.priority, ce.priority))
            Match.save(session, result.subject, result.candidate,
                       score=result.score, priority=priority)
            session.flush()
    except BrokenPipeError:
        pass
    session.commit()
Beispiel #5
0
def before():
    request.session = Session()
    request.user = '******'
    request.user = request.headers.get("X-Auth-Email") or request.user
Beispiel #6
0
def load_recon(recon):
    session = Session()
    for recon in Recon.from_file(recon):
        Match.save(session, recon.subject, recon.canonical,
                   judgement=recon.judgement)
    session.commit()
Beispiel #7
0
def dedupe(threshold):
    session = Session()
    Entity.dedupe(session, threshold=threshold)
    session.commit()
Beispiel #8
0
def dump_votes(votes):
    session = Session()
    for vote in Vote.all(session):
        votes.write(vote.to_json())
        votes.write('\n')
        votes.flush()