You are here: Home
Log in


Forgot your password?
 

OWL2AT Demo

Welcome to the demo of the OWL2AT system, set up for Triplify Challenge. It is a standard, out of the box Plone site whose only customisation is to have content types specified by an OWL ontology. The way in which the customisation is specified through OWL is described below. The code for this automatic customisation can be found in the /Code folder, and some instructions how add content that conforms to OWL ontology can be found under /Help. Content conforming to the ontology can be found in /Instances.

Generating Archetype Schemas from OWL Ontologies

The OWL2AT program can be used to generate Archetypes code for the classes in an OWL ontology. The full power of the Plone content management system can then be used to create instances of these classes and display them on the web.

The class named OWL in this module encapsulates an RDF graph, typically found in one or more files. Here we specify the graph as a string in N3 syntax.

>>> ont =  """
... @prefix : .
... @prefix owl: .
... @prefix rdf: .
... @prefix rdfs: .
... @prefix xsd: .
...
... :GraduateStudent a owl:Class;
... rdfs:label "graduate student";
... rdfs:subClassOf [ a owl:Restriction;
... owl:onProperty :takesCourse;
... owl:someValuesFrom :GraduateCourse],
... :Student.
...
... :Student a owl:Class;
... rdfs:label "student";
... rdfs:subClassOf :Person.
...
... :Person a owl:Class;
... rdfs:label "person".
...
... :takesCourse a owl:ObjectProperty;
... rdfs:label "takes course";
... rdfs:domain :Student;
... rdfs:range :Course.
...
... :Course a owl:Class;
... rdfs:label "course".
...
... :GraduateCourse a owl:Class;
... rdfs:subClassOf :Course;
... rdfs:label "graduate course".
...
... :name a owl:DatatypeProperty;
... rdfs:label "full name";
... rdfs:domain :Person;
... rdfs:range xsd:string.
...
... :birthDate a owl:DatatypeProperty;
... rdfs:label "birth date";
... rdfs:domain :Person;
... rdfs:range xsd:date.
...
... :studentID a owl:DatatypeProperty;
... rdfs:label "student ID number";
... rdfs:domain :Student;
... rdfs:range xsd:int.
...
... :xyz a :GraduateStudent;
... :name "John Smith";
... :takesCourse :abc;
... :birthDate "1985-12-1";
... :studentID "12543213451".
...
... :abc a :GraduateCourse;
... rdfs:label "Advanced AI".
... """
>>> owl = OWL([StringIO(ont)], format='n3')
Graph(s) parsed!
Extending graph ... extended!
>>> print owl
[a rdflib:ConjunctiveGraph;rdflib:storage [a rdflib:Store;rdfs:label 'IOMemory']]

We can call the method generate_archetypes with an optional 'outdir' argument. Without this argument a file in the temp directory is used.

>>> owl.generate_archetypes() # doctest:+ELLIPSIS
Output directory: /tmp/owl2at...
Archetypes generated!

In the output directory, a collection of files will be generated that constitute an entire Archetypes Product. This directory can be copied to the Products directory of a Zope instance. If Plone is installed on this Zope instance, the Archetypes will be available to any Plone portal there.

>>> dirs = os.listdir(owl.outdir); dirs.sort()
>>> for f in dirs: print f # doctest:+ELLIPSIS
Course.py
Course_folder.py
Extensions
GraduateCourse.py
GraduateCourse_folder.py
GraduateStudent.py
GraduateStudent_folder.py
OWL2AT.py
Person.py
Person_folder.py
Student.py
Student_folder.py
__init__.py
config.py
skins

The crucial files are the ones generated for each OWL class. They reflect all the information in the ontology relevant to this class, in particular there are Archetype fields for each property for which this class is a domain. Properties will also be inherited from a super class.

>>> print file(owl.outdir + '/GraduateStudent.py').read()
from Products.Archetypes.public import BaseSchema, Schema
from Products.Archetypes.public import StringField, TextField, ReferenceField
from Products.Archetypes.public import LinesField, IntegerField, FloatField, DateTimeField
from Products.Archetypes.public import SelectionWidget, TextAreaWidget, StringWidget
from Products.Archetypes.public import InAndOutWidget, RichWidget, ReferenceWidget
from Products.Archetypes.public import IntegerWidget, DecimalWidget, CalendarWidget
from Products.ATReferenceBrowserWidget.ATReferenceBrowserWidget \
import ReferenceBrowserWidget
from Products.Archetypes.public import BaseContent
from Products.Archetypes.public import registerType
from Products.Archetypes.Marshall import PrimaryFieldMarshaller
try:
from Products.CMFCore import CMFCorePermissions as permissions
except ImportError:
from Products.CMFCore import permissions
from config import PROJECTNAME
import OWL2AT

schema = BaseSchema + Schema ((
DateTimeField('birthDate',
uri='http://dfki.de/owl2at/univ.owl#birthDate',
multiValued=True,
addable=True,
searchable=False,
widget=CalendarWidget(
label="birth date",
),
),
IntegerField('studentID',
uri='http://dfki.de/owl2at/univ.owl#studentID',
multiValued=True,
addable=True,
searchable=False,
widget=IntegerWidget(
label="student ID number",
),
),
ReferenceField('takesCourse',
uri='http://dfki.de/owl2at/univ.owl#takesCourse',
multiValued=True,
required=True,
allowed_types=('GraduateCourse'),
addable=True,
widget=ReferenceBrowserWidget(
allow_search=True,
allow_browse=True,
show_index=False,
label="takes course",
),
relationship='takesCourse',
),
StringField('name',
uri='http://dfki.de/owl2at/univ.owl#name',
multiValued=True,
addable=True,
searchable=True,
widget=StringWidget(
label="full name",
),
),
))

class GraduateStudent(BaseContent, OWL2AT.Exportable):

_class_uri = 'http://dfki.de/owl2at/univ.owl#GraduateStudent'

_property_uris = {u'studentID': 'http://dfki.de/owl2at/univ.owl#studentID', u'takesCourse': 'http://dfki.de/owl2at/univ.owl#takesCourse', u'name': 'http://dfki.de/owl2at/univ.owl#name', u'birthDate': 'http://dfki.de/owl2at/univ.owl#birthDate'}

_immediate_subclasses = []

_all_subclasses = []

_immediate_superclasses = ['Student']

_all_superclasses = ['Person', 'Student', 'Resource']

_equivalent_classes = []

schema = schema

actions = OWL2AT.Exportable.actions

registerType(GraduateStudent, PROJECTNAME)

The following features of OWL Lite are handled:

  • Class (Thing, Nothing)

    Generates a file ".py" containing an Archetypes schema for the class and, optionally, a file "_folder.py" containing the definition of a Plone folder whose contents are restriced to instances of .

  • rdfs:subClassOf

    Properties are inherited from the superclass.

  • rdf:Property

    Properties become Archetypes fields.

  • rdfs:subPropertyOf

    Domains are inherited from sub properties.

  • rdfs:domain

    An Archetypes schema has a field for a property P if the class the schema belongs to is in the domain of P.

  • rdfs:range

    The property's range determines the allowed types in the Archetype field that is used.

  • Individual

    Currently not handled.

  • equivalentClass

    Equivalent classes should be taken into account when calculating subclass hierarchies and domains.

  • equivalentProperty

    Currently not handled.

  • sameAs

    Currently not handled.

  • differentFrom

    Currently not handled.

  • AllDifferent

    Currently not handled.

  • distinctMembers

    Currently not handled.

  • ObjectProperty

    Currently not handled.

  • DatatypeProperty

    • xsd:string -> String field.
    • xsd:int -> Integer field.
    • xsd:date -> Date field.
  • inverseOf

    Currently not handled.

  • TransitiveProperty

    Currently not handled.

  • SymmetricProperty

    Currently not handled.

  • FunctionalProperty

    A functional property corresponds to an Archetypes field that has 'multivalued' set to False.

  • InverseFunctionalProperty

    Currently not handled.

  • Restriction

    Used in the calcuation of allowed types for an Archetypes field.

  • onProperty

    Used with Restriction.

  • allValuesFrom

    Used with Restriction.

  • someValuesFrom

    Used with Restriction.

  • minCardinality (only 0 or 1)

    Currently not handled.

  • maxCardinality (only 0 or 1)

    Currently not handled.

  • cardinality (only 0 or 1)

    Currently not handled.

  • Ontology

    Currently not handled.

  • imports

    Currently not handled.

  • intersectionOf

    Used to determine sub class hierarchies.

  • xsd datatypes

    Mapped into the corresponding Archetypes field.

  • versionInfo

    Currently not handled.

  • priorVersion

    Currently not handled.

  • backwardCompatibleWith

    Currently not handled.

  • incompatiblewith

    Currently not handled.

  • DeprecatedClass

    Currently not handled.

  • DeprecatedProperty

    Currently not handled.

  • rdfs:label

    Currently not handled.

  • rdfs:comment

    Currently not handled.

  • rdfs:seeAlso

    Currently not handled.

  • rdfs:isDefinedBy

    Currently not handled.

  • AnnotationProperty

    Currently not handled.

  • OntologyProperty

    Currently not handled.

Document Actions
« March 2009 »
March
Mo Tu We Th Fr Sa Su
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
 
  • Powered by Plone
  • Valid XHTML
  • Valid CSS
  • Section 508
  • WCAG