Ejemplo n.º 1
0
 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]))
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
    def test_simple_segment_cross(self):
        "simple cross-dialogue"
        src = self.edu1_1
        tgt = self.edu2_1
        rel = FakeRelInst('r', src, tgt)

        doc = FakeDocument(self.edus1, [rel], [])
        contexts = Context.for_edus(doc)
        cp = doc.copies
        self.assertTrue(is_cross_dialogue(contexts)(cp[rel]))
Ejemplo n.º 8
0
    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]))
Ejemplo n.º 9
0
    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]))
Ejemplo n.º 10
0
    def test_innocent(self):
        "no squawking on in-dialogue relation"
        src = self.edu1_1
        tgt = self.edu1_2
        rel = FakeRelInst('r', src, tgt)

        doc = FakeDocument(self.edus1, [rel], [])
        contexts = Context.for_edus(doc)
        cp = doc.copies
        self.assertTrue(stac.is_edu(cp[src]))
        self.assertTrue(stac.is_edu(cp[rel].source))
        self.assertFalse(is_cross_dialogue(contexts)(cp[rel]))
Ejemplo n.º 11
0
    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]))