Permalink
Browse files

docs

  • Loading branch information...
1 parent d9b14ec commit 4048b1ef8c5755b2c64784e34e5c3ce274e2f866 @cmungall cmungall committed Nov 16, 2010
Showing with 439 additions and 56 deletions.
  1. +26 −4 README
  2. +4 −3 owl2_from_rdf.pl
  3. +1 −0 owl2_io.pl
  4. +53 −43 owl2_java_owlapi.pl
  5. +68 −4 owl2_plsyn.pl
  6. +3 −2 owl2_rl_rules.pl
  7. +19 −0 owl2_util.pl
  8. +134 −0 z1.txt
  9. +43 −0 z2.txt
  10. +44 −0 z3.txt
  11. +44 −0 z3b.txt
View
30 README
@@ -10,6 +10,9 @@ This documentation is intended to be read via pldoc
See INSTALL.txt
+You can bypass installation and use the 'thea' script directly. See
+below.
+
---++ Overview
The module owl2_io.pl provides a means of loading and saving OWL2
@@ -47,6 +50,23 @@ reasoners can be plugged in, both native prolog and non-prolog (the
latter accessed seamlessly via either owl2_owllink.pl or
owl2_java_owlapi.pl).
+---++ Command Line Usage
+
+The script "thea" in the bin directory should work from anywhere, with
+no installation of thea modules required.
+
+Type
+
+==
+thea --help
+==
+
+for full instructions. Many complex operations can be chained on the
+command line.
+
+See also the other wrapper scripts in the bin directory
+
+See Command_Line_Usage.txt for more details
---++ Further Reading
@@ -63,15 +83,17 @@ See also the apps/ directory for example applications.
* owl2_xml.pl -- support for OWL-XML
* owl2_manchester_paser.pl -- incomplete support for Manchester syntax
* owl2_plsyn.pl -- infix prolog syntax for OWL
- * owl2_model.pl
+ * owl2_model.pl -- definition of prolog predicates used to embed OWL
* swrl.pl
- * owl2_model.pl
- * owl2_reasoner.pl
+ * swrl_rdf_hooks.pl -- allows SWRL to be parsed by owl2_from_rdf.pl
+ * owl2_reasoner.pl -- pluggable reasoner framework
* owl2_rl_rules.pl
* owl2_graph_reasoner.pl
* owl2_java_owlapi.pl (requires JPL)
* owl2_owllink.pl
-
+ * owl2_util.pl -- misc utilities
+ * owl2_popl.pl -- prolog ontology processing language
+ * owl2_metamodel.pl -- information about OWL axiom types
---++ Reasoning support
View
@@ -69,6 +69,7 @@
:- use_module(owl2_model).
+:- use_module(library(debug)).
:- use_module(library('semweb/rdf_db')).
:- use_module(library('semweb/rdf_edit')).
:- use_module(library('semweb/rdfs')).
@@ -214,7 +215,7 @@
% see email to JanW July-1-2009
forall((test_use_owl(S,P,BNode),
atom(BNode),
- sub_string(BNode,0,2,_,'__'),
+ sub_atom(BNode,0,2,_,'__'),
test_use_owl(BNode,'http://www.w3.org/1999/02/22-rdf-syntax-ns#datatype',literal(_))),
( use_owl(S,P,BNode,datatype_fix),
use_owl(BNode,'http://www.w3.org/1999/02/22-rdf-syntax-ns#datatype',literal(_)),
@@ -335,7 +336,7 @@
rdf_load_stream(URL,Ontology,BaseURI,Imports) :-
BaseURI = URL,
- ( sub_string(URL,0,4,_,'http')
+ ( sub_atom(URL,0,4,_,'http')
-> catch((http_open(URL,RDF_Stream,[]),
rdf_load(RDF_Stream,[if(true),base_uri(BaseURI),blank_nodes(noshare),
result(Action, Triples, MD5),register_namespaces(true)]),
@@ -595,7 +596,7 @@
is_bnode(C) :-
atom(C),
- sub_string(C,0,2,_,'__').
+ sub_atom(C,0,2,_,'__').
% Table 11. Parsing Object Property Expressions
View
@@ -9,6 +9,7 @@
convert_axioms/5
]).
+:- use_module(library(debug)).
:- use_module(owl2_model,[consult_axioms/1, axiom/1]).
%% load_axioms_hook(+File,+Fmt,+Opts)
View
@@ -924,70 +924,80 @@
---+ Synopsis
-using OWLAPI to save files:
-
+using a reasoner:
+
==
-[owl2_model].
-[owl2_java_owlapi].
-[owl2_from_rdf].
-owl_parse_rdf('testfiles/Hydrology.owl'), % parse using prolog/thea
-create_factory(Man,Fac),
-build_ontology(Man,Fac,Ont),
-save_ontology(Man,Ont,'file:///tmp/foo'). % save using owlapi
+reasoner_test :-
+ initialize_reasoner(pellet,R),
+ forall(reasoner_ask(subClassOf(A,B)),
+ format('~w SubClassOf ~w~n',[A,B])).
==
-using a reasoner:
+To use this interactively, make sure to start-up prolog with JPL and
+everything in your classpath. You can use the thea-jpl wrapper script.
+
+To start a prolog session:
==
-create_reasoner(Man,pellet,Reasoner),
-create_factory(Man,Fac),
-build_ontology(Man,Fac,Ont),
-reasoner_classify(Reasoner,Man,Ont),
-save_ontology(Man,Ont,'file:///tmp/foo').
-==
+thea-jpl --prolog
+==
+
+To query reasoner results:
==
-[owl2_model].
-[owl2_java_owlapi].
-[owl2_from_rdf].
-owl_parse_rdf('testfiles/music_ontology.owl'),
-create_factory(Man,Fac),
-build_ontology(Man,Fac,Ont),
-writeln(classifying),
-create_reasoner(Man,pellet,Reasoner),
-reasoner_classify(Reasoner,Man,Ont),
-writeln(classified),
-class(C),
-writeln(c=C),
-reasoner_subClassOf(Reasoner,Fac,C,P),
-writeln(p=P).
-==
+thea-jpl --reasoner pellet testfiles/pizza.owl --reasoner-ask "subClassOf(A,B)"
+==
+
+---+ Details
+
+This module is intended to interface with the OWLAPI
-queries:
+ http://owlapi.sourceforge.net/
+
+This provides access to reasoners such as Pellet and FaCT++, as well
+as OWLAPI parsers and renderers. You can also use this if you want
+additional capabilities provided by the OWLAPI.
+
+
+---+ Hooks
+
+It provides hooks into both owl2_reasoner.pl and owl2_io.pl
+
+---++ I/O Hooks
+
+You can use the format =|owlapi(Format)|= to use the OWLAPI for
+reading or writing. E.g.
==
-someValuesFrom('http://purl.org/ontology/mo/performed','http://purl.org/ontology/mo/Performance')
+save_axioms('my.owl',owlapi(manchester)).
==
----+ Use
+Supported values:
- JPL Required
+ * owlapi(manchester)
+ * owlapi(owlxml)
+ * owlapi(owlrdf)
- Set your CLASSPATH to include owlapi-bin.jar, pellet.jar, ...
+ More can be added easily on request
- start SWI
+---++ Reasoner Hooks
+
+You can use any of
+
+ * pellet
+ * factpp
+ * hermit
+
+As arguments to reasoner_initialize/2.
----+ Details
- This module is intended to interface with the OWLAPI
- http://owlapi.sourceforge.net/
- This provides access to reasoners such as Pellet and FaCT++
+---+ Pre-Requisites
- JPL is required for this module
+JPL is required for this module
- Note that this module is not required for the rest of Thea2
+Note that this module is not required for the rest of Thea2
@author Chris Mungall
@version $Revision$
View
@@ -121,10 +121,15 @@
\+ ((ontologyAxiom(Ont,H),
member(Ont,Onts))).
+%% plsyn_owl(?Pl,?Owl)
+% as plsyn_owl/3
plsyn_owl(Pl,Owl) :-
plsyn_owl(Pl,Owl,[]).
-%% plsyn_owl(+Pl,?Owl,+Opts:list)
+%% plsyn_owl(?Pl,?Owl,+Opts:list)
+%
+% convert between a plsyn prolog term and an owl2_model.pl prolog term.
+% either one of Pl or Owl must be ground
plsyn_owl(Pl,Owl,Opts) :-
select(use_labels,Opts,Opts2),
!,
@@ -347,7 +352,7 @@
convenience predicates declared infix in order to resemble Manchester
Syntax.
-The following prolog file
+The following is a valid plsyn file:
==
ontology(spicy).
@@ -356,7 +361,7 @@
pizza_with_4_cheeses == pizza and hasPart exactly 4 of cheese.
==
-Can be loaded like this:
+This file can be loaded via load_axioms/2 like this:
==
load_axioms('myfile.plsyn',plsyn).
@@ -371,7 +376,66 @@
We are forced to introduce an extra keyword 'of' for cardinality
expressions to make this parseable by prolog.
-
TODO: show translation table
+---++ Infix Predicate Symbols for Axioms
+
+ * < --- subClassOf/2
+ * @< --- subPropertyOf/2
+ * == --- equivalentClasses/1
+ * = --- sameIndividual/1
+ * \= --- differentIndividuals/1
+ * :: --- classAssertion/2
+
+---++ Property Characteristic Prefix Predicates
+
+the following are all declared prefix
+
+ * transitive --- transitiveProperty/1
+ * symmetric --- symmetricProperty/1
+ * reflexive --- reflexiveProperty/1
+ * functional --- functionalProperty/1
+
+---++ Other Infix Predicates
+
+ * inverseOf --- inverseProperties/2
+
+---++ Class Expressions
+
+ * and --- intersectionOf
+ * or --- unionOf
+ * some --- someValuesFrom
+ * only --- allValuesFrom
+ * value --- hasValue
+ * not --- complementOf (prefix)
+ * exactly --- exactCardinality
+ * min --- minCardinality
+ * max --- maxCardinality
+ * of --- required when making QCRs. E.g. exactly 5 of finger
+
+ ---++ Property Expressions
+
+ Use the '*' symbol. For example
+
+ ==
+ uncleOf @< fatherOf * brotherOf.
+ ==
+
+ ---++ Uses
+
+ plsyn makes it easier to mix OWL ontologies and ontology templates into prolog programs.
+
+For example, consider the following failure-driven loop to add an OWL
+axiom with a complex nested expression for all facts of a 4-argument predicate:
+
+==
+generate_ownership_assertions :-
+ owns(Person,Number,Thing,Loc),
+ plsyn_owl( owns exactly Number of (Thing and located_in value Loc) :: Person, OwlAxiom),
+ assert_axiom(OwlAxiom),
+ fail.
+==
+
+The owl2_popl.pl module facilitates this kind of translation
+
*/
View
@@ -17,7 +17,6 @@
This module implements the OWL2 RL rule-based reasoninng
-
---+ Details
See http://www.w3.org/TR/2008/WD-owl2-profiles-20081202/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules
@@ -73,7 +72,9 @@
u_assert(X) :-
call(X),!.
-u_assert(X) :- assert(X).
+u_assert(X) :-
+ debug(rl_rules,'asserting : ~w',[X]),
+ assert(X).
View
@@ -16,11 +16,14 @@
remove_ns/2,
replace_ns_prefix/4,
use_label_as_IRI/2,
+ get_IRI_from_label/2,
use_labels_for_IRIs/0,
use_safe_labels_for_IRIs/0,
+ replace_labels_with_IRIs/0,
use_numeric_IRIs_for_classes/2,
prefix_IRIs/1,
translate_IRIs/1,
+ translate_IRIs/2,
map_IRIs/3,
assume_entity_declarations/0,
use_class_labels_as_synonyms/1,
@@ -211,6 +214,9 @@
use_safe_labels_for_IRIs:-
translate_IRIs(use_safe_label_as_IRI).
+replace_labels_with_IRIs:-
+ translate_IRIs(get_IRI_from_label).
+
remove_ns(IRI,X) :-
concat_atom([_,X],'#',IRI),
!.
@@ -250,6 +256,11 @@
!.
use_label_as_IRI(X,X).
+get_IRI_from_label(X,IRI) :- labelAnnotation_value(IRI,X),!.
+get_IRI_from_label(X,X).
+
+
+
use_property_as_IRI(Prop,IRI,NewIRI) :-
anyPropertyAssertion(Prop,IRI,Literal),
Literal=literal(type(_,Val)),
@@ -282,6 +293,14 @@
maplist(retract_axiom,Axioms),
maplist(assert_axiom,Axioms2).
+:- module_transparent translate_IRIs/2.
+translate_IRIs(Goal,Ontology):-
+ findall(A,ontologyAxiom(Ontology,A),Axioms),
+ maplist(map_IRIs(Goal),Axioms,Axioms2),
+ maplist(retract_axiom,Axioms),
+ forall(member(A,Axioms2),
+ assert_axiom(A,Ontology)).
+
%% map_IRIs(+MapGoal,+AxiomIn,?AxiomOut)
:- module_transparent map_IRIs/3.
map_IRIs(_,[],[]) :- !.
Oops, something went wrong.

0 comments on commit 4048b1e

Please sign in to comment.