def push_show_missing_vocabulary(self): root = self.root # get missing vocabulary text = self.latintext.get(1.0, 'end') text = model.words_from_text(text) vocabs = self.vocabstext.get(1.0, 'end') vocabs = model.words_from_text(vocabs) endings = self.load_endings() # abort here if no endings are defined if not endings: return t0 = time.clock() missing = model.missing_vocabulary(text, vocabs, endings) t = time.clock() - t0 # GUI rw = Toplevel(root) rw.title('Ergebnis') result_text = Text(rw, TEXT_SETTINGS, width=30) result_scroll = Scrollbar(rw) result_text.configure(yscrollcommand=result_scroll.set) result_scroll.configure(command=result_text.yview) result_scroll.pack(side=RIGHT, fill=Y) result_text.pack(side=LEFT, fill=BOTH, expand=1) # show in textfield result_text.insert(END, 'Unbekannte Vokabeln:\n\n') if missing: for vocab in missing: result_text.insert(END, vocab + '\n') else: result_text.insert(END, 'Keine unbekannten Vokabeln') result_text.insert(END, '\nErmittelt in %.4fs' % t)
def test_parsing(self): x = model.words_from_text("!Abc &§$def,gh iL..m\r\n\tx") self.failUnlessEqual(x, {'Abc', 'def', 'gh', 'iL', 'm', 'x'})
def test_empty_text(self): x = model.words_from_text("") self.failUnlessEqual(x, set())
def test_duplicates(self): x = model.words_from_text("A A A B C") self.failUnlessEqual(x, {"A", "B", "C"})
def test_char_only(self): x = model.words_from_text("!.%)(%/&(/!§)=)") self.failUnlessEqual(x, set())