コード例 #1
0
 def test_sanitize_sortbysize(self):
     wordlist = ["word", "is", "his", "short"]
     expect = ["short", "word", "his", "is"]
     test = WStext(wordlist, maxlength=11)
     answer = test.sanitize_sortbysize(wordlist)
     assert answer == expect
     wordlist = ["longing", "notshorter"]
     expect = ["notshorter", "longing"]
     test = WStext(wordlist, 11)
     answer = test.sanitize_sortbysize(wordlist)
     assert answer == expect
コード例 #2
0
 def test_sanitize_nosubwords(self):
     wordlist = ["short", "word", "is", "his"]
     expect = ["short", "word", "his"]
     reject = []
     test = WStext(wordlist, maxlength=11)
     good, bad = test.sanitize_nosubwords(wordlist, reject)
     assert good == expect
     assert bad == ["is"]
     wordlist = ["short", "notshorter", "longing", "long", "verylongword"]
     expect = ["notshorter", "longing", "verylongword"]
     reject = []
     test = WStext(wordlist)
     good, bad = test.sanitize_nosubwords(wordlist, reject)
     assert good == expect
     assert bad == ["short", "long"]
コード例 #3
0
 def test_sanitize_length(self):
     wordlist = ["short", "notshorter", "longing", "verylongword"]
     expect = ["notshorter", "longing"]
     expectreject = ["verylongword", "short"]
     test = WStext(wordlist, maxlength=11)
     assert test.wordlist == expect
     assert test.wordlist_rejected == expectreject
コード例 #4
0
 def setUpAll(self):
     self.wsstreamio = WSstreamIO()
     self.wstext = WStext()
     self.wstext.setLanguage('to')
     fh = self.wsstreamio.open('unicode.txt')
     self.wsstreamio.load(fh)
     self.lines = self.wsstreamio.lines
     self.originalEncoding = self.wsstreamio.originalEncoding
コード例 #5
0
 def test_sanitize_words(self):
     wordlist = ["word", "is", "his", "short"]
     expect = ["short", "word", "his"]
     reject = []
     test = WStext(wordlist, maxlength=11)
     good, bad = test.sanitize_words(wordlist, maxlength=11)
     assert good == expect
     assert bad == ["is"]
コード例 #6
0
 def test_sanitize_content(self):
     wordlist = ["short", "not6shorter", "longing", "verylongword"]
     expect = ["longing", "shorter", "not"]
     rejected = ["short", "verylongword"]
     test = WStext(wordlist, maxlength=11, lingua="en")
     for word in expect:
         assert word in test.wordlist
     for word in rejected:
         assert word in test.wordlist_rejected
コード例 #7
0
 def setUpAll(self):
     self.words = [
         'this', 'is', 'my', 'matrix', 'test', 'collection', 'not', 'very',
         'large', 'but', 'hoping'
     ]
     self.wstext = WStext(lingua="en")