mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-10 08:12:24 +03:00
* Comment out constituency parsing stuff, so that code compiles
This commit is contained in:
parent
8ee7c541f1
commit
f2ee9c4feb
|
@ -137,12 +137,12 @@ cdef int count_right_kids(const TokenC* head) nogil:
|
||||||
cdef State* new_state(Pool mem, const TokenC* sent, const int sent_len) except NULL:
|
cdef State* new_state(Pool mem, const TokenC* sent, const int sent_len) except NULL:
|
||||||
cdef int padded_len = sent_len + PADDING + PADDING
|
cdef int padded_len = sent_len + PADDING + PADDING
|
||||||
cdef State* s = <State*>mem.alloc(1, sizeof(State))
|
cdef State* s = <State*>mem.alloc(1, sizeof(State))
|
||||||
s.ctnt = <Constituent*>mem.alloc(padded_len, sizeof(Constituent))
|
#s.ctnt = <Constituent*>mem.alloc(padded_len, sizeof(Constituent))
|
||||||
s.ent = <Entity*>mem.alloc(padded_len, sizeof(Entity))
|
s.ent = <Entity*>mem.alloc(padded_len, sizeof(Entity))
|
||||||
s.stack = <int*>mem.alloc(padded_len, sizeof(int))
|
s.stack = <int*>mem.alloc(padded_len, sizeof(int))
|
||||||
for i in range(PADDING):
|
for i in range(PADDING):
|
||||||
s.stack[i] = -1
|
s.stack[i] = -1
|
||||||
s.ctnt += (PADDING -1)
|
#s.ctnt += (PADDING -1)
|
||||||
s.stack += (PADDING - 1)
|
s.stack += (PADDING - 1)
|
||||||
s.ent += (PADDING - 1)
|
s.ent += (PADDING - 1)
|
||||||
assert s.stack[0] == -1
|
assert s.stack[0] == -1
|
||||||
|
|
|
@ -183,37 +183,39 @@ cdef int _do_break(const Transition* self, State* state) except -1:
|
||||||
|
|
||||||
|
|
||||||
cdef int _do_constituent(const Transition* self, State* state) except -1:
|
cdef int _do_constituent(const Transition* self, State* state) except -1:
|
||||||
cdef Constituent* bracket = new_bracket(state.ctnts)
|
return False
|
||||||
|
#cdef Constituent* bracket = new_bracket(state.ctnts)
|
||||||
|
|
||||||
bracket.parent = NULL
|
#bracket.parent = NULL
|
||||||
bracket.label = self.label
|
#bracket.label = self.label
|
||||||
bracket.head = get_s0(state)
|
#bracket.head = get_s0(state)
|
||||||
bracket.length = 0
|
#bracket.length = 0
|
||||||
|
|
||||||
attach(bracket, state.ctnts.stack)
|
#attach(bracket, state.ctnts.stack)
|
||||||
# Attach rightward children. They're in the brackets array somewhere
|
# Attach rightward children. They're in the brackets array somewhere
|
||||||
# between here and B0.
|
# between here and B0.
|
||||||
cdef Constituent* node
|
#cdef Constituent* node
|
||||||
cdef const TokenC* node_gov
|
#cdef const TokenC* node_gov
|
||||||
for i in range(1, bracket - state.ctnts.stack):
|
#for i in range(1, bracket - state.ctnts.stack):
|
||||||
node = bracket - i
|
# node = bracket - i
|
||||||
node_gov = node.head + node.head.head
|
# node_gov = node.head + node.head.head
|
||||||
if node_gov == bracket.head:
|
# if node_gov == bracket.head:
|
||||||
attach(bracket, node)
|
# attach(bracket, node)
|
||||||
|
|
||||||
|
|
||||||
cdef int _do_adjust(const Transition* self, State* state) except -1:
|
cdef int _do_adjust(const Transition* self, State* state) except -1:
|
||||||
cdef Constituent* b0 = state.ctnts.stack[0]
|
return False
|
||||||
cdef Constituent* b1 = state.ctnts.stack[1]
|
#cdef Constituent* b0 = state.ctnts.stack[0]
|
||||||
|
#cdef Constituent* b1 = state.ctnts.stack[1]
|
||||||
|
|
||||||
assert (b1.head + b1.head.head) == b0.head
|
#assert (b1.head + b1.head.head) == b0.head
|
||||||
assert b0.head < b1.head
|
#assert b0.head < b1.head
|
||||||
assert b0 < b1
|
#assert b0 < b1
|
||||||
|
|
||||||
attach(b0, b1)
|
#attach(b0, b1)
|
||||||
# Pop B1 from stack, but keep B0 on top
|
## Pop B1 from stack, but keep B0 on top
|
||||||
state.ctnts.stack -= 1
|
#state.ctnts.stack -= 1
|
||||||
state.ctnts.stack[0] = b0
|
#state.ctnts.stack[0] = b0
|
||||||
|
|
||||||
|
|
||||||
do_funcs[SHIFT] = _do_shift
|
do_funcs[SHIFT] = _do_shift
|
||||||
|
@ -379,14 +381,14 @@ cdef inline bint _can_right(const State* s) nogil:
|
||||||
|
|
||||||
cdef inline bint _can_left(const State* s) nogil:
|
cdef inline bint _can_left(const State* s) nogil:
|
||||||
if NON_MONOTONIC:
|
if NON_MONOTONIC:
|
||||||
return s.stack_len >= 1 and not missing_brackets(s)
|
return s.stack_len >= 1 #and not missing_brackets(s)
|
||||||
else:
|
else:
|
||||||
return s.stack_len >= 1 and not has_head(get_s0(s))
|
return s.stack_len >= 1 and not has_head(get_s0(s))
|
||||||
|
|
||||||
|
|
||||||
cdef inline bint _can_reduce(const State* s) nogil:
|
cdef inline bint _can_reduce(const State* s) nogil:
|
||||||
if NON_MONOTONIC:
|
if NON_MONOTONIC:
|
||||||
return s.stack_len >= 2 and not missing_brackets(s)
|
return s.stack_len >= 2 #and not missing_brackets(s)
|
||||||
else:
|
else:
|
||||||
return s.stack_len >= 2 and has_head(get_s0(s))
|
return s.stack_len >= 2 and has_head(get_s0(s))
|
||||||
|
|
||||||
|
@ -413,26 +415,28 @@ cdef inline bint _can_break(const State* s) nogil:
|
||||||
cdef inline bint _can_constituent(const State* s) nogil:
|
cdef inline bint _can_constituent(const State* s) nogil:
|
||||||
if s.stack_len < 1:
|
if s.stack_len < 1:
|
||||||
return False
|
return False
|
||||||
else:
|
return False
|
||||||
# If all stack elements are popped, can't constituent
|
#else:
|
||||||
for i in range(s.ctnts.stack_len):
|
# # If all stack elements are popped, can't constituent
|
||||||
if not s.ctnts.is_popped[-i]:
|
# for i in range(s.ctnts.stack_len):
|
||||||
return True
|
# if not s.ctnts.is_popped[-i]:
|
||||||
else:
|
# return True
|
||||||
return False
|
# else:
|
||||||
|
# return False
|
||||||
|
|
||||||
|
|
||||||
cdef inline bint _can_adjust(const State* s) nogil:
|
cdef inline bint _can_adjust(const State* s) nogil:
|
||||||
if s.ctnts.stack_len < 2:
|
return False
|
||||||
return False
|
#if s.ctnts.stack_len < 2:
|
||||||
|
# return False
|
||||||
|
|
||||||
cdef const Constituent* b1 = s.ctnts.stack[-1]
|
#cdef const Constituent* b1 = s.ctnts.stack[-1]
|
||||||
cdef const Constituent* b0 = s.ctnts.stack[0]
|
#cdef const Constituent* b0 = s.ctnts.stack[0]
|
||||||
|
|
||||||
if (b1.head + b1.head.head) != b0.head:
|
#if (b1.head + b1.head.head) != b0.head:
|
||||||
return False
|
# return False
|
||||||
elif b0.head >= b1.head:
|
#elif b0.head >= b1.head:
|
||||||
return False
|
# return False
|
||||||
elif b0 >= b1:
|
#elif b0 >= b1:
|
||||||
return False
|
# return False
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue
Block a user