def test_connective(self): itm = p.Connective('also', p.SemClass(['Expansion', 'Conjunction'])) xml = x._Connective_xml(itm) self.assertEqual(itm, x._read_Connective(xml)) itm = p.Connective('also', p.SemClass(['Expansion', 'Conjunction']), p.SemClass(['Contingency', 'Cause', 'Result'])) xml = x._Connective_xml(itm) self.assertEqual(itm, x._read_Connective(xml))
def test_implicit_features_2(self): expected_conn1 = p.Connective( 'in particular', p.SemClass(['Expansion', 'Restatement', 'Specification'])) expected_conn2 = p.Connective( 'because', p.SemClass(['Contingency', 'Cause', 'Reason'])) expected_attr = p.Attribution('Wr', 'Comm', 'Null', 'Null') expected = p.ImplicitRelationFeatures(expected_attr, expected_conn1, expected_conn2) txt = ex_implicit_features self.assertParse(p._implicitRelationFeatures, expected, txt)
def test_implicit_features_1(self): expected_attr = p.Attribution('Wr', 'Comm', 'Null', 'Null') expected_conn = p.Connective('also', p.SemClass(['Expansion', 'Conjunction'])) expected = p.ImplicitRelationFeatures(expected_attr, expected_conn, None) txt = ex_implicit_attribution self.assertParse(p._implicitRelationFeatures, expected, txt)
def test_semclass(self): expected = 'Chosen alternative' txt = expected self.assertParse(p._SemanticClassWord, expected, txt) expected1 = p.SemClass( ['Expansion', 'Alternative', 'Chosen alternative']) expected = expected1 txt = 'Expansion.Alternative.Chosen alternative' self.assertParse(p._SemanticClass1, expected, txt) expected = (expected1, None) self.assertParse(p._semanticClass, expected, txt) expected2 = p.SemClass(['Contingency', 'Cause', 'Result']) expected = (expected1, expected2) txt = 'Expansion.Alternative.Chosen alternative, Contingency.Cause.Result' self.assertParse(p._semanticClass, expected, txt)
def _read_SemClass(attr): return ty.SemClass(attr.split('.'))
def test_connective(self): expected = p.Connective('also', p.SemClass(['Expansion', 'Conjunction'])) txt = 'also, Expansion.Conjunction' self.assertParse(p._conn1SemanticClass, expected, txt) self.assertParse(p._conn2SemanticClass, expected, txt)