From fafe0e26c32b933dbdf4407794b9c333bfb98fb8 Mon Sep 17 00:00:00 2001 From: daxid <david.rouquet@tetras-libre.fr> Date: Fri, 17 Mar 2023 13:30:24 +0000 Subject: [PATCH] Functional demo with nice looking --- selfContainedDemo.ipynb | 75 +++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/selfContainedDemo.ipynb b/selfContainedDemo.ipynb index e5d0d28..ef04eb2 100644 --- a/selfContainedDemo.ipynb +++ b/selfContainedDemo.ipynb @@ -28,19 +28,19 @@ "from dash.dependencies import Input, Output, State\n", "import base64\n", "\n", - "AMR_BATCH_PATH = \"/opt/dashboards/TetrasMARS/amrbatch/\"\n", + "AMR_BATCH_PATH = \"/opt/lib/TetrasMARS/amrbatch/\"\n", "sys.path.insert(0, os.path.abspath(AMR_BATCH_PATH))\n", "import amrbatch\n", "\n", - "TENET_PATH = \"/opt/dashboards/TetrasMARS/tenet/\"\n", + "TENET_PATH = \"/opt/lib/TetrasMARS/tenet/\"\n", "sys.path.insert(0, os.path.abspath(TENET_PATH))\n", "import tenet\n", "\n", - "AMR_MODEL_PATH=\"/opt/dashboards/TetrasMARS/corpus/cm-tool/amrModel/model_parse_xfm_bart_large-v0_1_0\"\n", + "AMR_MODEL_PATH=\"/opt/lib/TetrasMARS/corpus/cm-tool/amrModel/model_parse_xfm_bart_large-v0_1_0\"\n", "MEDIA_PATH = \"/opt/dashboards/media/17/\"\n", "MEDIA_URL = \"https://unsel.tetras-lab.io/dashboard/17/media/\"\n", - "ROOT_PATH = \"/opt/dashboards/TetrasMARS/tetras-mars-demo/\"\n", - "AMRLD_PATH = \"/opt/dashboards/TetrasMARS/tetras-mars-demo/lib/amrld/\"\n", + "ROOT_PATH = \"/opt/dashboards/TetrasMARS/tetras-mars-demo-prod/\"\n", + "AMRLD_PATH = \"/opt/lib/TetrasMARS/amrld/\"\n", "owl2vowlPath = '/opt/dashboards/tools/owl2vowl_0.3.7/owl2vowl.jar'\n", "WEBVOWL_PATH = '/opt/webvowl/'\n", "onto_prefix=\"ontologyTarget\"\n", @@ -207,6 +207,7 @@ "app = Dash(\n", " server_url=server_url, \n", " requests_pathname_prefix=base_path,\n", + " external_stylesheets=[dbc.themes.BOOTSTRAP]\n", ")\n", "##################################################################################################\n", "\n", @@ -220,23 +221,26 @@ "##################################################################################################\n", "\n", "app.layout = html.Div([\n", - " \"Enter an english text and click on the button bellow to construct an ontology.\",\n", + " html.H4(\"Enter an english text and click on the button bellow to construct an ontology.\", style={'text-align': 'center'}),\n", " html.Br(),\n", - " \" You can then browse the results online or download them as a zip file.\",\n", + " html.P(\"It should take about 10 sec/sentence. You can then browse the results online or download them as a zip file.\", style={'text-align': 'center'}),\n", + " html.P(\"The text must be a simple succession of sentences. Fancy formating is not supported at the moment. \", style={'text-align': 'center'}), \n", " html.Br(),\n", " html.Br(),\n", - " dcc.Textarea(\n", + " html.Div(dbc.Textarea(\n", " id='textarea-state',\n", - " value='Jupiter is a gas giant. Earth is a rock planet.',\n", - " style={'width': '80%', 'height': 100},\n", + " value='Jupiter is a gas giant. Earth is a rock planet.',style={'width': '100%', 'height': 130}),\n", + " style={'width': '60%', 'height': 130, 'margin-left': 'auto', 'margin-right': 'auto'},\n", " ),\n", " html.Br(), html.Br(),\n", - " html.Button('Construct AMR graphs and ontology', id='textarea-state-button', n_clicks=0),\n", + " html.Div(\n", + " dbc.Button('Construct AMR graphs and ontology', id='textarea-state-button', n_clicks=0, outline=True, color=\"primary\"),\n", + " className=\"text-center\"),\n", " html.Br(),\n", - " html.A(children=\"\", href='', target=\"_blank\",id=\"download-link\"),\n", + " dcc.Loading(html.Div(html.A(children=\"\", href='', target=\"_blank\",id=\"download-link\"), className=\"text-center\")),\n", " html.Br(),\n", " html.Br(),\n", - " dcc.Loading(html.Div(id='my-output'), color='#A85431', style={\"verticalAlign\":\"top\"}),\n", + " dcc.Loading(html.Div(id='my-output'), type='circle'),\n", "])\n", "\n", "@app.callback(\n", @@ -253,31 +257,28 @@ " uuidDirPath, uuidZipUrl, webvowlFilePath = processStr(value)\n", " #show_svg(svgPath) \n", " #display(IFrame('''https://unsel.tetras-lab.io/webvowl/#{}\">'''.format(webvowlFilePath.replace(\"/opt/webvowl/\",\"\").replace(\".json\",\"\")),800,1200))\n", - " return [html.Div(\n", - " dbc.Accordion(\n", - " [\n", - " dbc.AccordionItem(\n", + " return [dbc.Row([dbc.Col(),\n", + " dbc.Col(dbc.Accordion( \n", + " [dbc.AccordionItem(\n", " [\n", - " \"You can click a class to see its instances in the right panel, they are not shown on the graph.\",\n", + " localImage2htmlImg(svgPath)\n", + " ],\n", + " title=\"AMR Graph for sentence \"+re.sub(r'.document.*', '', svgPath.replace(uuidDirPath+\"document-\",\"\")),\n", + " )\n", + " for svgPath in sorted(glob(uuidDirPath+\"document-*/*.svg\"))\n", + " ]+\n", + " [dbc.AccordionItem(\n", + " [\n", + " \"You can click a class to see its instances in the right panel, they are not shown in the graph.\",\n", + " html.Br(),\n", + " '''https://unsel.tetras-lab.io/webvowl/#{}'''.format(webvowlFilePath.replace(\"/opt/webvowl/\",\"\").replace(\".json\",\"\")),\n", " html.Br(),\n", " html.Iframe(src='''https://unsel.tetras-lab.io/webvowl/#{}'''.format(webvowlFilePath.replace(\"/opt/webvowl/\",\"\").replace(\".json\",\"\")),style={\"height\": \"800px\", \"width\": \"100%\"}),\n", " ],\n", - " title=\"Browse ontology\",\n", + " title=\"Browse ontology\", item_id='onto'\n", " )\n", - " ] \n", - " #+ [dbc.AccordionItem(\n", - " # [\n", - " # localImage2htmlImg(svgPath)\n", - " # ],\n", - " # title=\"AMR Graph\",\n", - " # )\n", - " # \n", - " # for svgPath in glob(uuidDirPath+\"document-*/*.svg\")\n", - " # ]\n", - " # \n", - " # ,\n", - " )\n", - "),\n", + " ] , active_item='onto'), width=10), dbc.Col()\n", + " ]),\n", " \"Download Zip File\", uuidZipUrl\n", " ]\n", "\n", @@ -297,14 +298,6 @@ " host=host, port=port, proxy=proxy, height=2000)\n", "##################################################################################################\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b1817beb-04b7-4e6f-9b82-675de76cf8af", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { -- GitLab