Ejemplo n.º 1
0
 def setUp(self):
     # Copied from sudachipy.dictionay.Dictionary.read_system_dictionary
     test_resources_dir = os.path.join(
         os.path.dirname(os.path.abspath(__file__)), os.pardir, 'resources')
     filename = os.path.join(test_resources_dir, 'system.dic')
     with open(filename, 'rb') as system_dic:
         bytes_ = mmap.mmap(system_dic.fileno(), 0, access=mmap.ACCESS_READ)
     offset = 0
     self.header = DictionaryHeader.from_bytes(bytes_, offset)
Ejemplo n.º 2
0
 def setUp(self):
     # Copied from sudachipy.dictionay.Dictionary.read_system_dictionary
     test_resources_dir = os.path.join(
         os.path.dirname(os.path.abspath(__file__)), os.pardir, 'resources')
     filename = os.path.join(test_resources_dir, 'system.dic')
     with open(filename, 'r+b') as system_dic:
         bytes_ = mmap.mmap(system_dic.fileno(), 0, access=mmap.ACCESS_READ)
     header = DictionaryHeader.from_bytes(bytes_, 0)
     if header.version != SYSTEM_DICT_VERSION:
         raise Exception('invalid system dictionary')
     self.lexicon = DoubleArrayLexicon(bytes_, header.storage_size() + 470)