示例#1
0
 def getBytes(name: str) -> bytearray:
     """ Получить встроенный ресурс
     
     Args:
         name(str): имя, на который оканчивается ресурс
     
     """
     # ignored: assembly = EpNerBankInternalResourceHelper.
     names = Utils.getResourcesNames('pullenti.ner.bank.properties',
                                     '.png;.txt;.csv')
     for n in names:
         if (Utils.endsWithString(n, name, True)):
             try:
                 inf = Utils.getResourceInfo('pullenti.ner.bank.properties',
                                             n)
                 if (inf is None):
                     continue
                 with Utils.getResourceStream(
                         'pullenti.ner.bank.properties', n) as stream:
                     buf = Utils.newArrayOfBytes(Utils.getLengthIO(stream),
                                                 0)
                     Utils.readIO(stream, buf, 0, len(buf))
                     return buf
             except Exception as ex:
                 pass
     return None
    def get_bytes(name: str) -> bytearray:
        """ Получить встроенный ресурс
        
        Args:
            name(str): имя, на который оканчивается ресурс
        
        """

        names = Utils.getResourcesNames('pullenti.ner.org.properties',
                                        '.png;.dat')
        for n in names:
            if (Utils.endsWithString(n, name, True)):
                if (len(name) < len(n)):
                    if (n[len(n) - len(name) - 1] != '.'):
                        continue
                try:
                    inf = Utils.getResourceInfo('pullenti.ner.org.properties',
                                                n)
                    if (inf is None):
                        continue
                    with Utils.getResourceStream('pullenti.ner.org.properties',
                                                 n) as stream:
                        buf = Utils.newArrayOfBytes(stream.length, 0)
                        stream.read(buf, 0, len(buf))
                        return buf
                except Exception as ex:
                    pass
        return None
示例#3
0
 def initialize(self, lang: 'MorphLang') -> bool:
     from pullenti.morph.Morphology import Morphology
     if (not self.language.is_undefined):
         return False
     with self._m_lock:
         if (not self.language.is_undefined):
             return False
         self.language = lang
         # ignored: assembly =
         rsname = "m_{0}.dat".format(str(lang))
         names = Utils.getResourcesNames(
             'pullenti.morph.internal.properties', '.dat')
         for n in names:
             if (Utils.endsWithString(n, rsname, True)):
                 inf = Utils.getResourceInfo(
                     'pullenti.morph.internal.properties', n)
                 if (inf is None):
                     continue
                 with Utils.getResourceStream(
                         'pullenti.morph.internal.properties', n) as stream:
                     stream.seek(0, io.SEEK_SET)
                     self.__m_lazy_buf = MorphSerializeHelper.deserialize_all(
                         stream, self, False, Morphology.LAZY_LOAD)
                 return True
         return False
 def init(self, lang_ : 'MorphLang', lazy : bool) -> bool:
     if (self.__m_inited): 
         return True
     
     rsname = "d_{0}.dat".format(str(lang_))
     names = Utils.getResourcesNames('pullenti.semantic.utils.properties', '.dat')
     for n in names: 
         if (Utils.endsWithString(n, rsname, True)): 
             inf = Utils.getResourceInfo('pullenti.semantic.utils.properties', n)
             if (inf is None): 
                 continue
             with Utils.getResourceStream('pullenti.semantic.utils.properties', n) as stream: 
                 stream.position = 0
                 self._m_all_groups.clear()
                 self._deserialize(stream, lazy)
                 self.lang = lang_
             self.__m_inited = True
             return True
     return False
 def get_bytes(name : str) -> bytearray:
     
     names = Utils.getResourcesNames('pullenti.ner.core.properties', '.csv;.png')
     for n in names: 
         if (Utils.endsWithString(n, name, True)): 
             if (len(name) < len(n)): 
                 if (n[len(n) - len(name) - 1] != '.'): 
                     continue
             try: 
                 inf = Utils.getResourceInfo('pullenti.ner.core.properties', n)
                 if (inf is None): 
                     continue
                 with Utils.getResourceStream('pullenti.ner.core.properties', n) as stream: 
                     buf = Utils.newArrayOfBytes(stream.length, 0)
                     stream.read(buf, 0, len(buf))
                     return buf
             except Exception as ex: 
                 pass
     return None
示例#6
0
 def initialize(self, lang : 'MorphLang', lazy_load : bool) -> bool:
     if (not self.language.is_undefined): 
         return False
     with self._m_lock: 
         if (not self.language.is_undefined): 
             return False
         self.language = lang
         
         rsname = "m_{0}.dat".format(str(lang))
         names = Utils.getResourcesNames('pullenti.morph.internal.properties', '.dat')
         for n in names: 
             if (Utils.endsWithString(n, rsname, True)): 
                 inf = Utils.getResourceInfo('pullenti.morph.internal.properties', n)
                 if (inf is None): 
                     continue
                 with Utils.getResourceStream('pullenti.morph.internal.properties', n) as stream: 
                     stream.position = 0
                     self.deserialize(stream, False, lazy_load)
                 return True
         return False
示例#7
0
 def init(self, lang_: 'MorphLang') -> bool:
     if (self.__m_inited):
         return True
     # ignored: assembly =
     rsname = "d_{0}.dat".format(str(lang_))
     names = Utils.getResourcesNames('pullenti.morph.properties', '.dat')
     for n in names:
         if (Utils.endsWithString(n, rsname, True)):
             inf = Utils.getResourceInfo('pullenti.morph.properties', n)
             if (inf is None):
                 continue
             with Utils.getResourceStream('pullenti.morph.properties',
                                          n) as stream:
                 stream.seek(0, io.SEEK_SET)
                 self._m_all_groups.clear()
                 self.__m_buf = DeserializeHelper.deserializedd(
                     stream, self, True)
                 self.lang = lang_
             self.__m_inited = True
             return True
     return False