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