mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 18:56:36 +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 int padded_len = sent_len + PADDING + PADDING
|
||||
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.stack = <int*>mem.alloc(padded_len, sizeof(int))
|
||||
for i in range(PADDING):
|
||||
s.stack[i] = -1
|
||||
s.ctnt += (PADDING -1)
|
||||
#s.ctnt += (PADDING -1)
|
||||
s.stack += (PADDING - 1)
|
||||
s.ent += (PADDING - 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 Constituent* bracket = new_bracket(state.ctnts)
|
||||
return False
|
||||
#cdef Constituent* bracket = new_bracket(state.ctnts)
|
||||
|
||||
bracket.parent = NULL
|
||||
bracket.label = self.label
|
||||
bracket.head = get_s0(state)
|
||||
bracket.length = 0
|
||||
#bracket.parent = NULL
|
||||
#bracket.label = self.label
|
||||
#bracket.head = get_s0(state)
|
||||
#bracket.length = 0
|
||||
|
||||
attach(bracket, state.ctnts.stack)
|
||||
#attach(bracket, state.ctnts.stack)
|
||||
# Attach rightward children. They're in the brackets array somewhere
|
||||
# between here and B0.
|
||||
cdef Constituent* node
|
||||
cdef const TokenC* node_gov
|
||||
for i in range(1, bracket - state.ctnts.stack):
|
||||
node = bracket - i
|
||||
node_gov = node.head + node.head.head
|
||||
if node_gov == bracket.head:
|
||||
attach(bracket, node)
|
||||
#cdef Constituent* node
|
||||
#cdef const TokenC* node_gov
|
||||
#for i in range(1, bracket - state.ctnts.stack):
|
||||
# node = bracket - i
|
||||
# node_gov = node.head + node.head.head
|
||||
# if node_gov == bracket.head:
|
||||
# attach(bracket, node)
|
||||
|
||||
|
||||
cdef int _do_adjust(const Transition* self, State* state) except -1:
|
||||
cdef Constituent* b0 = state.ctnts.stack[0]
|
||||
cdef Constituent* b1 = state.ctnts.stack[1]
|
||||
return False
|
||||
#cdef Constituent* b0 = state.ctnts.stack[0]
|
||||
#cdef Constituent* b1 = state.ctnts.stack[1]
|
||||
|
||||
assert (b1.head + b1.head.head) == b0.head
|
||||
assert b0.head < b1.head
|
||||
assert b0 < b1
|
||||
#assert (b1.head + b1.head.head) == b0.head
|
||||
#assert b0.head < b1.head
|
||||
#assert b0 < b1
|
||||
|
||||
attach(b0, b1)
|
||||
# Pop B1 from stack, but keep B0 on top
|
||||
state.ctnts.stack -= 1
|
||||
state.ctnts.stack[0] = b0
|
||||
#attach(b0, b1)
|
||||
## Pop B1 from stack, but keep B0 on top
|
||||
#state.ctnts.stack -= 1
|
||||
#state.ctnts.stack[0] = b0
|
||||
|
||||
|
||||
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:
|
||||
if NON_MONOTONIC:
|
||||
return s.stack_len >= 1 and not missing_brackets(s)
|
||||
return s.stack_len >= 1 #and not missing_brackets(s)
|
||||
else:
|
||||
return s.stack_len >= 1 and not has_head(get_s0(s))
|
||||
|
||||
|
||||
cdef inline bint _can_reduce(const State* s) nogil:
|
||||
if NON_MONOTONIC:
|
||||
return s.stack_len >= 2 and not missing_brackets(s)
|
||||
return s.stack_len >= 2 #and not missing_brackets(s)
|
||||
else:
|
||||
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:
|
||||
if s.stack_len < 1:
|
||||
return False
|
||||
else:
|
||||
# If all stack elements are popped, can't constituent
|
||||
for i in range(s.ctnts.stack_len):
|
||||
if not s.ctnts.is_popped[-i]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
#else:
|
||||
# # If all stack elements are popped, can't constituent
|
||||
# for i in range(s.ctnts.stack_len):
|
||||
# if not s.ctnts.is_popped[-i]:
|
||||
# return True
|
||||
# else:
|
||||
# return False
|
||||
|
||||
|
||||
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* b0 = s.ctnts.stack[0]
|
||||
#cdef const Constituent* b1 = s.ctnts.stack[-1]
|
||||
#cdef const Constituent* b0 = s.ctnts.stack[0]
|
||||
|
||||
if (b1.head + b1.head.head) != b0.head:
|
||||
return False
|
||||
elif b0.head >= b1.head:
|
||||
return False
|
||||
elif b0 >= b1:
|
||||
return False
|
||||
#if (b1.head + b1.head.head) != b0.head:
|
||||
# return False
|
||||
#elif b0.head >= b1.head:
|
||||
# return False
|
||||
#elif b0 >= b1:
|
||||
# return False
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue
Block a user