Example #1
0
 def _serialize(self, stream: Stream) -> None:
     from pullenti.ner.core.internal.SerializerHelper import SerializerHelper
     super()._serialize(stream)
     SerializerHelper.serialize_string(stream, self.term)
     SerializerHelper.serialize_string(stream, self.lemma)
     SerializerHelper.serialize_short(
         stream, self.invariant_prefix_length_of_morph_vars)
     SerializerHelper.serialize_short(stream, self.max_length_of_morph_vars)
Example #2
0
 def serialize(self, stream: Stream) -> None:
     """ Сериализовать весь словарь в поток
     
     Args:
         stream(Stream): поток для сериализации
     """
     SerializerHelper.serialize_string(stream, self.__m_specs)
     SerializerHelper.serialize_int(stream, len(self.items))
     for it in self.items:
         it._serialize(stream)
Example #3
0
 def serialize(self, stream: Stream) -> None:
     SerializerHelper.serialize_string(stream, self.type_name)
     SerializerHelper.serialize_int(stream, len(self.__m_slots))
     for s in self.__m_slots:
         SerializerHelper.serialize_string(stream, s.type_name)
         SerializerHelper.serialize_int(stream, s.count)
         if ((isinstance(s.value, Referent))
                 and (isinstance(s.value.tag, int))):
             SerializerHelper.serialize_int(stream, -(s.value.tag))
         elif (isinstance(s.value, str)):
             SerializerHelper.serialize_string(
                 stream, Utils.asObjectOrNull(s.value, str))
         elif (s.value is None):
             SerializerHelper.serialize_int(stream, 0)
         else:
             SerializerHelper.serialize_string(stream, str(s.value))
     if (self.__m_occurrence is None):
         SerializerHelper.serialize_int(stream, 0)
     else:
         SerializerHelper.serialize_int(stream, len(self.__m_occurrence))
         for o in self.__m_occurrence:
             SerializerHelper.serialize_int(stream, o.begin_char)
             SerializerHelper.serialize_int(stream, o.end_char)
             attr = 0
             if (o.essential_for_occurence):
                 attr = 1
             SerializerHelper.serialize_int(stream, attr)
Example #4
0
 def serialize(self, stream: Stream) -> None:
     stream.writebyte(0xAA)
     stream.writebyte(1)
     self.__m_sofa.serialize(stream)
     SerializerHelper.serialize_int(stream, self.base_language.value)
     if (len(self.__m_entities) == 0):
         for d in self.__m_datas.items():
             self.__m_entities.extend(d[1].referents)
     SerializerHelper.serialize_int(stream, len(self.__m_entities))
     i = 0
     while i < len(self.__m_entities):
         self.__m_entities[i].tag = i + 1
         SerializerHelper.serialize_string(stream,
                                           self.__m_entities[i].type_name)
         i += 1
     for e0_ in self.__m_entities:
         e0_.serialize(stream)
     SerializerHelper.serialize_tokens(stream, self.first_token, 0)
 def _serialize(self, stream: Stream) -> None:
     SerializerHelper.serialize_string(
         stream, (None if self.ext_id is None else str(self.ext_id)))
     SerializerHelper.serialize_string(stream, self.__m_caption)
     if (self._refs is None):
         SerializerHelper.serialize_int(stream, 0)
     else:
         SerializerHelper.serialize_int(stream, len(self._refs))
         id0_ = 1
         for r in self._refs:
             r.tag = id0_
             id0_ += 1
         for r in self._refs:
             r.occurrence.clear()
             SerializerHelper.serialize_string(stream, r.type_name)
             r.serialize(stream)
     self.referent.occurrence.clear()
     SerializerHelper.serialize_string(stream, self.type_name)
     self.referent.serialize(stream)
 def __serialize_item(self, stream: Stream, bi: 'MorphBaseInfo') -> None:
     from pullenti.ner.core.internal.SerializerHelper import SerializerHelper
     ty = 0
     if (isinstance(bi, MorphWordForm)):
         ty = (1)
     stream.writebyte(ty)
     SerializerHelper.serialize_short(stream, bi.class0_.value)
     SerializerHelper.serialize_short(stream, bi.case_.value)
     SerializerHelper.serialize_short(stream, bi.gender)
     SerializerHelper.serialize_short(stream, bi.number)
     SerializerHelper.serialize_short(stream, bi.language.value)
     wf = Utils.asObjectOrNull(bi, MorphWordForm)
     if (wf is None):
         return
     SerializerHelper.serialize_string(stream, wf.normal_case)
     SerializerHelper.serialize_string(stream, wf.normal_full)
     SerializerHelper.serialize_short(stream, wf.undef_coef)
     SerializerHelper.serialize_int(
         stream, (0 if wf.misc is None else len(wf.misc.attrs)))
     if (wf.misc is not None):
         for a in wf.misc.attrs:
             SerializerHelper.serialize_string(stream, a)
Example #7
0
 def _serialize(self, stream: Stream) -> None:
     from pullenti.ner.core.internal.SerializerHelper import SerializerHelper
     super()._serialize(stream)
     SerializerHelper.serialize_string(stream, self.__m_value)
     SerializerHelper.serialize_int(stream, self.typ)
Example #8
0
 def serialize(self, stream: Stream) -> None:
     SerializerHelper.serialize_string(stream, self.text)