Skip to content

Commit

Permalink
#21. upd
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Apr 17, 2022
1 parent f17e36d commit 210e8a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions examples/demo/wui.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ def cgi_output(data):


def prepare_template(data, text, bratUrl):
assert (isinstance(data, dict))

with open("index.tmpl", "r") as template_file:
template_local = template_file.read()

template_local = template_local.replace("$____COL_DATA_SEM____", json.dumps(data.get('coll_data_sem', '')))
template_local = template_local.replace("$____DOC_DATA_SEM____", json.dumps(data.get('doc_data_sem', '')))
template_local = template_local.replace("$____COL_DATA_SEM____", json.dumps(data.get('coll_data', '')))
template_local = template_local.replace("$____DOC_DATA_SEM____", json.dumps(data.get('doc_data', '')))

template_local = template_local.replace("$____TEXT____", text)
template_local = template_local.replace("$____BRAT_URL____", bratUrl)
Expand All @@ -38,7 +39,7 @@ def prepare_template(data, text, bratUrl):
text = inputData.getfirst("text")

if not text:
template = prepare_template(data={}, text="", bratUrl=bratUrl)
template = prepare_template(data={}, text="США вводит сакнции против РФ", bratUrl=bratUrl)
cgi_output(template)
exit(0)

Expand Down
7 changes: 4 additions & 3 deletions test/test_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ class TestDemo(unittest.TestCase):

@staticmethod
def __prepare_template(data, text, template_filepath):
assert(isinstance(data, dict))

with open(template_filepath, "r") as template_file:
template_local = template_file.read()

template_local = template_local.replace("$____COL_DATA_SEM____", json.dumps(data.get('coll_data_sem', '')))
template_local = template_local.replace("$____DOC_DATA_SEM____", json.dumps(data.get('doc_data_sem', '')))
template_local = template_local.replace("$____COL_DATA_SEM____", json.dumps(data.get('coll_data', '')))
template_local = template_local.replace("$____DOC_DATA_SEM____", json.dumps(data.get('doc_data', '')))
template_local = template_local.replace("$____TEXT____", text)

return template_local

def test_demo_rus_bert(self):
text = "сша вводит сакнции против рф"
text = "США вводит сакнции против РФ"
contents = demo_infer_texts_bert(
text=text,
output_dir=".",
Expand Down

0 comments on commit 210e8a9

Please sign in to comment.