Пример #1
0
 def deserializedd(str0_: io.IOBase, dic: 'DerivateDictionary',
                   lazy_load: bool) -> 'ByteArrayWrapper':
     wr = None
     with io.BytesIO() as tmp:
         MorphSerializeHelper.deflate_gzip(str0_, tmp)
         wr = ByteArrayWrapper(bytearray(tmp.getvalue()))
         pos = 0
         wrappos9 = RefOutArgWrapper(pos)
         cou = wr.deserialize_int(wrappos9)
         pos = wrappos9.value
         while cou > 0:
             wrappos7 = RefOutArgWrapper(pos)
             p1 = wr.deserialize_int(wrappos7)
             pos = wrappos7.value
             ew = DerivateGroup()
             if (lazy_load):
                 ew._lazy_pos = pos
                 pos = p1
             else:
                 wrappos6 = RefOutArgWrapper(pos)
                 DeserializeHelper.deserialize_derivate_group(
                     wr, ew, wrappos6)
                 pos = wrappos6.value
             dic._m_all_groups.append(ew)
             cou -= 1
         dic._m_root = ExplanTreeNode()
         wrappos8 = RefOutArgWrapper(pos)
         DeserializeHelper.deserialize_tree_node(wr, dic, dic._m_root,
                                                 lazy_load, wrappos8)
         pos = wrappos8.value
     return wr
Пример #2
0
 def deserialize_tree_node(str0_: 'ByteArrayWrapper',
                           dic: 'DerivateDictionary', tn: 'ExplanTreeNode',
                           lazy_load: bool, pos: int) -> None:
     cou = str0_.deserialize_short(pos)
     li = (list() if cou > 1 else None)
     while cou > 0:
         id0_ = str0_.deserialize_int(pos)
         if (id0_ > 0 and id0_ <= len(dic._m_all_groups)):
             gr = dic._m_all_groups[id0_ - 1]
             if (gr._lazy_pos > 0):
                 p0 = pos.value
                 pos.value = gr._lazy_pos
                 DeserializeHelper.deserialize_derivate_group(
                     str0_, gr, pos)
                 gr._lazy_pos = 0
                 pos.value = p0
             if (li is not None):
                 li.append(gr)
             else:
                 tn.groups = (gr)
         cou -= 1
     if (li is not None):
         tn.groups = (li)
     cou = str0_.deserialize_short(pos)
     if (cou == 0):
         return
     while cou > 0:
         ke = str0_.deserialize_short(pos)
         p1 = str0_.deserialize_int(pos)
         tn1 = ExplanTreeNode()
         if (tn.nodes is None):
             tn.nodes = dict()
         if (not ke in tn.nodes):
             tn.nodes[ke] = tn1
         if (lazy_load):
             tn1.lazy_pos = pos.value
             pos.value = p1
         else:
             DeserializeHelper.deserialize_tree_node(
                 str0_, dic, tn1, False, pos)
         cou -= 1
Пример #3
0
 def deserializeTreeNode(str0_ : 'ByteArrayWrapper', dic : 'DerivateDictionary', tn : 'ExplanTreeNode', lazy_load : bool) -> None:
     cou = str0_.deserializeShort()
     li = (list() if cou > 1 else None)
     while cou > 0: 
         id0_ = str0_.deserializeInt()
         if (id0_ > 0 and id0_ <= len(dic._m_all_groups)): 
             gr = dic._m_all_groups[id0_ - 1]
             if (gr._lazy_pos > 0): 
                 p0 = str0_.position
                 str0_.seek(gr._lazy_pos)
                 DeserializeHelper.deserializeDerivateGroup(str0_, gr)
                 gr._lazy_pos = 0
                 str0_.seek(p0)
             if (li is not None): 
                 li.append(gr)
             else: 
                 tn.groups = (gr)
         cou -= 1
     if (li is not None): 
         tn.groups = (li)
     cou = str0_.deserializeShort()
     if (cou == 0): 
         return
     while cou > 0: 
         ke = str0_.deserializeShort()
         p1 = str0_.deserializeInt()
         tn1 = ExplanTreeNode()
         if (tn.nodes is None): 
             tn.nodes = dict()
         if (not ke in tn.nodes): 
             tn.nodes[ke] = tn1
         if (lazy_load): 
             tn1.lazy_pos = str0_.position
             str0_.seek(p1)
         else: 
             DeserializeHelper.deserializeTreeNode(str0_, dic, tn1, False)
         cou -= 1
Пример #4
0
 def deserializeDD(str0_ : io.IOBase, dic : 'DerivateDictionary', lazy_load : bool) -> 'ByteArrayWrapper':
     wr = None
     with io.BytesIO() as tmp: 
         MorphSerializeHelper.deflateGzip(str0_, tmp)
         wr = ByteArrayWrapper(bytearray(tmp.getvalue()))
         cou = wr.deserializeInt()
         while cou > 0: 
             p1 = wr.deserializeInt()
             ew = DerivateGroup()
             if (lazy_load): 
                 ew._lazy_pos = wr.position
                 wr.seek(p1)
             else: 
                 DeserializeHelper.deserializeDerivateGroup(wr, ew)
             dic._m_all_groups.append(ew)
             cou -= 1
         dic._m_root = ExplanTreeNode()
         DeserializeHelper.deserializeTreeNode(wr, dic, dic._m_root, lazy_load)
     return wr
Пример #5
0
 def add(self, dg: 'DerivateGroup') -> None:
     self._m_all_groups.append(dg)
     for w in dg.words:
         if (w.spelling is None):
             continue
         tn = self._m_root
         i = 0
         while i < len(w.spelling):
             k = ord(w.spelling[i])
             tn1 = None
             if (tn.nodes is None):
                 tn.nodes = dict()
             wraptn11 = RefOutArgWrapper(None)
             inoutres2 = Utils.tryGetValue(tn.nodes, k, wraptn11)
             tn1 = wraptn11.value
             if (not inoutres2):
                 tn1 = ExplanTreeNode()
                 tn.nodes[k] = tn1
             tn = tn1
             i += 1
         tn._add_group(dg)
Пример #6
0
 def unload(self) -> None:
     self._m_root = ExplanTreeNode()
     self._m_all_groups.clear()
     self.lang = MorphLang()
Пример #7
0
 def __init__(self) -> None:
     self.lang = None
     self.__m_inited = False
     self.__m_buf = None
     self._m_root = ExplanTreeNode()
     self._m_all_groups = list()