1:- module(prophier, []). 2:- use_module(library(semweb/rdf_db)). 3:- use_module(library(assoc)). 4:- use_module(library(http/http_dispatch)). 5:- use_module(library(http/html_write)). 6
7:- use_module(components(label)). 8:- use_module(cliopatria(hooks)).
29
30:- http_handler(root(prophier), property_hierarchy, []). 31
36
37cliopatria:(300=places/property_hierarchy, 'Predicate tree').
45property_hierarchy(_Request) :-
46 property_tree(Tree),
47 reply_html_page(cliopatria(default),
48 title('Property hierarchy'),
49 [ h1('RDF Property hierarchy'),
50 \emit_tree(Tree)
51 ]).
52
53
54emit_tree([]) --> !.
55emit_tree(List) -->
56 html(ul(\emit_children(List))).
57
58emit_children([]) --> [].
59emit_children([node(P,Children)|T]) -->
60 html(li([ \rdf_link(P) 61 | \emit_tree(Children)
62 ])),
63 emit_children(T).
76property_tree(List) :-
77 empty_assoc(Done0),
78 findall(node(P, _), p_root(P), List),
79 children(List, Done0, _Done).
80
81p_root(P) :-
82 rdf_current_predicate(P),
83 \+ rdf_has(P, rdfs:subPropertyOf, _).
84
85children([], Done, Done).
86children([node(P, Children)|T], Done0, Done) :-
87 ( get_assoc(P, Done0, _) 88 -> Done = Done0
89 ; put_assoc(P, Done0, true, Done1),
90 findall(node(P2, _), rdf_has(P2, rdfs:subPropertyOf, P), Children),
91 children(T, Done1, Done2),
92 children(Children, Done2, Done)
93 )
Vizualize the RDF property hierarchy
This program demonstrates simple data processing and vizualization. In order to process the request, we
ul
structureFinally, we can add it to the ClioPatria menu by adding a clause for cliopatria:menu_item/2.