def post_treatment_with_numbers_fr(num, **kwargs): datas = Datas({}) doc = Document(datas, lang="fr") section = doc.new_section() section.text = section.tools.number(num, **kwargs) section.write() return section.html.xpath('//div')[0].text_content()
def iter_elem_with_post_treatment_fr(text_input, iter_const=None): datas = Datas({}) doc = Document(datas, lang="fr") section = doc.new_section() section.text = section.tools.iter_elems(text_input, iter_const) section.write() return section.html.xpath('//div')[0].text_content()
def test_nested_synonym(self, input): datas = Datas({}) doc = Document(datas, lang="fr") section = doc.new_section() section.text = section.tools.nlg_syn(section.tools.nlg_syn(input), section.tools.nlg_syn(input)) section.write() assert section.html.xpath('//div')[0].text_content() in input
def post_treatment_with_synonyms_fr(*text_input): datas = Datas({}) doc = Document(datas, lang="fr") section = doc.new_section() section.text = section.tools.synonym(*text_input) section.write() return section.html.xpath('//div')[0].text_content()
def test_synonym_freeze(self, input): datas = Datas({}) doc = Document(datas, lang="fr", freeze=True) section = doc.new_section() section.text = section.tools.nlg_syn(input) section.write() assert section.html.xpath('//div')[0].text_content() == input[0]
def test_synonym_random(self, input): datas = Datas({}) doc = Document(datas, lang="fr") section = doc.new_section() section.text = section.tools.synonym(input, mode="random") section.write() assert section.html.xpath('//div')[0].text_content() in input
def test_keyval(self, input, expected): datas = Datas({}) doc = Document(datas, lang="fr") section = doc.new_section() section.text = section.tools.nlg_syn(input) section.text = section.tools.post_eval("TEST_KEYVAL", "post", "") section.write() assert section.html.xpath('//div')[0].text_content() == expected
def test_multi_synonym_keyval(self): datas = Datas({}) doc = Document(datas, lang="fr") section = doc.new_section() syno1 = ("word", "TEST_1") syno2 = ("term", "TEST_2") section.text = section.tools.synonym(syno1, syno2) section.text = section.tools.post_eval("TEST_1", section.tools.synonym(syno2), section.tools.synonym(syno1)) section.write() expected_result = ["Word term", "Term word"] assert section.html.xpath('//div')[0].text_content() in expected_result
def test_document_css(self): datas = Datas({}) document = Document(datas, css_path="path/to/css") expected = "\n".join([ '<html>', '<head>', '<meta charset="utf-8">', '<title></title>', '<link rel="stylesheet" href="path/to/css">', '</head>', '<body><div id="text_area"></div></body>', '</html>\n', ]) assert str(document) == expected
def test_multi_synonym(self): datas = Datas({}) doc = Document(datas, lang="fr") section = doc.new_section() synos = ["word", "term", "note"] section.text = section.tools.synonym(synos) section.text = section.tools.synonym(synos) section.text = section.tools.synonym(synos) section.write() expected_output = [ "Word term note", "Word note term", "Note word term", "Note term word", "Term word note", "Term note word" ] assert section.html.xpath('//div')[0].text_content() in expected_output
def create_empty_section(): datas = Datas({}) document = Document(datas) return document, document.new_section()
def create_empty_doc(): datas = Datas({}) return Document(datas)