Ejemplo n.º 1
0
    def __call__(self, xs, ts, ys):
        counts = DFCounts()

        for x, t, y in zip(xs, ts, ys):
            generator_seg = self.generate_lines_seg(x, t, y)
            generator_tag = self.generate_lines(x, t, y)
            counts.l1 = conlleval.evaluate(generator_seg, counts=counts.l1)
            counts.l2 = conlleval.evaluate(generator_tag, counts=counts.l2)

        return counts
Ejemplo n.º 2
0
    def __call__(self, xs, ts, ys):
        counts = FCounts()
        for x, t, y in zip(xs, ts, ys):
            generator = self.generate_lines(x, t, y)
            counts = conlleval.evaluate(generator, counts=counts)

        return counts
Ejemplo n.º 3
0
def evaluate(model, data, batch_size, log):
    was_training = model.training
    model.eval()
    pred = []
    gold = []
    with torch.no_grad():
        for pa in data_generator(data, batch_size):
            x = pa[0]
            y = pa[1]
            slot = pa[2]
            _x, _y, p = model(x, y, slot, 'test')
            gold += _y
            pred += p

    if was_training:
        model.train()

    _gold = []
    _pred = []
    for i in gold:
        for j in i:
            _gold.append(j)
    for i in pred:
        for j in i:
            _pred.append(j)
    return conlleval.evaluate(_gold, _pred, log, verbose=True)
Ejemplo n.º 4
0
    def __call__(self, xs, t1s, t2s, y1s, y2s):
        counts = FACounts()
        if not t2s or not y2s:
            t2s = [None] * len(xs)
            y2s = [None] * len(xs)

        for x, t1, t2, y1, y2 in zip(xs, t1s, t2s, y1s, y2s):
            generator_seg = self.generate_lines_seg(x, t1, y1)
            counts.l1 = conlleval.evaluate(generator_seg, counts=counts.l1)

            if t2 is not None:
                for ti, yi in zip(t2, y2):
                    counts.l2.total += 1
                    if ti == yi:
                        counts.l2.correct += 1

        return counts