Skip to content

Commit

Permalink
Add test case load model file that does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
bact committed Aug 23, 2020
1 parent 83eee2e commit aad2507
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tests/test_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,19 @@ def test_perceptron_tagger(self):
[("เม่น", "N"), ("กิน", "V")],
[("หนอน", "N"), ("กิน", "V")],
]
tagger.train(data, save_loc="temp.pkl")
self.assertTrue(path.exists("temp.pkl"))
self.assertEqual(len(tagger.tag(["นก", "เดิน"])), 2)
filename = "ptagger_temp4XcDf.pkl"
tagger.train(data, save_loc=filename)
self.assertTrue(path.exists(filename))

words = ["นก", "เดิน"]
word_tags = tagger.tag(words)
self.assertEqual(len(words), len(word_tags))

words2, _ = zip(*word_tags)
self.assertEqual(words, list(words2))

with self.assertRaises(IOError):
tagger.load("ptagger_notexistX4AcOcX.pkl") # file does not exist

# ### pythainlp.tag.locations

Expand Down

0 comments on commit aad2507

Please sign in to comment.