Ejemplo n.º 1
0
 def test_word_storage_put_existing(self):
     """existing word is not added to storage"""
     word_storage = WordStorage()
     word = 'word'
     word_storage.storage = {'word': 1}
     word_storage.put(word)
     self.assertEqual(word_storage.storage, {'word': 1})
Ejemplo n.º 2
0
 def test_word_storage_from_corpus_duplicates(self):
     """ideal case for get_id_of"""
     word_storage = WordStorage()
     sentence = ('<s>', 'mary', 'wanted', 'to', 'to', 'swim', '</s>')
     word_storage.from_corpus(sentence)
     self.assertEqual(len(word_storage.storage), 6)
Ejemplo n.º 3
0
 def test_word_storage_get_original_id_not_num(self):
     """ideal case for get_id_of"""
     word_storage = WordStorage()
     word_storage.storage = {'word': 1}
     self.assertEqual(word_storage.get_original_by(None), 'UNK')
Ejemplo n.º 4
0
 def test_word_storage_get_original_by_not_in_storage(self):
     """id not in storage get_original_by"""
     word_storage = WordStorage()
     word_storage.storage = {'word': 1}
     self.assertEqual(word_storage.get_original_by(2), 'UNK')
Ejemplo n.º 5
0
 def test_word_storage_get_original_by_ideal(self):
     """ideal case for get_original_by"""
     word_storage = WordStorage()
     word_storage.storage = {'word': 1}
     self.assertEqual(word_storage.get_original_by(1), 'word')
Ejemplo n.º 6
0
 def test_word_storage_get_id_of_word_not_in_storage(self):
     """word not in storage"""
     word_storage = WordStorage()
     word_storage.storage = {'word': 1}
     self.assertEqual(word_storage.get_id_of('another'), -1)
Ejemplo n.º 7
0
 def test_word_storage_get_id_of_not_str(self):
     """id is not str  get_id_of"""
     word_storage = WordStorage()
     word_storage.storage = {'word': 1}
     self.assertEqual(word_storage.get_id_of(123), -1)
Ejemplo n.º 8
0
 def test_word_storage_get_id_of_none(self):
     """get_id_of none"""
     word_storage = WordStorage()
     word_storage.storage = {'word': 1}
     self.assertEqual(word_storage.get_id_of(None), -1)
Ejemplo n.º 9
0
 def test_word_storage_get_id_of_ideal(self):
     """ideal case for get_id_of"""
     word_storage = WordStorage()
     word_storage.storage = {'word': 1}
     self.assertEqual(word_storage.get_id_of('word'), 1)
Ejemplo n.º 10
0
 def test_word_storage_put_word_not_str(self):
     """non string word is not added to storage"""
     word_storage = WordStorage()
     word = 123
     word_storage.put(word)
     self.assertEqual(word_storage.storage, {})
Ejemplo n.º 11
0
 def test_word_storage_put_word_none(self):
     """none is not added to storage"""
     word_storage = WordStorage()
     word = None
     word_storage.put(word)
     self.assertEqual(word_storage.storage, {})
Ejemplo n.º 12
0
 def test_word_storage_put_ideal(self):
     """word is added to storage"""
     word_storage = WordStorage()
     word = 'word'
     num = word_storage.put(word)
     self.assertEqual(word_storage.storage[word], num)
Ejemplo n.º 13
0
 def test_word_storage_from_corpus_not_tuple(self):
     """ideal case for get_id_of"""
     word_storage = WordStorage()
     sentence = 'Mary wanted to swim'
     word_storage.from_corpus(sentence)
     self.assertEqual(word_storage.storage, {})
Ejemplo n.º 14
0
 def test_word_storage_from_corpus_none(self):
     """ideal case for get_id_of"""
     word_storage = WordStorage()
     sentence = None
     word_storage.from_corpus(sentence)
     self.assertEqual(word_storage.storage, {})