From 38a6afa484fbce4354c2d4bc51d1c3c06e1585a8 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 15 Jun 2015 02:50:00 +0200 Subject: [PATCH] * Make possibly dubious correction to the unshift oracle --- spacy/syntax/arc_eager.pyx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spacy/syntax/arc_eager.pyx b/spacy/syntax/arc_eager.pyx index 7ac11fd46..ba20f813c 100644 --- a/spacy/syntax/arc_eager.pyx +++ b/spacy/syntax/arc_eager.pyx @@ -177,9 +177,15 @@ cdef class LeftArc: @staticmethod cdef inline int move_cost(StateClass s, const GoldParseC* gold) nogil: + cdef int cost = 0 if arc_is_gold(gold, s.B(0), s.S(0)): return 0 else: + # Account for deps we might lose between S0 and stack + if not s.has_head(s.S(0)): + for i in range(1, s.stack_depth()): + cost += gold.heads[s.S(i)] == s.S(0) + cost += gold.heads[s.S(0)] == s.S(i) return pop_cost(s, gold, s.S(0)) + arc_cost(s, gold, s.B(0), s.S(0)) @staticmethod