Entity class

This commit is contained in:
svlandeg 2019-03-21 13:32:21 +01:00
parent 1289cd6e8f
commit b6c3255a9f
2 changed files with 30 additions and 0 deletions

View File

@ -43,6 +43,14 @@ cdef struct _AliasC:
vector[float] probs
# TODO: document
cdef class Entity:
cdef readonly KnowledgeBase kb
cdef hash_t entity_hash
cdef float confidence
# TODO: document
cdef class Candidate:

View File

@ -3,6 +3,28 @@
from spacy.errors import user_warning
cdef class Entity:
def __init__(self, KnowledgeBase kb, entity_hash, confidence):
self.kb = kb
self.entity_hash = entity_hash
self.confidence = confidence
property kb_id_:
"""RETURNS (unicode): ID of this entity in the KB"""
def __get__(self):
return self.kb.strings[self.entity_hash]
property kb_id:
"""RETURNS (uint64): hash of the entity's KB ID"""
def __get__(self):
return self.entity_hash
property confidence:
def __get__(self):
return self.confidence
cdef class Candidate:
def __init__(self, KnowledgeBase kb, entity_hash, alias_hash, prior_prob):