Example #1
0
 def __find_in_tree(self, key : str, lang : 'MorphLang') -> typing.List['Termin']:
     if (key is None): 
         return None
     nod = self.__get_root(lang, ((lang is None or lang.is_undefined)) and LanguageHelper.is_latin(key))
     i = 0
     while i < len(key): 
         ch = ord(key[i])
         nn = None
         if (nod.children is not None): 
             wrapnn582 = RefOutArgWrapper(None)
             Utils.tryGetValue(nod.children, ch, wrapnn582)
             nn = wrapnn582.value
         if (nn is None): 
             if (ch == (32)): 
                 if (nod.termins is not None): 
                     pp = Utils.splitString(key, ' ', False)
                     res = None
                     for t in nod.termins: 
                         if (len(t.terms) == len(pp)): 
                             k = 0
                             k = 1
                             while k < len(pp): 
                                 if (not pp[k] in t.terms[k].variants): 
                                     break
                                 k += 1
                             if (k >= len(pp)): 
                                 if (res is None): 
                                     res = list()
                                 res.append(t)
                     return res
             return None
         nod = nn
         i += 1
     return nod.termins
Example #2
0
 def __remove_from_tree(self, key : str, t : 'Termin') -> None:
     if (key is None): 
         return
     nod = self.__get_root(t.lang, t.lang.is_undefined and LanguageHelper.is_latin(key))
     i = 0
     while i < len(key): 
         ch = ord(key[i])
         if (nod.children is None): 
             return
         nn = None
         wrapnn580 = RefOutArgWrapper(None)
         inoutres581 = Utils.tryGetValue(nod.children, ch, wrapnn580)
         nn = wrapnn580.value
         if (not inoutres581): 
             return
         nod = nn
         i += 1
     if (nod.termins is None): 
         return
     if (t in nod.termins): 
         nod.termins.remove(t)
Example #3
0
 def __add_to_tree(self, key : str, t : 'Termin') -> None:
     if (key is None): 
         return
     nod = self.__get_root(t.lang, t.lang.is_undefined and LanguageHelper.is_latin(key))
     i = 0
     while i < len(key): 
         ch = ord(key[i])
         if (nod.children is None): 
             nod.children = dict()
         nn = None
         wrapnn578 = RefOutArgWrapper(None)
         inoutres579 = Utils.tryGetValue(nod.children, ch, wrapnn578)
         nn = wrapnn578.value
         if (not inoutres579): 
             nn = TerminCollection.CharNode()
             nod.children[ch] = nn
         nod = nn
         i += 1
     if (nod.termins is None): 
         nod.termins = list()
     if (not t in nod.termins): 
         nod.termins.append(t)