From da504737012e5c92c191b8ad37072f2122ec8666 Mon Sep 17 00:00:00 2001 From: Matthw Honnibal Date: Mon, 29 Jun 2020 12:17:41 +0200 Subject: [PATCH] Tweak efficiency of arc_eager.set_costs --- spacy/syntax/arc_eager.pyx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spacy/syntax/arc_eager.pyx b/spacy/syntax/arc_eager.pyx index fcc05de3f..f129ee7d1 100644 --- a/spacy/syntax/arc_eager.pyx +++ b/spacy/syntax/arc_eager.pyx @@ -729,12 +729,13 @@ cdef class ArcEager(TransitionSystem): cdef ArcEagerGold gold_ = gold gold_.update(stcls) gold_state = gold_.c - n_gold = 0 + cdef int n_gold = 0 for i in range(self.n_moves): if self.c[i].is_valid(stcls.c, self.c[i].label): is_valid[i] = True costs[i] = self.c[i].get_cost(stcls, &gold_state, self.c[i].label) - n_gold += costs[i] <= 0 + if costs[i] <= 0: + n_gold += 1 else: is_valid[i] = False costs[i] = 9000