Jena Framework - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Jena Framework

Description:

ExtendedIterator iter = ontModel1.listDatatypeProperties(); while(iter.hasNext()){ DatatypeProperty dP= (DatatypeProperty)iter.next ... – PowerPoint PPT presentation

Number of Views:113
Avg rating:3.0/5.0
Slides: 24
Provided by: icsdA
Category:
Tags: framework | iter | jena

less

Transcript and Presenter's Notes

Title: Jena Framework


1
Jena Framework
  • Presentation Konstantinos Kanaris

2
Overview
  • What is Jena?
  • Usage of Jena
  • Main Concepts
  • Main Components
  • Storage Models
  • OWL API
  • RDF API
  • Reasoning
  • Application-oriented issues

3
What is Jena?
  • Open source Semantic Web framework for Java based
    on W3C recommendations for RDF and OWL
  • Provides a suitable programming environment for
    RDF, RDFS, OWL, SPARQL and an integrated
    rule-based inference mechanism

4
Usage of Jena
  • Import of owl ontologies, RDF, DAML into suitable
    models (persistent or in-memory)
  • Processing of these models
  • Export of these models to owl, rdf, daml files

5
Main Concepts
  • Almost all ontology concepts
  • Classes A class is a definition of a group of
    individuals that belong together because they
    share common properties. For example John and
    Mary both belong to the class person.
  • Instances Instances are what the classes consist
    of their members, they inherit class
    characteristics and properties may be used to
    relate to one another

6
Main Concepts
  • Properties binary relations
  • Object Properties relations between instances of
    two classes
  • Datatype Properties relations between instances
    of classes and RDF literals and XML Schema
    datatypes

7
Main Components
  • com.hp.hpl.jena.rdf.model package for creating
    and manipulating RDF graphs
  • Model RDF model
  • ModelMaker ModelMaker contains a collection of
    named models, methods for creating new models
    both named and anonymous and opening
    previously-named models, removing models, and
    accessing a single "default" Model for this
    Maker.
  • Literal RDF Literal
  • Statement RDF Statement

8
Main Components
  • com.hp.hpl.jena.ontology package that provides a
    set of abstractions and convenience classes for
    accessing and manipluating ontologies represented
    in RDF
  • OntModel An enhanced view of a Jena model that
    is known to contain ontology data, under a given
    ontology vocabulary (such as OWL)
  • OntClass Interface that represents an ontology
    node characterising a class description
  • ComplementClass
  • IntersectionClass
  • UnionClass

9
Main Components
  • OntResource Provides a common super-type for all
    of the abstractions in this ontology
    representation package
  • OntModelSpec Encapsulates a description of the
    components of an ontology model, including the
    storage scheme, reasoner and language profile
  • ObjectProperty Interface encapsulating
    properties whose range values are restricted to
    individuals (as distinct from datatype valued
    properties)
  • DatatypeProperties Interface that encapsulates
    the class of properties whose range values are
    datatype values (as distinct from ObjectProperty
    whose values are individuals)

10
Main Components
  • com.hp.hpl.jena.reasoner.Reasoner reasoner
    subsystem designed to allow a range of inference
    engines to be plugged into Jena
  • com.hp.hpl.jena.reasoner.ReasonerRegistry global
    registry of known reasoner modules

11
Storage Models
  • Persistent Storage
  • Example Source Code
  • OntModelSpec spec new OntModelSpec(OntModelSpec
    .OWL_DL_MEM) IDBConnection conn
    new DBConnection(dbURL, username, password,
    dbType) ModelMaker maker ModelFactory.createMod
    elRDBMaker(conn)
    Model m maker.createModel("http//www.icsd.ae
    gean.gr/ai-lab/projects/grid4all/ontology/grid4all
    Onto", false) m.read("fileG4Aonto-example.owl")

    conn.close()

12
Storage Models
  • In Memory
  • Source Code Example
  • ModelMaker modelMaker ModelFactory.createMemMode
    lMaker() Model model 1
    modelMaker.createModel("myBase")
    java.io.InputStream inFileManager.get().open(fc.g
    etCurrentDirectory().getAbsolutePath()"\\"fc.get
    SelectedFile().getName())
    model1.read(in,
    "")
    OntModelSpec spec
    new OntModelSpec(OntModelSpec.OWL_DL_MEM )
    com.hp.hpl.jena.reasoner.Reasoner reasoner1
    PelletReasonerFactory.theInstance().create()
    spec.setReasoner(
    reasoner1 )
    OntModel
    ontTestModel ModelFactory.createOntologyModel(sp
    ec, myModel)

13
OWL API
14
OWL API
  • Source Code Example
  • private ObjectProperty getAllPropertiesWithSameD
    omainAs(ObjectProperty oP)
    ObjectProperty oPznew ObjectProperty0
  • OntClass domainClasseslistDomainClasses(oP)
  • OntModel oMoP.getOntModel()
  • ExtendedIterator itoM.listObjectProperties()
  • while(it.hasNext())
  • ObjectProperty oP2(ObjectProperty)it.next()
  • if(oP2.getLocalName().compareTo(oP.getLocalName
    ())!0)
  • OntClass domainClasses2listDom
    ainClasses(oP2)
  • if(isSubclass(domainClasses,domainC
    lasses2))
  • oPzextendArray(oPz,oP2)
  • it.close()
  • return oPz

15
OWL API
16
OWL API
  • private String getAllSiblingClasses(OntClass
    Class2)
  • OntClass supClassClass2.getSuperClass()
  • int iNoOfSubClassessupClass.listSubClass
    es().toList().size()
  • String siblings new
    StringiNoOfSubClasses-1
  • int iCounter0
  • for(int i0 iltiNoOfSubClasses i)
  • OntClass oC(OntClass)supClass.listSu
    bClasses().toList().get(i)
  • if(!oC.equals(Class2))
  • siblingsiCounteroC.getLocalNam
    e()
  • iCounter
  • return siblings

17
RDF API
18
RDF API
  • ExtendedIterator iter ontModel1.listDatatypePro
    perties()
  • while(iter.hasNext())
  • DatatypeProperty dP
    (DatatypeProperty)iter.next()
  • if(dP.getRange().getLocalName().c
    ompareTo("int")0 dP.getRange().getLocalName()
    .compareTo("double")0)
  • String sProtnew
    String4
  • ExtendedIterator iter3
    ontModel1.listIndividuals()
  • while(iter3.hasNext())
  • OntResource oRes
    (OntResource)iter3.next()
  • NodeIterator
    sitoRes.listPropertyValues(dP)
  • while(sit.hasNext())
  • com.hp.hpl.jena.rdf.m
    odel.impl.LiteralImpl pr(com.hp.hpl.jena.rdf.mode
    l.impl.LiteralImpl)sit.next()
  • String
    sSubjectoRes.getLocalName()
  • String
    sObjectpr.getString()
  • String
    sPredicatedP.getLocalName()

19
Reasoning
  • Internal Reasoning
  • com.hp.hpl.jena.reasoner.ReasonerRegistry
    ,mediocre reasoning ability
  • Source Code Example
  • OntModelSpec spec new OntModelSpec(
    OntModelSpec.OWL_DL_MEM ) com.hp.hpl.jena.reasone
    r.Reasoner reasoner1 ReasonerRegistry.getOWLReas
    oner() spec.setReasoner( reasoner1 )
    ontTestModel ModelFactory.createOntologyModel(s
    pec, myModel)
  • External Reasoning
  • E.g.Pellet Reasoner, complete reasoning ability
  • Source Code Example
  • OntModelSpec spec new OntModelSpec(
    OntModelSpec.OWL_DL_MEM ) com.hp.hpl.jena.reasone
    r.Reasoner reasoner1 PelletReasonerFactory.theIn
    stance().create()spec.setReasoner( reasoner1 )
    ontTestModel ModelFactory.createOntologyModel(sp
    ec, myModel)

20
Application-oriented issues
  • Jena 2.5.4 used
  • One in memory RDF model used
  • A persistent model approach was initially
    introduced but was rejected
  • Two in memory ontology models used
  • One with a reasoner attached
  • One without reasoner
  • Pellet 1.5.1 reasoner used is some occasions only
    to determine subsumptions between subclasses and
    superclasses and their individuals respectively

21
Application-oriented issues
  • Only ontology files imported (OWL-DL)
  • No alterations on the imported ontology
  • Only Knowledge Extraction
  • Use of this knowledge to create Multiple Choice
    Questions
  • No SPARQL Queries developed

22
Application-oriented issues
  • Limited use of the RDF API
  • Used only to create ontology models and in some
    occasions to detect certain statements.
  • Extended use of the Ontology API
  • Knowledge extracted concerning
  • Classes
  • Individuals
  • Object Properties
  • Datatype Properties

23
Questions???
  • ??????????????????????????????????????????????????
    ???????????????__________?????????????????????????
    ??????????/__________\????????????????????????????
    ????/_/?????????\_\??????????????????????????????\
    _\?????????/_/???????????????????????????????\_\??
    ????/_/?????????????????????????????????????????/_
    /?????????????????????????????????????????/_/?????
    ?????????????????????????????????????_??????????
    ??????????????????????????????????????????????????
    ??????????????????????????????????????????????????
    ???????????????????????????_????????????????????
    ?
Write a Comment
User Comments (0)
About PowerShow.com