Exemple #1
0
 def test_033(self):
     """ Page store/load - unicode - latin """
     page = Page(text="hāllo world, goodbye")
     page.store('files/tmp.txt')
     page._words = None
     page.load('files/tmp.txt')
     self.assertEqual(towords(page.words), ["hāllo", "world", "goodbye"])
     os.remove("files/tmp.txt")
     Page.ROMAN = True
     page = Page(text="québec")
     page.store('files/tmp.txt')
     page._words = None
     page.load('files/tmp.txt')
     Page.ROMAN = False
     self.assertEqual(towords(page.words), ["quebec"])
     os.remove("files/tmp.txt")
Exemple #2
0
 def test_026(self):
     """ Page overridden += : words is non-None """
     page = Page(text="hello")
     self.assertEqual(len(page), 1)
     page += "world"
     self.assertEqual(page.text, "hello world")
     self.assertEqual(len(page), 2)
Exemple #3
0
 def test_032(self):
     """ Page store/load """
     page = Page(text="hello world, goodbye")
     page.store('files/tmp.txt')
     page._words = None
     page.load('files/tmp.txt')
     os.remove("files/tmp.txt")
     self.assertEqual(towords(page.words), ["hello", "world", "goodbye"])
Exemple #4
0
 def test_034(self):
     """ Page - Bag of Words """
     page = Page(text="zoo castle zoo bird zoo bird")
     self.assertEqual(page.bagOfWords, {'zoo': 3, 'castle': 1, 'bird': 2})
Exemple #5
0
 def test_001(self):
     """ Page constructor - no parameters """
     page = Page()
     self.assertEqual(page.path, None)
     self.assertEqual(page.text, None)
     self.assertEqual(page.words, None)
Exemple #6
0
 def test_031(self):
     """ Page number """
     page = Page("files/test.txt")
     self.assertEqual(page.pageno, None)
     page = Page("files/test.txt", pageno=2)
     self.assertEqual(page.pageno, 2)