Exemple #1
0
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)
Exemple #2
0
 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()))
Exemple #3
0
    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))
Exemple #4
0
 def value_for(self, _):
     return String(self.text)