property annotations for fields with only a getter

This commit is contained in:
svlandeg 2019-03-22 16:10:49 +01:00
parent 9751312aff
commit b4cd5d5ee9

View File

@ -11,39 +11,39 @@ cdef class Candidate:
self.alias_hash = alias_hash self.alias_hash = alias_hash
self.prior_prob = prior_prob self.prior_prob = prior_prob
property entity_id: @property
def entity_id(self):
"""RETURNS (uint64): hash of the entity's KB ID""" """RETURNS (uint64): hash of the entity's KB ID"""
def __get__(self):
return self.entity_id_hash return self.entity_id_hash
property entity_id_: @property
def entity_id_(self):
"""RETURNS (unicode): ID of this entity in the KB""" """RETURNS (unicode): ID of this entity in the KB"""
def __get__(self):
return self.kb.vocab.strings[self.entity_id] return self.kb.vocab.strings[self.entity_id]
property entity_name: @property
def entity_name(self):
"""RETURNS (uint64): hash of the entity's KB name""" """RETURNS (uint64): hash of the entity's KB name"""
def __get__(self):
entry_index = <int64_t>self.kb._entry_index.get(self.entity_id) entry_index = <int64_t>self.kb._entry_index.get(self.entity_id)
return self.kb._entries[entry_index].entity_name_hash return self.kb._entries[entry_index].entity_name_hash
property entity_name_: @property
def entity_name_(self):
"""RETURNS (unicode): name of this entity in the KB""" """RETURNS (unicode): name of this entity in the KB"""
def __get__(self):
return self.kb.vocab.strings[self.entity_name] return self.kb.vocab.strings[self.entity_name]
property alias: @property
def alias(self):
"""RETURNS (uint64): hash of the alias""" """RETURNS (uint64): hash of the alias"""
def __get__(self):
return self.alias_hash return self.alias_hash
property alias_: @property
def alias_(self):
"""RETURNS (unicode): ID of the original alias""" """RETURNS (unicode): ID of the original alias"""
def __get__(self):
return self.kb.vocab.strings[self.alias] return self.kb.vocab.strings[self.alias]
property prior_prob: @property
def __get__(self): def prior_prob(self):
return self.prior_prob return self.prior_prob