From 4df8a3d90f0f6b7e878868120338d45cebca0587 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 10 Apr 2015 05:02:15 +0200 Subject: [PATCH] * Add ne_iob and ne_type attributes to context vector --- spacy/syntax/_parse_features.pxd | 36 ++++++++++++++++++++++++++++++++ spacy/syntax/_parse_features.pyx | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/spacy/syntax/_parse_features.pxd b/spacy/syntax/_parse_features.pxd index a51706af3..81107e94c 100644 --- a/spacy/syntax/_parse_features.pxd +++ b/spacy/syntax/_parse_features.pxd @@ -32,6 +32,8 @@ cpdef enum: S2_prefix S2_suffix S2_shape + S2_ne_iob + S2_ne_type S1w S1W @@ -43,6 +45,8 @@ cpdef enum: S1_prefix S1_suffix S1_shape + S1_ne_iob + S1_ne_type S1rw S1rW @@ -54,6 +58,8 @@ cpdef enum: S1r_prefix S1r_suffix S1r_shape + S1r_ne_iob + S1r_ne_type S0lw S0lW @@ -65,6 +71,8 @@ cpdef enum: S0l_prefix S0l_suffix S0l_shape + S0l_ne_iob + S0l_ne_type S0l2w S0l2W @@ -76,6 +84,8 @@ cpdef enum: S0l2_prefix S0l2_suffix S0l2_shape + S0l2_ne_iob + S0l2_ne_type S0w S0W @@ -87,6 +97,8 @@ cpdef enum: S0_prefix S0_suffix S0_shape + S0_ne_iob + S0_ne_type S0r2w S0r2W @@ -98,6 +110,8 @@ cpdef enum: S0r2_prefix S0r2_suffix S0r2_shape + S0r2_ne_iob + S0r2_ne_type S0rw S0rW @@ -109,6 +123,8 @@ cpdef enum: S0r_prefix S0r_suffix S0r_shape + S0r_ne_iob + S0r_ne_type N0l2w N0l2W @@ -120,6 +136,8 @@ cpdef enum: N0l2_prefix N0l2_suffix N0l2_shape + N0l2_ne_iob + N0l2_ne_type N0lw N0lW @@ -131,6 +149,8 @@ cpdef enum: N0l_prefix N0l_suffix N0l_shape + N0l_ne_iob + N0l_ne_type N0w N0W @@ -142,6 +162,8 @@ cpdef enum: N0_prefix N0_suffix N0_shape + N0_ne_iob + N0_ne_type N1w N1W @@ -153,6 +175,8 @@ cpdef enum: N1_prefix N1_suffix N1_shape + N1_ne_iob + N1_ne_type N2w N2W @@ -164,6 +188,8 @@ cpdef enum: N2_prefix N2_suffix N2_shape + N2_ne_iob + N2_ne_type P1w P1W @@ -175,6 +201,8 @@ cpdef enum: P1_prefix P1_suffix P1_shape + P1_ne_iob + P1_ne_type P2w P2W @@ -186,6 +214,8 @@ cpdef enum: P2_prefix P2_suffix P2_shape + P2_ne_iob + P2_ne_type E0w E0W @@ -197,6 +227,8 @@ cpdef enum: E0_prefix E0_suffix E0_shape + E0_ne_iob + E0_ne_type E1w E1W @@ -208,6 +240,8 @@ cpdef enum: E1_prefix E1_suffix E1_shape + E1_ne_iob + E1_ne_type # Misc features at the end dist @@ -221,4 +255,6 @@ cpdef enum: S1_has_head S2_has_head + ent_type + CONTEXT_SIZE diff --git a/spacy/syntax/_parse_features.pyx b/spacy/syntax/_parse_features.pyx index 363665138..44030122b 100644 --- a/spacy/syntax/_parse_features.pyx +++ b/spacy/syntax/_parse_features.pyx @@ -32,6 +32,8 @@ cdef inline void fill_token(atom_t* context, const TokenC* token) nogil: context[7] = 0 context[8] = 0 context[9] = 0 + context[10] = 0 + context[11] = 0 else: context[0] = token.lex.orth context[1] = token.lemma @@ -55,6 +57,8 @@ cdef inline void fill_token(atom_t* context, const TokenC* token) nogil: context[7] = token.lex.prefix context[8] = token.lex.suffix context[9] = token.lex.shape + context[10] = token.ent_iob + context[11] = token.ent_type cdef int fill_context(atom_t* context, State* state) except -1: