Ejemplo n.º 1
0
def apply_rules(transformer):
    for rule in transformer.rules:
        log.info(u".. {}".format(rule.name))
        rule.apply(transformer)
        if rule.show:
            g = visualise_triples(transformer.get_triples(), grey_rel)
            yield (rule.name, "After rule: "+rule.name, g.getHTMLObject())
Ejemplo n.º 2
0
def check_gold(goldfile, sid, transformer):
    gold, gold_relations = get_gold(goldfile)
    if sid not in gold: return
    gold = gold[sid]
    log.info("Comparing with gold standard")
    triples = transformer.get_triples()
    found = set(Triple(int(t.subject.position), t.predicate, int(t.object.position))
        for t in triples if t.predicate in gold_relations)
    gold = set(do_gold_reality(found, gold))
    
    g = visualise_triples(triples, partial(gold_colors, gold, gold_relations))
    for t in gold - found: # add false negatives
        g.addEdge("node_%i" % t.subject, "node_%i" % t.object, label=t.predicate, color="orange")
    yield"Gold", "Gold Standard", g.getHTMLObject()
Ejemplo n.º 3
0
def get_graph(transformer):
    g = visualise_triples(transformer.get_triples())
    print(g.getDot())
    return g.getHTMLObject()