Exemplo n.º 1
0
    def test_glossary(self):
        txt = random_usl(Text)
        self.assertTrue(all(t in Dictionary() for t in txt.glossary))
        self.assertTrue(all(t in txt for t in txt.glossary))

        with self.assertRaises(ValueError):
            'test' in txt
Exemplo n.º 2
0
    def test_random(self):
        r = RandomPoolIEMLObjectGenerator(level=Sentence)
        s = r.sentence()
        p = path("s+a+m + (s+a+m):(r+f)")
        elems = resolve(s, p)
        self.assertSetEqual(
            elems,
            {p
             for p in s.tree_iter() if isinstance(p, (Word, Morpheme))})

        p = path("t + t:(s+a+m+r+f+(s+a+m):(s+a+m+r+f+(s+a+m):(r+f)))")
        usl = random_usl(rank_type=Text)
        elems = resolve(usl.ieml_object, p)
        self.assertSetEqual(
            set(e for e in usl.ieml_object.tree_iter()
                if not isinstance(e, (Text, SuperClause, Clause, SyntaxTerm))),
            elems)
Exemplo n.º 3
0
 def test_translation(self):
     u = random_usl(rank_type=Text)
     t = u.auto_translation()
     self.assertIn('fr', t)
     self.assertIn('en', t)
Exemplo n.º 4
0
 def test_deference_path(self):
     u = random_usl(rank_type=Text)
     p = random.sample(tuple(u.paths.items()), 1)
     self.assertEqual(u[p[0][0]], p[0][1])
Exemplo n.º 5
0
    def test_random_usl(self):
        u = random_usl()
        self.assertIsInstance(u, Usl)

        u = random_usl(rank_type=Word)
        self.assertIsInstance(u.ieml_object, Word)