This repository has been archived by the owner on Nov 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexplanation_renderer.pl
42 lines (36 loc) · 1.67 KB
/
explanation_renderer.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
:- module(_, [term_rendering//3]). % +Term, +Vars, +Options
:- use_module(library(http/html_write)).
:- use_module(library(http/term_html)).
:- use_module(library(http/js_write)).
:- use_module(swish(lib/render)).
:- register_renderer(explanation_renderer, "An explanation tree").
:- use_module('../reasoner.pl').
:- use_module('../kp_loader.pl').
term_rendering(Explanation, _Vars, _Options) -->
{Explanation=taxlogExplanation(Trees), is_list(Trees)}, % validate...
!,
{
explanationHTML(Trees,HTML)
},
html(
div([ 'data-render'('As taxlog explanation')],[
div([],HTML)
])
).
% explanationHTML(ExpandedExplanationTree,TermerizedHTMLlist)
% works ok but not inside SWISH because of its style clobbering ways:
explanationHTML(s(G,Ref,_,_,_,C),[li(title="Rule inference step",["~w"-[NG],Navigator]),ul(CH)]) :-
niceModule(G,NG),
clauseNavigator(Ref,Navigator), explanationHTML(C,CH).
explanationHTML(u(G,Ref,_,_,_,[]),[li(title="Unknown",["~w ?"-[NG],Navigator])]) :-
niceModule(G,NG),
clauseNavigator(Ref,Navigator).
%explanationHTML(unknown(at(G,K)),[li([style="color:blue",title="Unknown"],a(href=K,"~w"-[G]))]).
% explanationHTML(unknown(at(G,K)),[li([p("UNKNOWN: ~w"-[G]),p(i(K))])]).
explanationHTML(f(G,Ref,_,_,_,C),[li(title="Failed goal",[span(style="color:red","~w ~~"-[NG]),Navigator]), ul(CH)]) :-
niceModule(G,NG),
clauseNavigator(Ref,Navigator), explanationHTML(C,CH).
%explanationHTML(at(G,K),[li(style="color:green",a(href=K,"~w"-[G]))]).
%explanationHTML(at(G,K),[li([p("~w"-[G]),p(i(K))])]).
explanationHTML([C1|Cn],CH) :- explanationHTML(C1,CH1), explanationHTML(Cn,CHn), append(CH1,CHn,CH).
explanationHTML([],[]).