From 472f576b828f66256a560276f180421e7e4502f8 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 5 May 2016 15:01:10 +0200 Subject: [PATCH] * Deprojectivize German parses --- spacy/syntax/arc_eager.pyx | 3 +++ spacy/syntax/nonproj.pyx | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spacy/syntax/arc_eager.pyx b/spacy/syntax/arc_eager.pyx index d44183022..bb4738a30 100644 --- a/spacy/syntax/arc_eager.pyx +++ b/spacy/syntax/arc_eager.pyx @@ -18,6 +18,7 @@ from libc.string cimport memcpy from cymem.cymem cimport Pool from .stateclass cimport StateClass from ._state cimport StateC, is_space_token +from .nonproj import PseudoProjectivity DEF NON_MONOTONIC = True @@ -385,6 +386,8 @@ cdef class ArcEager(TransitionSystem): def finalize_doc(self, doc): doc.is_parsed = True + if doc.vocab.lang == 'de': + PseudoProjectivity.projectivize(doc) cdef int set_valid(self, int* output, const StateC* st) nogil: cdef bint[N_MOVES] is_valid diff --git a/spacy/syntax/nonproj.pyx b/spacy/syntax/nonproj.pyx index 9339efb39..28e6dc9e7 100644 --- a/spacy/syntax/nonproj.pyx +++ b/spacy/syntax/nonproj.pyx @@ -114,7 +114,7 @@ class PseudoProjectivity: @classmethod - def deprojectivize(cls, Doc tokens): + def deprojectivize(cls, tokens): # reattach arcs with decorated labels (following HEAD scheme) # for each decorated arc X||Y, search top-down, left-to-right, # breadth-first until hitting a Y then make this the new head