diff --git a/spacy/ner/_state.pxd b/spacy/ner/_state.pxd index da89a9493..43b37d3bd 100644 --- a/spacy/ner/_state.pxd +++ b/spacy/ner/_state.pxd @@ -1,21 +1,5 @@ from cymem.cymem cimport Pool -from .moves cimport Move - - -cdef struct Entity: - int start - int end - int label - - -cdef struct State: - Entity curr - Entity* ents - int* tags - int i - int j - int length - +from .structs cimport State, Entity, Move cdef int begin_entity(State* s, label) except -1 diff --git a/spacy/ner/_state.pyx b/spacy/ner/_state.pyx index edffebf39..660a0642f 100644 --- a/spacy/ner/_state.pyx +++ b/spacy/ner/_state.pyx @@ -1,4 +1,4 @@ -from .moves cimport BEGIN, UNIT +from .bilou_moves cimport BEGIN, UNIT cdef int begin_entity(State* s, label) except -1: diff --git a/spacy/ner/moves.pxd b/spacy/ner/bilou_moves.pxd similarity index 83% rename from spacy/ner/moves.pxd rename to spacy/ner/bilou_moves.pxd index 1b30cfdad..20ec58291 100644 --- a/spacy/ner/moves.pxd +++ b/spacy/ner/bilou_moves.pxd @@ -3,7 +3,8 @@ from cymem.cymem cimport Pool from thinc.typedefs cimport class_t from thinc.typedefs cimport weight_t -from ._state cimport State +from .structs cimport State, Move + cpdef enum ActionType: MISSING @@ -15,13 +16,6 @@ cpdef enum ActionType: N_ACTIONS -cdef struct Move: - class_t clas - int action - int label - bint accept - - cdef int set_accept_if_oracle(Move* moves, Move* golds, int n, State* s) except 0 cdef int set_accept_if_valid(Move* moves, int n, State* s) except 0 diff --git a/spacy/ner/moves.pyx b/spacy/ner/bilou_moves.pyx similarity index 100% rename from spacy/ner/moves.pyx rename to spacy/ner/bilou_moves.pyx diff --git a/spacy/ner/greedy_parser.pxd b/spacy/ner/greedy_parser.pxd index 79972f316..0e8577161 100644 --- a/spacy/ner/greedy_parser.pxd +++ b/spacy/ner/greedy_parser.pxd @@ -6,7 +6,7 @@ from thinc.typedefs cimport * from ..tokens cimport Tokens from ..typedefs cimport * -from .moves cimport Move +from .bilou_moves cimport Move cdef class NERParser: diff --git a/spacy/ner/greedy_parser.pyx b/spacy/ner/greedy_parser.pyx index 9812eba2f..c84975c79 100644 --- a/spacy/ner/greedy_parser.pyx +++ b/spacy/ner/greedy_parser.pyx @@ -12,11 +12,11 @@ from thinc.features cimport ConjFeat from .context cimport fill_context from .context cimport N_FIELDS -from .moves cimport Move -from .moves cimport fill_moves, transition, best_accepted -from .moves cimport set_accept_if_valid, set_accept_if_oracle +from .bilou_moves cimport Move +from .bilou_moves cimport fill_moves, transition, best_accepted +from .bilou_moves cimport set_accept_if_valid, set_accept_if_oracle from ._state cimport entity_is_open -from .moves import get_n_moves +from .bilou_moves import get_n_moves from ._state cimport State from ._state cimport init_state @@ -81,7 +81,7 @@ cdef class NERParser: n_correct = 0 cdef int f = 0 while s.i < tokens.length: - fill_context(self._context, s.i, tokens) + fill_context(self._context, s, tokens) self.extractor.extract(self._feats, self._values, self._context, NULL) self.model.score(self._scores, self._feats, self._values) @@ -109,7 +109,7 @@ cdef class NERParser: cdef State* s = init_state(mem, tokens.length) cdef Move* move while s.i < tokens.length: - fill_context(self._context, s.i, tokens) + fill_context(self._context, s, tokens) self.extractor.extract(self._feats, self._values, self._context, NULL) self.model.score(self._scores, self._feats, self._values) set_accept_if_valid(self._moves, self.n_classes, s) diff --git a/spacy/ner/pystate.pxd b/spacy/ner/pystate.pxd index ea15b4fca..9293fae01 100644 --- a/spacy/ner/pystate.pxd +++ b/spacy/ner/pystate.pxd @@ -1,7 +1,6 @@ from cymem.cymem cimport Pool -from .moves cimport Move -from ._state cimport State +from .structs cimport Move, State cdef class PyState: diff --git a/spacy/ner/pystate.pyx b/spacy/ner/pystate.pyx index 606375d77..ba18c2f07 100644 --- a/spacy/ner/pystate.pyx +++ b/spacy/ner/pystate.pyx @@ -2,11 +2,11 @@ from __future__ import unicode_literals from ._state cimport init_state from ._state cimport entity_is_open -from .moves cimport fill_moves -from .moves cimport transition -from .moves cimport set_accept_if_valid, set_accept_if_oracle -from .moves import get_n_moves -from .moves import ACTION_NAMES +from .bilou_moves cimport fill_moves +from .bilou_moves cimport transition +from .bilou_moves cimport set_accept_if_valid, set_accept_if_oracle +from .bilou_moves import get_n_moves +from .bilou_moves import ACTION_NAMES cdef class PyState: