]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/SemanticWeb.php
rough layout for the new formats
[SourceForge/phpwiki.git] / lib / SemanticWeb.php
1 <?php rcs_id('$Id: SemanticWeb.php,v 1.1 2006-03-07 20:53:55 rurban Exp $');
2 /**
3  * What to do on ?format=rdf  What to do on ?format=owl
4  *
5  * Map relations on a wikipage to a RDF ressource to build a "Semantic Web" 
6  * - a web ontology frontend compatible to OWL (web ontology language).
7  * http://www.w3.org/2001/sw/Activity
8  * Simple RDF ontologies contain facts and rules, expressed by RDF triples:
9  *   Subject (page) -> Predicate (verb, relation) -> Object (links)
10  * OWL extents that to represent a typical OO framework. 
11  *  OO predicates: 
12  *    is_a, has_a, ...
13  *  OWL predicates:
14  *    subClassOf, restrictedBy, onProperty, intersectionOf, allValuesFrom, ...
15  *    someValuesFrom, unionOf, equivalentClass, disjointWith, ...
16  *    plus the custom vocabulary (ontology): canRun, canBite, smellsGood, ...
17  *  OWL Subjects: Class, Restriction, ...
18  *  OWL Properties: type, label, comment, ...
19  * DAML should also be supported.
20  *
21  * Purpose:
22  * - Another way to represent various KB models in various DL languages. (OWL/DAML/other DL)
23  * - Frontend to various KB model reasoners and representations. 
24  * - Generation/update of static wiki pages based on external OWL/DL/KB (=> ModelTest/Categories)
25  *   KB Blackboard and Visualization.
26  * - OWL generation based on static wiki pages (ModelTest?format=owl)
27  *
28  * Facts: (may be represented by special links on a page)
29  *  - Each page must be representable with an unique URL.
30  *  - Each fact must be representable with an unique RDF triple.
31  *  - A class is represented by a category page.
32  *  - To represent more expressive description logic, "enriched" 
33  *    links will not be enough (? variable symbolic objects).
34  *
35  * Rules: (may be represented by special content on a page)
36  *  - Syntax: reasoner backend specific, or common or ?
37  *
38  * RDF Triple: (representing facts)
39  *   Subject (page) -> Predicate (verb, relation) -> Object (links)
40  * Subject: a page
41  * Verb: 
42  *   Special link qualifiers represent RDF triples, based on RDF standard notation.
43  *   See RDF standard DTD's on daml.org and w3.org, plus your custom predicates. 
44  *   (need your own DTD)
45  *   Example: page [Ape] isa:Animal, ...
46  * Object: special links on a page.
47  * Class: WikiCategory
48  * Model: Basepage for a KB. (parametrizeable pages or copies of modified snapshots?)
49  *
50  * DL: Description Logic
51  * KB: Knowledge Base
52  *
53  * Discussion:
54  * Of course *real* expert systems ("reasoners") will help/must be used in
55  * optimization and maintainance of the SemanticWeb KB (Knowledge
56  * Base). Hooks will be tested to KM (an interactive KB playground),
57  * LISA (standard unifier), FaCT, RACER, ... 
58
59  * Maybe also ZEBU (parser generator) is needed to convert the wiki KB
60  * syntax to the KB reasoner backend (LISA, KM, CLIPS, JESS, FaCT,
61  * ...) and forth.
62
63  * pOWL is a simple php backend with some very simple AI logic in PHP,
64  * though I strongly doubt the usefulness of reasoners not written in
65  * Common Lisp.
66  *
67  * SEAL (omntoweb.org) is similar to that, just on top of the Zope CMF.
68  * FaCT uses e.g. this KB DTD:
69 <!ELEMENT KNOWLEDGEBASE (DEFCONCEPT|DEFROLE|IMPLIESC|EQUALC|IMPLIESR|EQUALR|TRANSITIVE|FUNCTIONAL)*> 
70 <!ELEMENT CONCEPT (PRIMITIVE|TOP|BOTTOM|AND|OR|NOT|SOME|ALL|ATMOST|ATLEAST)> 
71 <!ELEMENT ROLE (PRIMROLE|INVROLE)> 
72 ... (facts and rules described in XML)
73  *
74  * Links:
75  *   http://phpwiki.org/SemanticWeb, 
76  *   http://en.wikipedia.org/wiki/Knowledge_representation
77  *   http://www.ontoweb.org/
78  *   http://www.semwebcentral.org/ (OWL on top of GForge)
79  *
80  *
81  * Author: Reini Urban <rurban@x-ray.at>
82  */
83 /*============================================================================*/
84 /*
85  Copyright 2004 Reini Urban
86
87  This file is part of PhpWiki.
88
89  PhpWiki is free software; you can redistribute it and/or modify
90  it under the terms of the GNU General Public License as published by
91  the Free Software Foundation; either version 2 of the License, or
92  (at your option) any later version.
93
94  PhpWiki is distributed in the hope that it will be useful,
95  but WITHOUT ANY WARRANTY; without even the implied warranty of
96  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
97  GNU General Public License for more details.
98
99  You should have received a copy of the GNU General Public License
100  along with PhpWiki; if not, write to the Free Software
101  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
102  */
103
104 /**
105  * RdfWriter - A class to represent a wikipage as RDF. Supports ?format=rdf
106  *
107  * RdfWriter
108  *  - RssWriter
109  *    - RecentChanges (RecentChanges?format=rss)
110  *      channel: ... item: ...
111  */
112 include_once('lib/RssWriter.php');
113 class RdfWriter extends RssWriter // in fact it should be rewritten to be other way round.
114 {
115     function RdfWriter () {
116         $this->XmlElement('rdf:RDF',
117                           array('xmlns' => "http://purl.org/rss/1.0/",
118                                 'xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'));
119
120         $this->_modules = array(
121             //Standards
122             'content'   => "http://purl.org/rss/1.0/modules/content/",
123             'dc'        => "http://purl.org/dc/elements/1.1/",
124             );
125
126         $this->_uris_seen = array();
127         $this->_items = array();
128     }
129 }
130
131 /**
132  * OwlWriter - A class to represent a set of wiki pages (a DL model) as OWL. 
133  * Supports ?format=owl
134  *
135  * OwlWriter
136  *  - RdfWriter
137  *  - Reasoner
138 */
139 class OwlWriter extends RdfWriter {
140 };
141
142 /**
143  * ModelWriter - Export a KB as set of wiki pages. 
144  * Probably based on some convenient DL expression syntax. (deffact, defrule, ...)
145  *
146  * ModelWriter
147  *  - OwlWriter
148  *  - ReasonerBackend
149 */
150 class ModelWriter extends OwlWriter {
151 };
152
153
154 /**
155  * ReasonerBackend - hooks to reasoner backends.
156  * via http as with DIG,
157  * or internally
158  */
159 class ReasonerBackend {
160     function ReasonerBackend () {
161         ;
162     }
163     /**
164      * transform to reasoner syntax
165      */
166     function transformTo () {
167         ;
168     }
169     /**
170      * transform from reasoner syntax
171      */
172     function transformFrom () {
173         ;
174     }
175     /**
176      * call the reasoner
177      */
178     function invoke () {
179         ;
180     }
181 };
182
183 class ReasonerBackend_LISA extends ReasonerBackend {
184 };
185
186 class ReasonerBackend_KM extends ReasonerBackend {
187 };
188
189
190 // (c-file-style: "gnu")
191 // Local Variables:
192 // mode: php
193 // tab-width: 8
194 // c-basic-offset: 4
195 // c-hanging-comment-ender-p: nil
196 // indent-tabs-mode: nil
197 // End:   
198 ?>