From ea1d4a81eb42eafbeba54fecf6496ada48824e43 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 22 Oct 2014 13:10:56 +1100 Subject: [PATCH] * Refactoring get_atoms, improving tokens API --- spacy/pos.pyx | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/spacy/pos.pyx b/spacy/pos.pyx index 24e021436..46e677b3c 100644 --- a/spacy/pos.pyx +++ b/spacy/pos.pyx @@ -119,26 +119,12 @@ cdef int get_atoms(atom_t* context, int i, Tokens tokens, class_t prev_tag, cdef int j for j in range(CONTEXT_SIZE): context[j] = 0 - cdef int[5] indices - indices[0] = i-2 - indices[1] = i-1 - indices[2] = i - indices[3] = i+1 - indices[4] = i+2 + cdef int* indices = [i-2, i-1, i, i+1, i+2] - cdef int[2] int_feats - int_feats[0] = LexInt_id - int_feats[1] = LexInt_cluster - - cdef int[4] string_feats - string_feats[0] = LexStr_shape - string_feats[1] = LexStr_suff - string_feats[2] = LexStr_pre - string_feats[3] = LexStr_norm - - cdef int[2] bool_feats - bool_feats[0] = LexDist_title - bool_feats[1] = LexDist_upper + cdef int* int_feats = [LexInt_id, LexInt_cluster] + cdef int* string_feats = [LexStr_shape, LexStr_suff, LexStr_pre, + LexStr_norm] + cdef int* bool_feats = [LexDist_title, LexDist_upper] cdef int c = 0 c = tokens.int_array(context, c, indices, 5, int_feats, 2)