示例#1
0
    def test_glossary(self):
        txt = random_usl(Text)
        self.assertTrue(all(t.script in Dictionary() for t in txt.words))
        self.assertTrue(all(t in txt for t in txt.words))

        with self.assertRaises(ValueError):
            'test' in txt
示例#2
0
    def test_random(self):
        r = RandomPoolIEMLObjectGenerator(level=Fact)
        s = r.fact()
        p = path("s+a+m + (s+a+m):(r+f)")
        elems = resolve(s, p)
        self.assertSetEqual(elems, s.topics.union(s.words))

        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, p)
        self.assertSetEqual(
            usl.facts.union(usl.topics).union(usl.words).union(usl.theories),
            elems)
示例#3
0
 def test_translation(self):
     u = random_usl(rank_type=Text)
     t = u.auto_translation()
     self.assertIn('fr', t)
     self.assertIn('en', t)
示例#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])
示例#5
0
    def test_random_usl(self):
        u = random_usl()
        self.assertIsInstance(u, Usl)

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