Section

Section #

The Section class is a text zone of your document independant with an independant NlgTools object. Synonyms drawing will be independant between sections. It is created from the Document class with the new_section method.
You can give a HTML tag name in parameter (by_default ‘div’) and HTML attributes.

my_datas = MyDatas(input)

document = Document(my_datas)

first_paragraph_section = document.new_section(html_elem_attr={"id": "firstParagraph"})
second_paragraph_section = document.new_section(html_elem_attr={"id": "secondParagraph"})

document.write()

The write method of your document will call write_text on each section in the document.

def write_section(self, section, parent_elem=None, parent_id=None)

You should not confuse a Section with a simple text zone.

If you want your first and second paragraph to be independant, you create sections like above.
If you just want to have two separates text zone in your document but without independancy on the synonyms, you create tags with the add_tag method (which is an alias of nlg_tags we saw earlier).

paragraph_section = document.new_section()

paragraph_section.text = (
  paragraph_section.tools.add_tag('div', id='first_paragraph', text='First paragraph text'),
  paragraph_section.tools.add_tag('div', id='two_paragraph', text='Second paragraph text')
)