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_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"]
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"]
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
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"]
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
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)
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
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
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"]
def setUpAll(self): self.words = [ 'this', 'is', 'my', 'matrix', 'test', 'collection', 'not', 'very', 'large', 'but', 'hoping' ] self.wstext = WStext(lingua="en")