diff --git a/selfContainedDemo.ipynb b/selfContainedDemo.ipynb index 537f971db8b4d3c11c2b117807063df1c8854648..4067d508325e4410bcfcfc3f9c3b54690d1c7c90 100644 --- a/selfContainedDemo.ipynb +++ b/selfContainedDemo.ipynb @@ -146,21 +146,28 @@ " uuidZipUrl = MEDIA_URL+uuidStr+\".zip\"\n", " \n", " # Generate an AMR graph by sentence in a subfolder (with companion files such as images of the graphs)\n", - " amr_graph_list = amrbatch.parse_document_string_to_produce_amr_graph(\n", + " try: \n", + " amr_graph_list = amrbatch.parse_document_string_to_produce_amr_graph(\n", " input, None, amr_model_path=AMR_MODEL_PATH, output_dirpath=uuidDirPath, \n", " amrld_serialization=True)\n", + " except:\n", + " errorStr = \"Error generating AMR graphs. You can try a simpler input. Sorry :(\"\n", " \n", " # Construct ontologies from each AMR graph plus a \"full\" one that is the union\n", - " factoids = tenet.create_ontology_from_amrld_dir(\n", + " try:\n", + " factoids = tenet.create_ontology_from_amrld_dir(\n", " uuidDirPath,\n", " onto_prefix=\"http://ontologies\",\n", " out_file_path=fullOntoPath,\n", " technical_dir_path=ontoBySentencePath)\n", + " owl2vowl(fullOntoPath, webvowlFileName, webvowlFilePath, uuid=uuidStr)\n", + " errorStr = \"\"\n", + " except:\n", + " errorStr = \"Error generating ontology. You can still clic this link to download AMR graphs or see them below. Try a simpler input, sorry :(\"\n", " \n", " # Create a zip file so the user can download all generated files\n", - " owl2vowl(fullOntoPath, webvowlFileName, webvowlFilePath, uuid=uuidStr)\n", " shutil.make_archive(uuidZipPath, 'zip', uuidDirPath)\n", - " return uuidDirPath, uuidZipUrl, webvowlFilePath" + " return uuidDirPath, uuidZipUrl, webvowlFilePath, errorStr" ] }, { @@ -262,7 +269,11 @@ ")\n", "def update_output(n_clicks, value):\n", " if n_clicks > 0:\n", - " uuidDirPath, uuidZipUrl, webvowlFilePath = processStr(value)\n", + " uuidDirPath, uuidZipUrl, webvowlFilePath, errorStr = processStr(value)\n", + " if \"Error\" in errorStr:\n", + " feedbackStr = errorStr\n", + " else:\n", + " feedbackStr = \"Download Zip File\"\n", " #show_svg(svgPath) \n", " #display(IFrame('''https://unsel.tetras-lab.io/webvowl/#{}\">'''.format(webvowlFilePath.replace(\"/opt/webvowl/\",\"\").replace(\".json\",\"\")),800,1200))\n", " return [dbc.Row([dbc.Col(),\n", @@ -287,7 +298,7 @@ " )\n", " ] , active_item='onto'), width=10), dbc.Col()\n", " ]),\n", - " \"Download Zip File\", uuidZipUrl\n", + " feedbackStr, uuidZipUrl\n", " ]\n", "\n", "#@app.callback(\n",