mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 02:36:32 +03:00
* Deprojectivize German parses
This commit is contained in:
parent
9bbd6cf031
commit
472f576b82
|
@ -18,6 +18,7 @@ from libc.string cimport memcpy
|
||||||
from cymem.cymem cimport Pool
|
from cymem.cymem cimport Pool
|
||||||
from .stateclass cimport StateClass
|
from .stateclass cimport StateClass
|
||||||
from ._state cimport StateC, is_space_token
|
from ._state cimport StateC, is_space_token
|
||||||
|
from .nonproj import PseudoProjectivity
|
||||||
|
|
||||||
|
|
||||||
DEF NON_MONOTONIC = True
|
DEF NON_MONOTONIC = True
|
||||||
|
@ -385,6 +386,8 @@ cdef class ArcEager(TransitionSystem):
|
||||||
|
|
||||||
def finalize_doc(self, doc):
|
def finalize_doc(self, doc):
|
||||||
doc.is_parsed = True
|
doc.is_parsed = True
|
||||||
|
if doc.vocab.lang == 'de':
|
||||||
|
PseudoProjectivity.projectivize(doc)
|
||||||
|
|
||||||
cdef int set_valid(self, int* output, const StateC* st) nogil:
|
cdef int set_valid(self, int* output, const StateC* st) nogil:
|
||||||
cdef bint[N_MOVES] is_valid
|
cdef bint[N_MOVES] is_valid
|
||||||
|
|
|
@ -114,7 +114,7 @@ class PseudoProjectivity:
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def deprojectivize(cls, Doc tokens):
|
def deprojectivize(cls, tokens):
|
||||||
# reattach arcs with decorated labels (following HEAD scheme)
|
# reattach arcs with decorated labels (following HEAD scheme)
|
||||||
# for each decorated arc X||Y, search top-down, left-to-right,
|
# for each decorated arc X||Y, search top-down, left-to-right,
|
||||||
# breadth-first until hitting a Y then make this the new head
|
# breadth-first until hitting a Y then make this the new head
|
||||||
|
|
Loading…
Reference in New Issue
Block a user