def deserialize(self, stream : io.IOBase) -> bool: vers = 0 b = Utils.readByteIO(stream) if (b == (0xAA)): b = (Utils.readByteIO(stream)) vers = (b) else: stream.seek(stream.tell() - (1), io.SEEK_SET) self.__m_sofa = SourceOfAnalysis(None) self.__m_sofa.deserialize(stream) self.base_language = MorphLang._new5(SerializerHelper.deserializeInt(stream)) self.__m_entities = list() cou = SerializerHelper.deserializeInt(stream) i = 0 while i < cou: typ = SerializerHelper.deserializeString(stream) r = ProcessorService.createReferent(typ) if (r is None): r = Referent("UNDEFINED") self.__m_entities.append(r) i += 1 i = 0 while i < cou: self.__m_entities[i].deserialize(stream, self.__m_entities, self.__m_sofa) i += 1 self.first_token = SerializerHelper.deserializeTokens(stream, self, vers) self.__createStatistics() return True
def clone(self) -> 'Referent': from pullenti.ner.Slot import Slot res = ProcessorService.createReferent(self.type_name) if (res is None): res = Referent(self.type_name) res.occurrence.extend(self.occurrence) res.ontology_items = self.ontology_items for r in self.slots: rr = Slot._new2690(r.type_name, r.value, r.count) rr.owner = res res.slots.append(rr) return res