* Set initial freqs, to avoid missing values in serializer

This commit is contained in:
Matthew Honnibal 2015-07-23 01:16:27 +02:00
parent 680bb47b55
commit 12699a1152
2 changed files with 8 additions and 0 deletions

View File

@ -262,6 +262,9 @@ cdef class EnPosTagger:
'morphs.json'))))
self.lemmatizer = Lemmatizer(path.join(data_dir, 'wordnet'), NOUN, VERB, ADJ)
self.freqs = {TAG: defaultdict(int)}
for tag in self.tag_names:
self.freqs[TAG][self.strings[tag]] = 1
self.freqs[TAG][0] = 1
def __call__(self, Doc tokens):
"""Apply the tagger, setting the POS tags onto the Doc object.

View File

@ -33,6 +33,11 @@ cdef class TransitionSystem:
self.freqs = {}
for attr in (TAG, HEAD, DEP, ENT_TYPE, ENT_IOB):
self.freqs[attr] = defaultdict(int)
self.freqs[attr][0] = 1
# Ensure we've seen heads. Need an official dependency length limit...
for i in range(512):
self.freqs[HEAD][i] = 1
self.freqs[HEAD][-i] = 1
cdef int initialize_state(self, StateClass state) except -1:
pass