mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-27 09:44:36 +03:00
* Remove old _state imports
This commit is contained in:
parent
e9aaecc619
commit
e2f9a80713
2
setup.py
2
setup.py
|
@ -152,7 +152,7 @@ MOD_NAMES = ['spacy.parts_of_speech', 'spacy.strings',
|
||||||
'spacy.morphology',
|
'spacy.morphology',
|
||||||
'spacy.syntax.stateclass',
|
'spacy.syntax.stateclass',
|
||||||
'spacy._ml', 'spacy.tokenizer', 'spacy.en.attrs',
|
'spacy._ml', 'spacy.tokenizer', 'spacy.en.attrs',
|
||||||
'spacy.en.pos', 'spacy.syntax.parser', 'spacy.syntax._state',
|
'spacy.en.pos', 'spacy.syntax.parser',
|
||||||
'spacy.syntax.transition_system',
|
'spacy.syntax.transition_system',
|
||||||
'spacy.syntax.arc_eager', 'spacy.syntax._parse_features',
|
'spacy.syntax.arc_eager', 'spacy.syntax._parse_features',
|
||||||
'spacy.gold', 'spacy.orth',
|
'spacy.gold', 'spacy.orth',
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from thinc.typedefs cimport atom_t
|
from thinc.typedefs cimport atom_t
|
||||||
|
|
||||||
from ._state cimport State
|
|
||||||
from .stateclass cimport StateClass
|
from .stateclass cimport StateClass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,6 @@ from libc.string cimport memset
|
||||||
from itertools import combinations
|
from itertools import combinations
|
||||||
|
|
||||||
from ..tokens cimport TokenC
|
from ..tokens cimport TokenC
|
||||||
from ._state cimport State
|
|
||||||
from ._state cimport get_s2, get_s1, get_s0, get_n0, get_n1, get_n2
|
|
||||||
from ._state cimport get_p2, get_p1
|
|
||||||
from ._state cimport get_e0, get_e1
|
|
||||||
from ._state cimport has_head, get_left, get_right
|
|
||||||
from ._state cimport count_left_kids, count_right_kids
|
|
||||||
|
|
||||||
|
|
||||||
from .stateclass cimport StateClass
|
from .stateclass cimport StateClass
|
||||||
|
|
||||||
|
@ -58,7 +51,7 @@ cdef inline void fill_token(atom_t* context, const TokenC* token) nogil:
|
||||||
# the source that are set to 1.
|
# the source that are set to 1.
|
||||||
context[4] = token.lex.cluster & 15
|
context[4] = token.lex.cluster & 15
|
||||||
context[5] = token.lex.cluster & 63
|
context[5] = token.lex.cluster & 63
|
||||||
context[6] = token.dep if has_head(token) else 0
|
context[6] = token.dep if token.head != 0 else 0
|
||||||
context[7] = token.lex.prefix
|
context[7] = token.lex.prefix
|
||||||
context[8] = token.lex.suffix
|
context[8] = token.lex.suffix
|
||||||
context[9] = token.lex.shape
|
context[9] = token.lex.shape
|
||||||
|
|
|
@ -2,8 +2,6 @@ from cymem.cymem cimport Pool
|
||||||
|
|
||||||
from thinc.typedefs cimport weight_t
|
from thinc.typedefs cimport weight_t
|
||||||
|
|
||||||
|
|
||||||
from ._state cimport State
|
|
||||||
from .stateclass cimport StateClass
|
from .stateclass cimport StateClass
|
||||||
|
|
||||||
from .transition_system cimport TransitionSystem, Transition
|
from .transition_system cimport TransitionSystem, Transition
|
||||||
|
|
|
@ -4,13 +4,6 @@ from __future__ import unicode_literals
|
||||||
import ctypes
|
import ctypes
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from ._state cimport State
|
|
||||||
from ._state cimport has_head, get_idx, get_s0, get_n0, get_left, get_right
|
|
||||||
from ._state cimport is_final, at_eol, pop_stack, push_stack, add_dep
|
|
||||||
from ._state cimport head_in_buffer, children_in_buffer
|
|
||||||
from ._state cimport head_in_stack, children_in_stack
|
|
||||||
from ._state cimport count_left_kids
|
|
||||||
|
|
||||||
from ..structs cimport TokenC
|
from ..structs cimport TokenC
|
||||||
|
|
||||||
from .transition_system cimport do_func_t, get_cost_func_t
|
from .transition_system cimport do_func_t, get_cost_func_t
|
||||||
|
|
|
@ -36,7 +36,7 @@ MOVE_NAMES[OUT] = 'O'
|
||||||
cdef do_func_t[N_MOVES] do_funcs
|
cdef do_func_t[N_MOVES] do_funcs
|
||||||
|
|
||||||
|
|
||||||
cdef bint _entity_is_sunk(StateClass st, Transition* golds) except -1:
|
cdef bint _entity_is_sunk(StateClass st, Transition* golds) nogil:
|
||||||
if not st.entity_is_open():
|
if not st.entity_is_open():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -154,32 +154,32 @@ cdef class BiluoPushDown(TransitionSystem):
|
||||||
|
|
||||||
cdef class Missing:
|
cdef class Missing:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef bint is_valid(StateClass st, int label) except -1:
|
cdef bint is_valid(StateClass st, int label) nogil:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int transition(StateClass s, int label) except -1:
|
cdef int transition(StateClass s, int label) nogil:
|
||||||
raise NotImplementedError
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int cost(StateClass s, const GoldParseC* gold, int label) except -1:
|
cdef int cost(StateClass s, const GoldParseC* gold, int label) nogil:
|
||||||
return 9000
|
return 9000
|
||||||
|
|
||||||
|
|
||||||
cdef class Begin:
|
cdef class Begin:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef bint is_valid(StateClass st, int label) except -1:
|
cdef bint is_valid(StateClass st, int label) nogil:
|
||||||
return label != 0 and not st.entity_is_open()
|
return label != 0 and not st.entity_is_open()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int transition(StateClass st, int label) except -1:
|
cdef int transition(StateClass st, int label) nogil:
|
||||||
st.open_ent(label)
|
st.open_ent(label)
|
||||||
st.set_ent_tag(st.B(0), 3, label)
|
st.set_ent_tag(st.B(0), 3, label)
|
||||||
st.push()
|
st.push()
|
||||||
st.pop()
|
st.pop()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int cost(StateClass s, const GoldParseC* gold, int label) except -1:
|
cdef int cost(StateClass s, const GoldParseC* gold, int label) nogil:
|
||||||
cdef int g_act = gold.ner[s.B(0)].move
|
cdef int g_act = gold.ner[s.B(0)].move
|
||||||
cdef int g_tag = gold.ner[s.B(0)].label
|
cdef int g_tag = gold.ner[s.B(0)].label
|
||||||
|
|
||||||
|
@ -198,17 +198,17 @@ cdef class Begin:
|
||||||
|
|
||||||
cdef class In:
|
cdef class In:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef bint is_valid(StateClass st, int label) except -1:
|
cdef bint is_valid(StateClass st, int label) nogil:
|
||||||
return st.entity_is_open() and label != 0 and st.E_(0).ent_type == label
|
return st.entity_is_open() and label != 0 and st.E_(0).ent_type == label
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int transition(StateClass st, int label) except -1:
|
cdef int transition(StateClass st, int label) nogil:
|
||||||
st.set_ent_tag(st.B(0), 1, label)
|
st.set_ent_tag(st.B(0), 1, label)
|
||||||
st.push()
|
st.push()
|
||||||
st.pop()
|
st.pop()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int cost(StateClass s, const GoldParseC* gold, int label) except -1:
|
cdef int cost(StateClass s, const GoldParseC* gold, int label) nogil:
|
||||||
move = IN
|
move = IN
|
||||||
cdef int next_act = gold.ner[s.B(1)].move if s.B(0) < s.length else OUT
|
cdef int next_act = gold.ner[s.B(1)].move if s.B(0) < s.length else OUT
|
||||||
cdef int g_act = gold.ner[s.B(0)].move
|
cdef int g_act = gold.ner[s.B(0)].move
|
||||||
|
@ -238,17 +238,17 @@ cdef class In:
|
||||||
|
|
||||||
cdef class Last:
|
cdef class Last:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef bint is_valid(StateClass st, int label) except -1:
|
cdef bint is_valid(StateClass st, int label) nogil:
|
||||||
return st.entity_is_open() and label != 0 and st.E_(0).ent_type == label
|
return st.entity_is_open() and label != 0 and st.E_(0).ent_type == label
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int transition(StateClass st, int label) except -1:
|
cdef int transition(StateClass st, int label) nogil:
|
||||||
st.close_ent()
|
st.close_ent()
|
||||||
st.push()
|
st.push()
|
||||||
st.pop()
|
st.pop()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int cost(StateClass s, const GoldParseC* gold, int label) except -1:
|
cdef int cost(StateClass s, const GoldParseC* gold, int label) nogil:
|
||||||
move = LAST
|
move = LAST
|
||||||
|
|
||||||
cdef int g_act = gold.ner[s.B(0)].move
|
cdef int g_act = gold.ner[s.B(0)].move
|
||||||
|
@ -277,11 +277,11 @@ cdef class Last:
|
||||||
|
|
||||||
cdef class Unit:
|
cdef class Unit:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef bint is_valid(StateClass st, int label) except -1:
|
cdef bint is_valid(StateClass st, int label) nogil:
|
||||||
return label != 0 and not st.entity_is_open()
|
return label != 0 and not st.entity_is_open()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int transition(StateClass st, int label) except -1:
|
cdef int transition(StateClass st, int label) nogil:
|
||||||
st.open_ent(label)
|
st.open_ent(label)
|
||||||
st.close_ent()
|
st.close_ent()
|
||||||
st.set_ent_tag(st.B(0), 3, label)
|
st.set_ent_tag(st.B(0), 3, label)
|
||||||
|
@ -289,7 +289,7 @@ cdef class Unit:
|
||||||
st.pop()
|
st.pop()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int cost(StateClass s, const GoldParseC* gold, int label) except -1:
|
cdef int cost(StateClass s, const GoldParseC* gold, int label) nogil:
|
||||||
cdef int g_act = gold.ner[s.B(0)].move
|
cdef int g_act = gold.ner[s.B(0)].move
|
||||||
cdef int g_tag = gold.ner[s.B(0)].label
|
cdef int g_tag = gold.ner[s.B(0)].label
|
||||||
|
|
||||||
|
@ -308,17 +308,17 @@ cdef class Unit:
|
||||||
|
|
||||||
cdef class Out:
|
cdef class Out:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef bint is_valid(StateClass st, int label) except -1:
|
cdef bint is_valid(StateClass st, int label) nogil:
|
||||||
return not st.entity_is_open()
|
return not st.entity_is_open()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int transition(StateClass st, int label) except -1:
|
cdef int transition(StateClass st, int label) nogil:
|
||||||
st.set_ent_tag(st.B(0), 2, 0)
|
st.set_ent_tag(st.B(0), 2, 0)
|
||||||
st.push()
|
st.push()
|
||||||
st.pop()
|
st.pop()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef int cost(StateClass s, const GoldParseC* gold, int label) except -1:
|
cdef int cost(StateClass s, const GoldParseC* gold, int label) nogil:
|
||||||
cdef int g_act = gold.ner[s.B(0)].move
|
cdef int g_act = gold.ner[s.B(0)].move
|
||||||
cdef int g_tag = gold.ner[s.B(0)].label
|
cdef int g_tag = gold.ner[s.B(0)].label
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user