def test_cross_puncture(self, enclose=False): "c1[e1.1 e1.2] c2[e1.3]; e1.3 -> e1.2 (puncture)" c1 = FakeCDU('c1', [self.edu1_1, self.edu1_2]) c2 = FakeCDU('c2', [self.edu1_3]) r = FakeRelInst('r', self.edu1_3, self.edu1_2) cdus = self.enclose(c2, c1, [c1, c2], enclose) doc = FakeDocument(self.edus1, [r], cdus) self.assertPunctured(doc, r)
def test_double_dangler(self, enclose=False): """ Danglers can poke out of multiple CDUs """ c1 = FakeCDU('c1', [self.edu1_1, self.edu1_2]) c2 = FakeCDU('c2', [c1]) r = FakeRelInst('r', self.edu1_2, self.edu1_3) cdus = self.enclose(c2, self.edu1_3, [c1, c2], enclose) doc = FakeDocument(self.edus1, [r], cdus) self.assertIntact(doc, r)
def test_cdu_chain(self): "containment chain: c2[c1[e1.1 e1.2]]" c1 = FakeCDU('c1', [self.edu1_1, self.edu1_2]) c2 = FakeCDU('c2', [self.edu1_3, c1]) doc = FakeDocument(self.edus1, [], [c1, c2]) g = self.mk_graph(doc) ids = graph_ids(g) def get_id(x): "anno id as seen by the graph" return g.mirror(ids[x.local_id()]) mark = self.edu1_2.local_id() self.assertEqual([get_id(y) for y in [c1, c2]], g.containing_cdu_chain(ids[mark]))
def test_non_puncture(self, enclose=False): "c1[e1.1 1.2] -> e1.3 (non-puncture)" c1 = FakeCDU('c1', [self.edu1_1, self.edu1_2]) r = FakeRelInst('r', c1, self.edu1_3) cdus = self.enclose(c1, self.edu1_3, [c1], enclose) doc = FakeDocument(self.edus1, [r], cdus) self.assertIntact(doc, r)
def enclose(du1, du2, cdus, noop=True): "wrap these two DUs in a CDU; return expanded CDU list" if noop: return cdus cdus2 = copy.copy(cdus) cdus2.append(FakeCDU('cw', [du1, du2])) return cdus2
def test_cdu_itself_cross(self): "naughty: CDU spanning dialogues" cdu = FakeCDU('c1', [self.edu1_1, self.edu2_1]) doc = FakeDocument(self.edus1, [], [cdu]) contexts = Context.for_edus(doc) cp = doc.copies self.assertTrue(is_cross_dialogue(contexts)(cp[cdu]))
def test_simple_puncture(self, enclose=False): "c1[e1.1 e1.2]; e1.3 -> e1.2 (puncture)" c1 = FakeCDU('c1', [self.edu1_1, self.edu1_2]) r = FakeRelInst('r', self.edu1_3, self.edu1_2) cdus = self.enclose(self.edu1_3, c1, [c1], enclose) doc = FakeDocument(self.edus1, [r], cdus) self.assertPunctured(doc, r)
def test_simple_dangler(self, enclose=False): """ Danglers are not treated as punctures """ c1 = FakeCDU('c1', [self.edu1_1, self.edu1_2]) r = FakeRelInst('r', self.edu1_2, self.edu1_3) cdus = self.enclose(c1, self.edu1_3, [c1], enclose) doc = FakeDocument(self.edus1, [r], cdus) self.assertIntact(doc, r)
def test_cdu_cross(self): "naughty: rel to CDU in another dialogue" cdu = FakeCDU('c1', [self.edu1_1, self.edu1_2]) src = cdu tgt = self.edu2_1 rel = FakeRelInst('r', src, tgt) doc = FakeDocument(self.edus1, [rel], [cdu]) contexts = Context.for_edus(doc) cp = doc.copies self.assertTrue(is_cross_dialogue(contexts)(cp[rel]))
def test_innocent_cdu(self): "innocent: CDU entirely in dialogue" cdu = FakeCDU('c1', [self.edu1_1, self.edu1_2]) src = cdu tgt = self.edu1_3 rel = FakeRelInst('r', src, tgt) doc = FakeDocument(self.edus1, [rel], [cdu]) contexts = Context.for_edus(doc) cp = doc.copies self.assertFalse(is_cross_dialogue(contexts)(cp[rel])) self.assertFalse(is_cross_dialogue(contexts)(cp[cdu]))