mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 09:56:28 +03:00
Entity class
This commit is contained in:
parent
1289cd6e8f
commit
b6c3255a9f
|
@ -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:
|
||||
|
||||
|
|
22
spacy/kb.pyx
22
spacy/kb.pyx
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user