Esempio n. 1
0
 def test_label(self):
     l = Q.label("NP")
     c = self.d.engine.connect()
     res = c.execute(l.sql(self.d).order_by(self.d.nodes.c.rowid)).fetchall()
     self.assertEqual(len(res), 3)
     self.assertEqual(self.d._reconstitute(res[0][0]), self.d[0][0])
     self.assertEqual(self.d._reconstitute(res[1][0]), self.d[0][2])
     self.assertEqual(self.d._reconstitute(res[2][0]), self.d[0][3][1])
Esempio n. 2
0
    def test_and(self):
        l = Q.dash_tag("ACC")
        l2 = Q.label("NP")
        both = l & l2

        c = self.d.engine.connect()
        res = c.execute(both.sql(self.d)).fetchall()
        self.assertEqual(len(res), 1)
        self.assertEqual(self.d._reconstitute(res[0][0]), self.d[0][2])
Esempio n. 3
0
    def test_or(self):
        l = Q.dash_tag("X")
        l2 = Q.label("NP")
        both = l | l2

        c = self.d.engine.connect()
        res = c.execute(both.sql(self.d).order_by(self.d.nodes.c.rowid)).fetchall()
        self.assertEqual(len(res), 4)
        self.assertEqual(self.d._reconstitute(res[0][0]), self.d[0][0])
        self.assertEqual(self.d._reconstitute(res[1][0]), self.d[0][2])
        self.assertEqual(self.d._reconstitute(res[2][0]), self.d[0][3])
        self.assertEqual(self.d._reconstitute(res[3][0]), self.d[0][3][1])
Esempio n. 4
0
 def setUp(self):
     self.l = Q.label("NP", exact=True)
Esempio n. 5
0
 def setUp(self):
     self.l = Q.label("NP")
Esempio n. 6
0
 def test_daughter_and(self):
     dq = Q.idoms(Q.label("NP")) & Q.idoms(Q.label("VBD"))
     c = self.d.engine.connect()
     res = c.execute(dq.sql(self.d)).fetchall()
     self.assertEqual(len(res), 1)
     self.assertEqual(self.d._reconstitute(res[0][0]), self.d[0])
Esempio n. 7
0
 def test_daugher(self):
     dq = Q.idoms(Q.label("ADJ"))
     c = self.d.engine.connect()
     res = c.execute(dq.sql(self.d).order_by(self.d.dom.c.parent)).fetchall()
     self.assertEqual(len(res), 1)
     self.assertEqual(self.d._reconstitute(res[0][0]), self.d[0][2])
Esempio n. 8
0
    def test_label_misc(self):
        l = Q.label(re.compile("foo"))
        self.assertRaises(Exception, lambda: l.sql(None))

        l = Q.label("NP%")
        self.assertRaises(Exception, lambda: l.sql(None))
Esempio n. 9
0
 def test_label_exact(self):
     l = Q.label("NP", exact=True)
     c = self.d.engine.connect()
     res = c.execute(l.sql(self.d).order_by(self.d.nodes.c.rowid)).fetchall()
     self.assertEqual(len(res), 1)
     self.assertEqual(self.d._reconstitute(res[0][0]), self.d[0][0])
Esempio n. 10
0
 def setUp(self):
     self.q = Q.text("foo")
     self.q_complex = Q.label("NP") & Q.idoms(Q.text("foo"))
Esempio n. 11
0
 def setUp(self):
     self.l = Q.label("XP") & Q.isprec(Q.label("YP"))
     self.l_oper = Q.label("XP") >> Q.label("YP")
Esempio n. 12
0
 def setUp(self):
     self.l = Q.label("XP") & Q.sprec(Q.label("YP"))
     self.l_oper = Q.label("XP") > Q.label("YP")
     self.l_oper_tuple = Q.label("XP") > (Q.label("YP"), Q.label("ZP"))
Esempio n. 13
0
 def setUp(self):
     self.l = Q.label("NP") & Q.idoms(Q.label("N"))
     self.l_oper = Q.label("NP") ^ Q.label("N")
Esempio n. 14
0
 def setUp(self):
     self.l = Q.label("NP") & Q.doms(Q.label("N"))
Esempio n. 15
0
 def setUp(self):
     l = Q.label("NP")
     l2 = Q.dash_tag("FOO")
     self.a = l | l2