diff --git a/src/app/app.py b/src/app/app.py index f9367091b216db90228cd9db81e6f6b4d0960603..972bb23c0ca863772f2c9a801f4233b1ec9ce0e7 100644 --- a/src/app/app.py +++ b/src/app/app.py @@ -53,27 +53,27 @@ def convertUnl(unl, outputs): # Handle rdf output if any if 'rdf' in outputs: - fname = '{}/{}.ttl'.format(out_dir, out_name) - with open(fname, 'r') as f: - res['rdf'] = f.read() try: + fname = '{}/{}.ttl'.format(out_dir, out_name) + with open(fname, 'r') as f: + res['rdf'] = f.read() os.remove(fname) except FileNotFoundError: - pass + res['rdf'] = 'Error : no ttl file' # Handle dot output if any if 'dot' in outputs: - fname = '{}/{}.dot'.format(out_dir, out_name) - cmd = ['dot', '-Tsvg', fname] - with Popen(cmd, stdout=PIPE, stderr=PIPE) as p: - p.wait() - if p.returncode != 0: - res['error'] += "Dot: \n\n"+p.stderr.read().decode() - else: - res['dot'] = p.stdout.read().decode() try: - os.remove(fname) + fname = '{}/{}.dot'.format(out_dir, out_name) + cmd = ['dot', '-Tsvg', fname] + with Popen(cmd, stdout=PIPE, stderr=PIPE) as p: + p.wait() + if p.returncode != 0: + res['error'] += "Dot: \n\n"+p.stderr.read().decode() + else: + res['dot'] = p.stdout.read().decode() + os.remove(fname) except FileNotFoundError: - pass + res['dot'] = 'Error : no dot file' return res diff --git a/src/app/templates/unl2rdf.html b/src/app/templates/unl2rdf.html index a5e33ff1a6f26cbc0948216b33acf4d2756a37d5..d28a94519a8f64fa5b600b24c9d65fd768a2aa55 100644 --- a/src/app/templates/unl2rdf.html +++ b/src/app/templates/unl2rdf.html @@ -5,7 +5,43 @@ <div class="form-group"> <form action="{{request.path}}" method="POST"> <h2>Enter some UNL here I will convert it for you</h2> - <textarea class="form-control" name="unl" cols="80" rows="10" style="width: 300px; height: 150px;"></textarea> + <textarea class="form-control" name="unl" cols="120" rows="30" style="width: 80%;"> +; Type in your UNL text, it may be a simple graph enclosed in [S] and [/S] tags +; or a structures UNL documents using [D] [P] [T] [S] flags +; with or without the multilingual facets (enclosed in {org}, {fr}, etc... flags +[D] +[S:R1] +{org:en} +The system allows a radio channel to take on two states: Listening and Traffic. +{/org} +{unl} +aoj( allow(icl>be, aoj>thing, ben>thing, obj>uw, equ>make_possible).@entry, system(icl>group).@def ) +obj( allow(icl>be, aoj>thing, ben>thing, obj>uw, equ>make_possible).@entry, take_on(aoj>thing, equ>assume,icl>change, obj>thing) ) +ben( allow(icl>be, aoj>thing, ben>thing, obj>uw, equ>make_possible).@entry, channel(icl>radiowave).@indef) +aoj( take_on(aoj>thing, equ>assume, icl>change, obj>thing), channel(icl>radiowave).@indef ) +obj( take_on(aoj>thing, equ>assume, icl>change, obj>thing), state(icl>attribute).@plu ) +qua( state(icl>attribute).@plu, 2 ) +cnt( state(icl>attribute).@plu, listening(icl>sensing) ) +and( listening(icl>sensing),traffic(icl>communication) ) +{/unl} +[/S] +[S:R2] +{org:en} +The system displays a channel in green when it is in broadcast state. +{/org} +{unl} +agt(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,system(icl>group).@def) +mod(channel(icl>radiowave).@indef,green(icl>adj,iof>color)) +obj(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,channel(icl>radiowave).@indef) +tim(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,when(icl>how,com>always,tim<uw,obj>uw)) +aoj:01(be_in_a_state(aoj>thing,icl>be,obj>state).@entry.@present,channel(icl>radiowave).@indef) +plc:01(state(icl>attribute),broadcast(icl>message)) +obj:01(be_in_a_state(aoj>thing,icl>be,obj>state).@entry.@present,state(icl>attribute)) +obj(when(icl>how,com>always,tim<uw,obj>uw),:01) +{/unl} +[/S] +[/D] + </textarea> <h2>Tell me which output(s) you want</h2> <ul> <li><label><input type="checkbox" name="outputs" value="rdf" checked>RDF</label></li>