def test_saveAsText_and_loadFromText(self): """ `Dictionary` can be saved as textfile and loaded again from textfile. """ tmpf = get_tmpfile('dict_test.txt') d = Dictionary(self.texts) d.saveAsText(tmpf) # does the file exists self.assertTrue(os.path.exists(tmpf)) d_loaded = Dictionary.loadFromText(get_tmpfile('dict_test.txt')) self.assertNotEqual(d_loaded, None) self.assertEqual(d_loaded.token2id, d.token2id)
def test_saveAsText_and_loadFromText(self): """ `Dictionary` can be saved as textfile and loaded again from textfile. """ tmpf = get_tmpfile("dict_test.txt") d = Dictionary(self.texts) d.saveAsText(tmpf) # does the file exists self.assertTrue(os.path.exists(tmpf)) d_loaded = Dictionary.loadFromText(get_tmpfile("dict_test.txt")) self.assertNotEqual(d_loaded, None) self.assertEqual(d_loaded.token2id, d.token2id)