Changes to matcher.pyx for new StringStore scheme

This commit is contained in:
Matthew Honnibal 2016-09-30 19:56:48 +02:00
parent eceeaefe53
commit 3ff09614e0
1 changed files with 3 additions and 3 deletions

View File

@ -153,7 +153,7 @@ def _convert_strings(token_specs, string_store):
if isinstance(attr, basestring): if isinstance(attr, basestring):
attr = attrs.IDS.get(attr.upper()) attr = attrs.IDS.get(attr.upper())
if isinstance(value, basestring): if isinstance(value, basestring):
value = string_store[value] value = string_store.intern(value)
if isinstance(value, bool): if isinstance(value, bool):
value = int(value) value = int(value)
if attr is not None: if attr is not None:
@ -221,9 +221,9 @@ cdef class Matcher:
def add(self, entity_key, etype, attrs, specs): def add(self, entity_key, etype, attrs, specs):
self._patterns[entity_key] = (etype, dict(attrs), list(specs)) self._patterns[entity_key] = (etype, dict(attrs), list(specs))
if isinstance(entity_key, basestring): if isinstance(entity_key, basestring):
entity_key = self.vocab.strings[entity_key] entity_key = self.vocab.strings.intern(entity_key)
if isinstance(etype, basestring): if isinstance(etype, basestring):
etype = self.vocab.strings[etype] etype = self.vocab.strings.intern(etype)
elif etype is None: elif etype is None:
etype = -1 etype = -1
# TODO: Do something more clever about multiple patterns for single # TODO: Do something more clever about multiple patterns for single