-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathontology.php
More file actions
339 lines (299 loc) · 11.5 KB
/
ontology.php
File metadata and controls
339 lines (299 loc) · 11.5 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<?php
/**
* User: Hans-Gert Gräbe
* last update: 2022-09-22
*/
require 'vendor/autoload.php';
require_once 'helper.php';
require_once 'layout.php';
function theTitle() {
return '<h2>The WUMM Ontology Project</h2>';
}
// ------ helper ----
function displayThesaurus() {
/* $graph = new \EasyRdf\Graph('http://opendiscovery.org/rdf/Ontology/');
$graph->parseFile("rdf/Thesaurus.rdf");
$graph->parseFile("rdf/Souchkov-Glossary.rdf");
$graph->parseFile("rdf/TOP-Glossary.rdf");
$graph->parseFile("rdf/VDI-Glossary.rdf"); // add more */
setNamespaces();
global $sparql;
$query='
PREFIX od: <http://opendiscovery.org/rdf/Model#>
describe ?a
from <http://opendiscovery.org/rdf/Thesaurus/>
from <http://opendiscovery.org/rdf/Souchkov-Glossary/>
from <http://opendiscovery.org/rdf/TOP-Glossary/>
from <http://opendiscovery.org/rdf/VDI-Glossary/>
where { ?a a skos:Concept . }
LIMIT 10000
';
try {
$graph = $sparql->query($query);
} catch (Exception $e) {
print "<div class='error'>".$e->getMessage()."</div>\n";
}
$a=array();
foreach ($graph->allOfType("skos:Concept") as $concept) {
$uri=str_replace("http://opendiscovery.org/rdf/","",$concept->getURI());
$types=join("<br/> ",$concept->all("rdf:type"));
$preflabel=showLanguage($concept->all("skos:prefLabel"),"<br/>");
$out='<h4><a href="displayuri.php?uri='.$uri.'">'.$uri.'</a></h4>'
.'<h5><strong>Types</strong></h5>'.$types
.'<h5><strong>Preferred Label</strong></h5>'.$preflabel;
$a[$concept->getUri()]="<div>\n$out\n</div>\n";
}
ksort($a);
$out=theTitle().'
<h3>The Combined TRIZ Thesaurus</h2>
<div class="concept">
'.join("\n", $a).'
</div> <!-- end concept list -->';
return '<div class="container">'.$out.'</div>';
}
function displayAllGlossaries() {
global $sparql;
$query='
PREFIX od: <http://opendiscovery.org/rdf/Model#>
PREFIX tc: <http://opendiscovery.org/rdf/Concept/>
describe ?a
where { ?a a skos:Concept . }
LIMIT 10000
';
#Nevertheless not all attributes are displayed
try {
$graph = $sparql->query($query);
} catch (Exception $e) {
print "<div class='error'>".$e->getMessage()."</div>\n";
}
$a=array();
$res = $graph->allOfType("skos:Concept");
foreach ($res as $concept) {
$out=displayGlossaryEntry($concept);
$a[$concept->getUri()]="<div>\n$out\n</div>\n";
}
ksort($a);
$out=theTitle().'
<h3>A Combined TRIZ Glossary</h2>
<p>It contains glossaries in particular from Valeri Souchkov, from the VDI
norm, the GSA thesaurus.</p>
<div class="concept">
'.join("\n", $a).'
</div> <!-- end concept list -->';
return '<div class="container">'.$out.'</div>';
}
function displayGlossaryEntry($concept) {
$uri=str_replace("http://opendiscovery.org/rdf/","",$concept->getURI());
$types=join("<br/> ",$concept->all("rdf:type"));
$preflabel=showLanguage($concept->all("skos:prefLabel"),"<br/>");
$out='<h4><a href="displayuri.php?uri='.$uri.'">'.$uri.'</a></h4>'
.'<h5><strong>Types</strong></h5>'.$types
.'<h5><strong>Preferred Label</strong></h5>'.$preflabel;
$u=showLanguage($concept->all("od:TOPExplanation"),"<br/>");
if (!empty($u)) {
$out.='<h5><strong>TOP Explanation:</strong></h5>'.$u.'</p>';}
$u=showLanguage($concept->all("od:SouchkovDefinition"),"<br/>");
if (!empty($u)) {
$out.='<h5><strong>Souchkov\'s Definition:</strong></h5> '.$u.'</p>'; }
$u=showLanguage($concept->all("od:MatvienkoDefinition"),"<br/>");
if (!empty($u)) {
$out.='<h5><strong>Matvienko\'s Definition:</strong></h5> '.$u.'</p>'; }
$u=showLanguage($concept->all("od:VDIGlossaryDefinition"),"<br/>");
if (!empty($u)) {
$out.='<h5><strong>Definition in the VDI Glossary:</strong></h5> '.$u.'</p>'; }
$u=showLanguage($concept->all("od:hasLippertNote"),"<br/>");
if (!empty($u)) {$out.='<h5><strong>Note in Lippert/Cloutier:</strong></h5> '.$u.'</p>'; }
return $out;
}
function displayGlossary($gloss, $title) {
global $sparql;
$query='
PREFIX od: <http://opendiscovery.org/rdf/Model#>
PREFIX tc: <http://opendiscovery.org/rdf/Concept/>
describe ?a
from <http://opendiscovery.org/rdf/'.$gloss.'>
where { ?a a skos:Concept . }
';
try {
$graph = $sparql->query($query);
} catch (Exception $e) {
print "<div class='error'>".$e->getMessage()."</div>\n";
}
$a=array();
$res = $graph->allOfType("skos:Concept");
foreach ($res as $concept) {
$out=displayGlossaryEntry($concept);
$a[$concept->getUri()]="<div>\n$out\n</div>\n";
}
ksort($a);
$out=theTitle().'
<h3>'.$title.'</h2>
<div class="concept">
'.join("\n", $a).'
</div> <!-- end concept list -->';
return '<div class="container">'.$out.'</div>';
}
// ------ the top level concepts
function TopLevel() {
/* $graph = new \EasyRdf\Graph('http://opendiscovery.org/rdf/Ontology/');
$graph->parseFile("rdf/TopLevel.rdf"); */
setNamespaces();
global $sparql;
$query='
PREFIX od: <http://opendiscovery.org/rdf/Model#>
describe ?a
from <http://opendiscovery.org/rdf/TopLevel/>
where { ?a a od:TopLevelConcept .}';
try {
$graph = $sparql->query($query);
} catch (Exception $e) {
print "<div class='error'>".$e->getMessage()."</div>\n";
}
$a=array();
$res = $graph->allOfType("od:TopLevelConcept");
foreach ($res as $concept) {
$uri=str_replace("http://opendiscovery.org/rdf/","",$concept->getURI());
$types=join("<br/> ",$concept->all("rdf:type"));
$preflabel=showLanguage($concept->all("skos:prefLabel"),"<br/>");
$parts=$concept->all("od:includes");
$out='<h4><a href="displayuri.php?uri='.$uri.'">'.$uri.'</a></h4>'
.'<h5><strong>Types</strong></h5>'.$types
.'<h5><strong>Preferred Label</strong></h5>'.$preflabel;
if(!empty($parts)) {
$out.='<h5><strong>Has SubConcepts</strong></h5>'.displaySubconcepts($parts);
}
$a[$concept->getUri()]="<div>\n$out\n</div>\n";
}
ksort($a);
$out=theTitle().'
<h3>The Top Level Concepts</h2>
<div class="concept">
'.join("\n", $a).'
</div> <!-- end concept list -->';
return '<div class="container">'.$out.'</div>';
}
function displaySubconcepts($s) {
$a=array();
foreach ($s as $key => $entry) {
$a[]='<li><a href="displayuri.php?uri='.$entry.'">'.$entry.'</a><li>';
}
return '<ul>'.join("\n",$a).'</ul>';
}
// ------ the ontocards
function OntoCards() {
// extract the OntoCards
setNamespaces();
global $sparql;
$query='
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX od: <http://opendiscovery.org/rdf/Model#>
PREFIX tc: <http://opendiscovery.org/rdf/Concept/>
construct { ?a ?b ?c . ?e od:hasSubConcept ?d . }
from <http://opendiscovery.org/rdf/OntoCards/>
where { { ?a a od:OntoCard ; ?b ?c . }
union { ?d od:hasSuperConcept ?e . }
}';
try {
$graph = $sparql->query($query);
} catch (Exception $e) {
print "<div class='error'>".$e->getMessage()."</div>\n";
}
$out=theTitle().'
<h3>The OntoCards</h2>
<div class="concept">
'.displayOntoCard($graph,"http://opendiscovery.org/rdf/Concept/TRIZ").'
</div> <!-- end concept list -->';
return '<div class="container">'.$out.'</div>';
}
function displayOntoCard ($graph,$s) {
$node=$graph->resource($s);
$a=array();
$uri=str_replace("http://opendiscovery.org/rdf/","",$node->getURI());
$preflabel=showLanguage($node->all("skos:prefLabel"),"<br/>");
$web=$node->get("od:hasWebPage");
$out='<h4><a href="displayuri.php?uri='.$uri.'">'.$uri.'</a></h4>'
.$preflabel;
if(!empty($web)) {
$out.='<div>'.createLink($web,'The Web Page').'</div>';
}
$b=array();
foreach($node->all("od:hasSubConcept") as $v) {
#echo $v->{"a"}."\n====\n";
$b[]='<li>'.displayOntoCard($graph,$v->getURI()).'</li>' ;
}
if (!empty($b)) { $out.='<ul>'.join("\n",$b).'</ul>'; }
return "<div>\n$out\n</div>\n";
}
// ------ the main info page
function generalOntologyInfo() {
$out=theTitle().'
<p>We proudly present the reengineering along established semantic web
concepts of a small part of the <a
href="https://wumm-project.github.io/Ontology.html" >TRIZ Ontology
Project</a>. It\'s a first hack, more detailed explanations will be comiled
<a href="https://wumm-project.github.io/OntologyDetails">elsewhere</a>.</p>
<p>For the moment we compiled
<ul>
<li><a href="ontology.php?rdf=thesaurus">A combined Thesaurus</a> </li>
<li><a href="ontology.php?rdf=sparql">A combined Glossary</a> (by some yet
uncovered reason not all information is displayed) </li>
<li><a href="ontology.php?rdf=Souchkov">Souchkov\'s Glossary</a> </li>
<li><a href="ontology.php?rdf=VDI">The VDI Glossary</a> </li>
<li><a href="ontology.php?rdf=Matvienko">Matvienko\'s Glossary</a> </li>
<li><a href="ontology.php?rdf=TOP">The Glossary of the TRIZ Ontology
Project</a> </li>
<li><a href="ontology.php?rdf=Lippert">Lippert\'s Notes</a> </li>
<li><a href="ontology.php?rdf=TopLevel">Top Level Concepts</a> from the TRIZ
Ontology Project</li>
<li><a href="ontology.php?rdf=OntoCards">OntoCards</a> from the TRIZ Ontology
Project</li>
</ul>
The concepts from the different sources are tagged with different rdf:type,
that all are subtypes of skos:Concept to follow up their provenience. Some
more efforts are required to unify the URIs of the concepts between the
different sources.</p>
<p>There is a link attached to each such concept that leads to the full
information about that topic extracted from our <a
href="http://wumm.uni-leipzig.de:8891/sparql">SPARQL Endpoint</a> including
all direct successors (i.e. objects, where the given concept is the subject)
and predecessors (i.e. subjects, where the given concept is the object). This
allows for a first navigation through the full WUMM RDF Data stored so far.
</p>
<p>You can follow up secondary links in such a presentation to different
concepts in the WUMM RDF database to get a similar representation for those
concepts. In particular you can get listed all instances of a given RDF type,
calling the listing of that type, since the instances are predecessors of the
type for the predicate <tt>rdf:type</tt>.</p>
<p>Links to sources outside the WUMM RDF database call the target page
directly. For the moment this mainly concerns links to web pages (in Russian)
of the <a href="https://triz-summit.ru/onto_triz">TRIZ Ontology
Project</a>.</p>
';
return '<div class="container">'.$out.'</div>';
}
function theOntologyPage($rdf) {
setNamespaces();
#echo $rdf;
if ($rdf=='thesaurus') { $out=displayThesaurus(); }
else if ($rdf=='sparql') { $out=displayAllGlossaries(); }
else if ($rdf=='TopLevel') { $out=TopLevel(); }
else if ($rdf=='OntoCards') { $out=OntoCards(); }
else if ($rdf=='VDI') {
$out=displayGlossary("VDI-Glossary/","The VDI Glossary"); }
else if ($rdf=='Souchkov') {
$out=displayGlossary("Souchkov-Glossary/","Souchkov's Glossary"); }
else if ($rdf=='Matvienko') {
$out=displayGlossary("Matvienko-Glossary/","Matvienko's Glossary"); }
else if ($rdf=='Lippert') {
$out=displayGlossary("Lippert-Glossary/","Lippert's Notes"); }
else { $out=generalOntologyInfo(); }
return '<div class="container">'.$out.'</div>';
}
$rdf=$_GET["rdf"]; // (thesaurus | sparql | TopLevel | OntoCards | VDI )
#$rdf="VDI"; // (thesaurus | sparql | TopLevel | OntoCards | VDI )
echo showpage(theOntologyPage($rdf));
#echo displayThesaurus();
#echo displayVDIGlossary();
#echo displayGlossary();
#echo OntoCards();
?>