Exemple #1
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
Exemple #2
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"]
Exemple #3
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"]
Exemple #4
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
Exemple #5
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"]
Exemple #6
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
Exemple #7
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        
Exemple #8
0
class u_WSlang(libpry.AutoTree):
    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        
        
    def test_loadfile(self):
        self.wstext.setWordlist(self.lines)
        lineswordcount = 0
        for line in self.lines:
            for word in line:
                lineswordcount += 1
        assert lineswordcount > len(self.wstext.wordlist)
Exemple #9
0
class u_WSlang(libpry.AutoTree):
    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

    def test_loadfile(self):
        self.wstext.setWordlist(self.lines)
        lineswordcount = 0
        for line in self.lines:
            for word in line:
                lineswordcount += 1
        assert lineswordcount > len(self.wstext.wordlist)
Exemple #10
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
Exemple #11
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
Exemple #12
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"]
Exemple #13
0
 def setUpAll(self):
     self.words = [
         'this', 'is', 'my', 'matrix', 'test', 'collection', 'not', 'very',
         'large', 'but', 'hoping'
     ]
     self.wstext = WStext(lingua="en")