示例#1
0
    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)
示例#2
0
 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'})
示例#3
0
 def test_empty_text(self):
     x = model.words_from_text("")
     self.failUnlessEqual(x, set())
示例#4
0
 def test_duplicates(self):
     x = model.words_from_text("A A A B C")
     self.failUnlessEqual(x, {"A", "B", "C"})
示例#5
0
 def test_char_only(self):
     x = model.words_from_text("!.%)(%/&(/!§)=)")
     self.failUnlessEqual(x, set())