mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
Entity class
This commit is contained in:
parent
6ba4079f7c
commit
a5d5a05930
|
@ -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