Beispiel #1
0
 def generate():
     preType = 5
     preChar = 0
     typeList = []
     for i in range(65535):
         type = TextUtility.charType(i)
         if type != preType:
             array = [int()] * 3
             array[0] = preChar
             array[1] = i - 1
             array[2] = preType
             typeList.append(array)
         preChar = i
     array = [int()] * 3
     array[0] = preChar
     array[1] = 65535
     array[2] = preType
     typeList.append(array)
     out = sys.file(Config.CharTypePath, 'w+')
     for array in typeList:
         out.writelines(Convert.convert_char(array[0]))
         out.writelines(Convert.convert_char(array[1]))
         out.writelines(Convert.convert_byte(array[2]))
     out.close()
     byteArray = ByteArray.createByteArray(Config.CharTypePath)
     return byteArray
    def saveDat(self, map):
        """
        保存bat到磁盘
        :param map:
        :return:
        """
        out = open(JapanesePersonDictionary.path + Predefine.VALUE_EXT, 'w+')
        out.writelines(Convert.convert(map.size()))
        for k, c in map.items():
            out.writelines(Convert.convert_char(ord(c)))
        out.close()

        return JapanesePersonDictionary.trie.save(JapanesePersonDictionary.path + Predefine.TRIE_EXT)