def promote_to_string(s): """Convert non-nlglib classes (e.g., str) to String and return.""" if not s: return String('') if isinstance(s, (Document, Element, RhetRel, MsgSpec)): return s return String(s)
def test_elements(self): expected = [ String('Title'), Document('Section 1', 'para 1', 'para 2'), Document('Section 2', 'para 3', 'para 4') ] self.assertEqual(expected, list(self.doc.elements()))
def test_repr(self): expected = """<Document: (Title) <Document: (Section 1) String('para 1') String('para 2')> <Document: (Section 2) String('para 3') String('para 4')>>""" self.assertEqual(expected, repr(self.doc))
def value_for(self, _): return String(self.text)