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])
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])
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])
def setUp(self): self.l = Q.label("NP", exact=True)
def setUp(self): self.l = Q.label("NP")
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])
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])
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))
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])
def setUp(self): self.q = Q.text("foo") self.q_complex = Q.label("NP") & Q.idoms(Q.text("foo"))
def setUp(self): self.l = Q.label("XP") & Q.isprec(Q.label("YP")) self.l_oper = Q.label("XP") >> Q.label("YP")
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"))
def setUp(self): self.l = Q.label("NP") & Q.idoms(Q.label("N")) self.l_oper = Q.label("NP") ^ Q.label("N")
def setUp(self): self.l = Q.label("NP") & Q.doms(Q.label("N"))
def setUp(self): l = Q.label("NP") l2 = Q.dash_tag("FOO") self.a = l | l2