diff --git a/spacy/kb.pxd b/spacy/kb.pxd index 9d9a21a8c..3ba9c8bba 100644 --- a/spacy/kb.pxd +++ b/spacy/kb.pxd @@ -67,8 +67,8 @@ cdef class KnowledgeBase: # efficient. cdef object _aliases_table - cdef void c_add_entity(self, hash_t key, float prob, const int32_t* vector_rows, - int feats_row) nogil: + cdef inline int64_t c_add_entity(self, hash_t key, float prob, const int32_t* vector_rows, + int feats_row): """Add an entry to the knowledge base.""" # This is what we'll map the hash key to. It's where the entry will sit # in the vector of entries, so we can get it later. diff --git a/spacy/kb.pyx b/spacy/kb.pyx index ce76f2fc4..46acc2967 100644 --- a/spacy/kb.pyx +++ b/spacy/kb.pyx @@ -11,17 +11,21 @@ cdef class KnowledgeBase: return cdef hash_t name_hash = hash_string(name) - self.c_add_entity(name_hash, prob, self._vectors_table.get_pointer(vectors), - self._features_table.get(features)) + cdef int32_t dummy_value = 342 + self.c_add_entity(name_hash, prob, &dummy_value, dummy_value) + # TODO self._vectors_table.get_pointer(vectors), + # self._features_table.get(features)) def add_alias(self, alias, entities, probabilities): """For a given alias, add its potential entities and prior probabilies to the KB.""" cdef hash_t alias_hash = hash_string(alias) + cdef hash_t entity_hash = 0 + cdef int64_t entity_index = 0 # TODO: check len(entities) == len(probabilities) for entity, prob in zip(entities, probabilities): - cdef hash_t entity_hash = hash_string(entity) - cdef int64_t entity_index = self._index[entity_hash] + entity_hash = hash_string(entity) + entity_index = self._index[entity_hash] # TODO: check that entity is already in this KB (entity_index is OK) self._aliases_table.add(alias_hash, entity_index, prob)