Example #1
0
   def test_loaded_equals_saved(self):
      'Test that words loaded from a file match those saved'

      saveWords(self.file, self.sample)

      self.assertEqual(self.sample, loadWords(self.file))
      os.remove(self.file)
Example #2
0
def bookToWords(bookPath, wordsPath):
   '''
   Read a file with text (a book) and 
   write out the vocabulary into a file of JSON.
   '''

   words = openBook(bookPath)
   uwords = uniqueWords(words)
   saveWords(wordsPath, uwords)