Ejemplo n.º 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)
Ejemplo n.º 2
0
 def test_only_words(self):
     x = model.missing_vocabulary({"a", "b", "c", "d"}, set(), set())
     self.failUnlessEqual(x, {"a", "b", "c", "d"})
Ejemplo n.º 3
0
 def test_empty_basicforms(self):
     x = model.missing_vocabulary({"a", "b", "c", "d"}, set(), {"a", "b"})
     self.failUnlessEqual(x, {"a", "b", "c", "d"})
Ejemplo n.º 4
0
 def test_empty_endings(self):
     x = model.missing_vocabulary({"a", "b", "c", "d"}, {"c", "d"}, set())
     self.failUnlessEqual(x, {"a", "b"})
Ejemplo n.º 5
0
 def test_basic_case(self):
     x = model.missing_vocabulary(
         {"A1", "A2", "A3"}, {"A", "B"}, {"1", "2"})
     self.failUnlessEqual(x, {'a3'})
Ejemplo n.º 6
0
 def test_empty_words(self):
     x = model.missing_vocabulary(set(), {"a", "b"}, {"1", "2"})
     self.failUnlessEqual(x, set())
Ejemplo n.º 7
0
 def test_basic(self):
     x = model.missing_vocabulary(
         {"a1", "a2", "a3"}, {"a", "b"}, {"1", "2"})
     self.failUnlessEqual(x, {"a3"})
Ejemplo n.º 8
0
 def test_word_is_in_vocab(self):
     x = model.missing_vocabulary({"xxx", "yyy"}, {"xxx", "yyy"}, set())
     self.failUnlessEqual(x, set())
Ejemplo n.º 9
0
 def test_empty_args(self):
     x = model.missing_vocabulary(set(), set(), set())
     self.failUnlessEqual(x, set())
Ejemplo n.º 10
0
 def test_words_and_endings(self):
     x = model.missing_vocabulary({"a", "b", "c", "d"}, set(), {"c", "d"})
     self.failUnlessEqual(x, {"a", "b", "c", "d"})
Ejemplo n.º 11
0
 def test_words_and_basicforms(self):
     x = model.missing_vocabulary({"a", "b", "c", "d"}, {"a", "b"}, set())
     self.failUnlessEqual(x, {"c", "d"})