Revert NER action loading change, for model compatibility

This commit is contained in:
Matthew Honnibal 2017-09-17 05:46:03 -05:00
parent 43210abacc
commit c003c561c3

View File

@ -219,28 +219,28 @@ cdef class BiluoPushDown(TransitionSystem):
raise Exception(move) raise Exception(move)
return t return t
def add_action(self, int action, label_name): #def add_action(self, int action, label_name):
cdef attr_t label_id # cdef attr_t label_id
if not isinstance(label_name, (int, long)): # if not isinstance(label_name, (int, long)):
label_id = self.strings.add(label_name) # label_id = self.strings.add(label_name)
else: # else:
label_id = label_name # label_id = label_name
if action == OUT and label_id != 0: # if action == OUT and label_id != 0:
return # return
if action == MISSING or action == ISNT: # if action == MISSING or action == ISNT:
return # return
# Check we're not creating a move we already have, so that this is # # Check we're not creating a move we already have, so that this is
# idempotent # # idempotent
for trans in self.c[:self.n_moves]: # for trans in self.c[:self.n_moves]:
if trans.move == action and trans.label == label_id: # if trans.move == action and trans.label == label_id:
return 0 # return 0
if self.n_moves >= self._size: # if self.n_moves >= self._size:
self._size *= 2 # self._size *= 2
self.c = <Transition*>self.mem.realloc(self.c, self._size * sizeof(self.c[0])) # self.c = <Transition*>self.mem.realloc(self.c, self._size * sizeof(self.c[0]))
self.c[self.n_moves] = self.init_transition(self.n_moves, action, label_id) # self.c[self.n_moves] = self.init_transition(self.n_moves, action, label_id)
assert self.c[self.n_moves].label == label_id # assert self.c[self.n_moves].label == label_id
self.n_moves += 1 # self.n_moves += 1
return 1 # return 1