|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.semanticweb.owl.io.owl_rdf.OWLConsumer
This is yet another refactoring and reimplementation of the parser. This time, we're collecting all the triples up after parsing and stuffing them into a big data structure. It is likely that this is getting less and less efficient, and at some point we would be better moving to using a parser such as Jena that actually provides some optimised data structures for these kinds of things. However, in the short term it may be fruitful to have multiple implementations of parser.
This parser that doesn't even attempt to do any streaming. Instead it collects the triples as required and then processes them later.
This does introduce memory overhead, but makes the whole process of parsing much easier as we no longer have to make guesses or assumptions about the format of things.
Where it can, the parser will try and fix broken bits of syntax. For example, if we have untyped individuals, these will still be added to the ontology. However, the error handler will be informed of the problem. Thus if the parsing client wishes to strictly enforce, e.g. membership of OWL Lite, it can do so, but if it's happy to have the parser try and fix the problem it can simply ignore (or report) the problem.
In some situations, there are multiple ways in which the triples can be mapped into the data structures. The basic choice boils down to whether assertions about subclasses and equivalences are represented as either axioms or "class definitions". Of course, in terms of formal semantics, there is no difference, but it can be useful to preserve the users intention (see DAML+OIL is Not Enough).
In order to do this, the parser basically tries to identify situations where the triples have been produced via a mapping from the abstract syntax, as described in the OWL Abstract Syntax and Semantics document. As an example, a situation like:
<class id="a">
<intersectionOf rdf:parseType="Collection">
<class id="b"/>
<class id="c"/>
</intersectionOf>
</class>
can only arise from a statement of the form:
Class(a complete intersectionOf(b c))in the abstract syntax. Thus this is dealt with by adding information to the class rather than as an equivalence axiom. Note that this is the only place where intersectionOf can appear in an OWL lite ontology. The only situation where there is ambiguity is in:
<class id="a">
<subClassOf>
<intersectionOf rdf:parseType="Collection">
<class id="b"/>
<class id="c"/>
</intersectionOf>
</subClassOf>
</class>
In this case, these triples may arise from:
Class(a partial intersectionOf(b c))or
SubClass(a intersectionOf(b c))The parser will choose the former wherever it can, on the basis that information relating to the class is then kept in one place.
Limitations and known issues/bugs
Note also that this parser is really targeted at parsing OWL-DL (and Lite) ontologies. If given an OWL-RDF which is actually Full, some of the information in the triples may be ignored or interpreted in a particular way. If this does occur, however, warnings or errors will be communicated to the error handler of the parser.
| Nested Class Summary | |
protected class |
OWLConsumer.LiteralTriple
|
protected class |
OWLConsumer.Triple
|
| Field Summary | |
protected OWLRDFErrorHandler |
handler
|
protected Map |
stringsToURIs
|
protected int |
tripleCount
|
protected static int |
tripleCountChunk
|
| Constructor Summary | |
OWLConsumer(OWLOntology onto)
Create a new consumer that will parse into the given ontology |
|
| Method Summary | |
protected void |
additionalParsingHook()
This function provides a hook for parser extensions. |
protected void |
addLiteralTriple(URI s,
URI p,
String o,
String l,
String dt)
|
void |
addModelAttribte(String arg0,
String arg1)
|
protected void |
addToMap(Map map,
Object key,
Object value)
|
protected void |
addTriple(URI s,
URI p,
URI o)
|
protected void |
applyChange(OntologyChange oc)
|
protected void |
checkAndConsumeBNode(URI bnode)
Check to see if the given node is a bnode, and if so, whether it's been used before. |
protected void |
checkBooleans()
Check that any booleans are declared properly. |
protected void |
checkForMalformedLists()
|
protected void |
checkForOneOfs()
Check that any oneOfs are declared properly. |
protected void |
checkForRDFProperties()
Check that any properties declared using rdf:Property have also been dealt with properly. |
protected void |
checkForRDFSClasses()
Check that anything declared as an rdfs:Class has been dealt with properly. |
protected void |
checkForUndefinedClasses()
|
protected void |
checkForUndefinedDataProperties()
|
protected void |
checkForUndefinedObjectProperties()
|
protected void |
checkForUndefinedOntologies()
|
protected void |
checkForUntypedIndividuals()
|
protected void |
createAnnotationInstance(OWLOntology onto,
URI subject,
URI predicate,
Object object)
|
protected OWLAnnotationProperty |
createAnnotationProperty(OWLOntology onto,
URI uri)
|
protected OWLClass |
createClass(OWLOntology onto,
URI uri)
Method createClass. |
protected OWLDataProperty |
createDataProperty(OWLOntology onto,
URI uri)
|
protected void |
createDataPropertyInstance(OWLOntology onto,
URI subject,
URI predicate,
String datatype,
String language,
String object)
|
protected OWLDataType |
createDatatype(OWLOntology onto,
URI uri)
Method createDatatype. |
protected void |
createDifferentFrom(OWLOntology onto,
URI subj,
URI obj)
|
protected void |
createDomain(OWLOntology onto,
URI property,
URI domain)
|
protected void |
createEquivalentProperty(OWLOntology onto,
URI subj,
URI obj)
|
protected void |
createInverseOf(OWLOntology onto,
URI subj,
URI obj)
We assume that inverse of must apply to object properties. |
protected OWLObjectProperty |
createObjectProperty(OWLOntology onto,
URI uri)
|
protected void |
createOntology(OWLOntology onto,
String subj)
Method createOntology. |
protected void |
createPropertyInstance(OWLOntology onto,
URI subj,
URI pred,
URI obj)
|
protected void |
createRange(OWLOntology onto,
URI property,
URI range)
Method createRange. |
protected void |
createSameIndividualAs(OWLOntology onto,
URI subj,
URI obj)
Method createSameIndividualAs. |
protected void |
createSubProperty(OWLOntology onto,
URI subj,
URI obj)
|
protected String |
dumpTriples()
|
void |
endModel()
|
protected void |
error(String message)
|
protected OWLClass |
getAndAssumeOWLClass(URI uri)
|
protected Set |
getByPredicate(String predicate)
|
protected Set |
getByPredicate(URI predicate)
|
protected Set |
getLiterals(String subject,
String predicate)
|
protected Set |
getLiterals(URI subject,
URI predicate)
|
protected Set |
getObjects(String subject,
String predicate)
|
protected Set |
getObjects(URI subject,
URI predicate)
|
protected OWLAnnotationProperty |
getOrCreateAnnotationProperty(URI uri)
|
protected OWLDataProperty |
getOrCreateDataProperty(URI uri)
|
protected OWLObjectProperty |
getOrCreateObjectProperty(URI uri)
|
protected OWLProperty |
getProperty(URI uri)
Returns a property with the given uri if it is created in the ontology null otherwise |
protected Object |
getSingletonObject(Set s)
|
protected Set |
getSubjects(String predicate,
String object)
|
protected Set |
getSubjects(URI predicate,
URI object)
|
protected OWLConsumer.Triple |
getTriple(String subject,
String predicate,
String object)
|
protected OWLConsumer.Triple |
getTriple(URI subject,
URI predicate,
URI object)
|
protected void |
importOntology(OWLOntology onto,
URI subj,
URI obj)
Method importOntology. |
void |
includeModel(String arg0,
String arg1)
|
protected boolean |
isAnonymousNode(String str)
|
protected boolean |
isObject(URI object)
|
protected boolean |
languageMachineryType(URI uri)
Returns true if it's the uri of one of a number of language things |
void |
logicalURI(String arg0)
|
protected URI |
newURI(String u)
|
protected void |
owlFullConstruct(int code,
String message)
|
protected void |
owlFullConstruct(int code,
String message,
Object obj)
|
protected int |
parseInt(String str,
String type)
|
protected void |
rdfListToSet(URI start,
Set mySet)
Takes a URI that should be the URI of an RDF listm and returns a collection of those things that form the elements of the list. |
protected void |
releaseTripleModel()
|
protected void |
setAssumptions(HashSet[] assumptions)
Set the assumptions that this consumer should be making about the objects that its parsing. |
protected void |
setCheckDefinitions(boolean b)
|
void |
setIncludeAnnotationContent(boolean b)
Control whether the consumer should include data annotatations. |
void |
setOWLRDFErrorHandler(OWLRDFErrorHandler h)
|
void |
setOWLRDFParser(OWLRDFParser p)
|
void |
startModel(String arg0)
|
void |
statementWithLiteralValue(String subject,
String predicate,
String object,
String language,
String datatype)
Called when a statement with literal value is added to the model. |
void |
statementWithResourceValue(String subj,
String pred,
String obj)
|
protected OWLDescription |
translateCardinalityRestriction(URI uri,
URI propURI,
int type,
boolean obj)
|
protected OWLDataRange |
translateDataRange(URI range)
|
protected OWLDescription |
translateDescription(URI uri)
Returns an OWLDescription that corresponds to the given URI. |
protected OWLIndividual |
translateIndividual(URI uri)
|
protected OWLDescription |
translateRestriction(URI uri,
URI propURI,
int type,
boolean obj)
Returns a translation of the given URI |
protected boolean |
tripleExists(String subject,
String predicate)
|
protected boolean |
tripleExists(String subject,
String predicate,
String object)
|
protected boolean |
tripleExists(URI subject,
URI predicate)
|
protected boolean |
tripleExists(URI subject,
URI predicate,
URI object)
|
protected Set |
uriToClassSet(Set uriSet)
Takes a URI representing a list of descriptions and returns a collection of descriptions obtained by translating those descriptions. |
Set |
uriToIndividualSet(Set uriSet)
|
protected void |
warning(String message)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int tripleCount
protected static int tripleCountChunk
protected Map stringsToURIs
protected OWLRDFErrorHandler handler
| Constructor Detail |
public OWLConsumer(OWLOntology onto)
throws OWLException
| Method Detail |
public void setOWLRDFParser(OWLRDFParser p)
public void setIncludeAnnotationContent(boolean b)
protected void owlFullConstruct(int code,
String message)
throws SAXException
SAXException
protected void owlFullConstruct(int code,
String message,
Object obj)
throws SAXException
SAXException
protected void error(String message)
throws SAXException
SAXException
protected void warning(String message)
throws SAXException
SAXExceptionpublic void setOWLRDFErrorHandler(OWLRDFErrorHandler h)
protected void rdfListToSet(URI start,
Set mySet)
throws SAXException
SAXException
protected Set uriToClassSet(Set uriSet)
throws SAXException
SAXException
public Set uriToIndividualSet(Set uriSet)
throws SAXException
SAXExceptionprotected void setAssumptions(HashSet[] assumptions)
protected void setCheckDefinitions(boolean b)
public void startModel(String arg0)
throws SAXException
startModel in interface edu.unika.aifb.rdf.api.syntax.RDFConsumerSAXExceptionRDFConsumer.startModel(String)
protected OWLProperty getProperty(URI uri)
throws OWLException
OWLException
public void endModel()
throws SAXException
endModel in interface edu.unika.aifb.rdf.api.syntax.RDFConsumerSAXExceptionRDFConsumer.endModel()
protected OWLDescription translateDescription(URI uri)
throws SAXException
SAXException
protected OWLDescription translateRestriction(URI uri,
URI propURI,
int type,
boolean obj)
throws SAXException
SAXException
protected OWLDescription translateCardinalityRestriction(URI uri,
URI propURI,
int type,
boolean obj)
throws SAXException
SAXException
protected OWLIndividual translateIndividual(URI uri)
throws SAXException
SAXException
protected OWLDataRange translateDataRange(URI range)
throws OWLException,
SAXException
OWLException
SAXException
public void statementWithResourceValue(String subj,
String pred,
String obj)
throws SAXException
statementWithResourceValue in interface edu.unika.aifb.rdf.api.syntax.RDFConsumerSAXExceptionRDFConsumer.statementWithResourceValue(String, String, String)
public void statementWithLiteralValue(String subject,
String predicate,
String object,
String language,
String datatype)
throws SAXException
statementWithLiteralValue in interface edu.unika.aifb.rdf.api.syntax.RDFConsumersubject - URI of the subject resourcepredicate - URI of the predicate resourceobject - literal object valuelanguage - the language
SAXException
protected void createPropertyInstance(OWLOntology onto,
URI subj,
URI pred,
URI obj)
throws SAXException
SAXException
protected void createSameIndividualAs(OWLOntology onto,
URI subj,
URI obj)
throws SAXException
onto - subj - obj -
SAXException
protected void createInverseOf(OWLOntology onto,
URI subj,
URI obj)
throws SAXException
SAXException
protected void createDifferentFrom(OWLOntology onto,
URI subj,
URI obj)
throws SAXException
SAXException
protected void createEquivalentProperty(OWLOntology onto,
URI subj,
URI obj)
throws SAXException
SAXException
protected void createSubProperty(OWLOntology onto,
URI subj,
URI obj)
throws SAXException
SAXException
protected void createRange(OWLOntology onto,
URI property,
URI range)
throws SAXException
onto -
SAXException
protected void createDomain(OWLOntology onto,
URI property,
URI domain)
throws SAXException
SAXException
protected void importOntology(OWLOntology onto,
URI subj,
URI obj)
throws SAXException
onto - subj - obj -
SAXException
protected OWLObjectProperty createObjectProperty(OWLOntology onto,
URI uri)
protected OWLAnnotationProperty createAnnotationProperty(OWLOntology onto,
URI uri)
protected OWLDataProperty createDataProperty(OWLOntology onto,
URI uri)
throws SAXException
SAXException
protected OWLObjectProperty getOrCreateObjectProperty(URI uri)
throws SAXException
SAXException
protected OWLAnnotationProperty getOrCreateAnnotationProperty(URI uri)
throws SAXException
SAXException
protected OWLDataProperty getOrCreateDataProperty(URI uri)
throws SAXException
SAXException
protected void createOntology(OWLOntology onto,
String subj)
throws SAXException
onto - subj -
SAXException
protected OWLClass createClass(OWLOntology onto,
URI uri)
throws SAXException
onto -
SAXException
protected OWLDataType createDatatype(OWLOntology onto,
URI uri)
throws SAXException
onto -
SAXException
protected void createDataPropertyInstance(OWLOntology onto,
URI subject,
URI predicate,
String datatype,
String language,
String object)
throws SAXException
SAXException
protected void createAnnotationInstance(OWLOntology onto,
URI subject,
URI predicate,
Object object)
throws SAXException
SAXException
public void logicalURI(String arg0)
throws SAXException
logicalURI in interface edu.unika.aifb.rdf.api.syntax.RDFConsumerSAXExceptionRDFConsumer.logicalURI(String)
public void includeModel(String arg0,
String arg1)
throws SAXException
includeModel in interface edu.unika.aifb.rdf.api.syntax.RDFConsumerSAXExceptionRDFConsumer.includeModel(String, String)
public void addModelAttribte(String arg0,
String arg1)
throws SAXException
addModelAttribte in interface edu.unika.aifb.rdf.api.syntax.RDFConsumerSAXExceptionRDFConsumer.addModelAttribte(String, String)
protected void applyChange(OntologyChange oc)
throws OWLException
OWLException
protected OWLClass getAndAssumeOWLClass(URI uri)
throws SAXException
SAXExceptionprotected boolean isAnonymousNode(String str)
protected void addToMap(Map map,
Object key,
Object value)
protected Object getSingletonObject(Set s)
protected void checkForUntypedIndividuals()
throws SAXException
SAXException
protected void checkForUndefinedOntologies()
throws SAXException
SAXException
protected void checkForUndefinedClasses()
throws SAXException
SAXException
protected void checkForUndefinedObjectProperties()
throws SAXException
SAXException
protected void checkForUndefinedDataProperties()
throws SAXException
SAXException
protected void checkForRDFProperties()
throws SAXException
SAXException
protected void checkForRDFSClasses()
throws SAXException
SAXException
protected void checkForOneOfs()
throws SAXException
SAXException
protected void checkBooleans()
throws SAXException
SAXException
protected void checkForMalformedLists()
throws SAXException
SAXExceptionprotected void releaseTripleModel()
protected void addTriple(URI s,
URI p,
URI o)
throws SAXException
SAXException
protected void addLiteralTriple(URI s,
URI p,
String o,
String l,
String dt)
protected Set getSubjects(String predicate,
String object)
throws SAXException
SAXException
protected Set getSubjects(URI predicate,
URI object)
protected Set getObjects(String subject,
String predicate)
throws SAXException
SAXException
protected Set getObjects(URI subject,
URI predicate)
protected Set getLiterals(String subject,
String predicate)
throws SAXException
SAXException
protected Set getLiterals(URI subject,
URI predicate)
protected Set getByPredicate(URI predicate)
protected Set getByPredicate(String predicate)
throws SAXException
SAXException
protected boolean isObject(URI object)
throws SAXException
SAXException
protected boolean tripleExists(String subject,
String predicate)
throws SAXException
SAXException
protected boolean tripleExists(URI subject,
URI predicate)
throws SAXException
SAXException
protected boolean tripleExists(URI subject,
URI predicate,
URI object)
throws SAXException
SAXException
protected boolean tripleExists(String subject,
String predicate,
String object)
throws SAXException
SAXException
protected OWLConsumer.Triple getTriple(URI subject,
URI predicate,
URI object)
throws SAXException
SAXException
protected OWLConsumer.Triple getTriple(String subject,
String predicate,
String object)
throws SAXException
SAXExceptionprotected String dumpTriples()
protected boolean languageMachineryType(URI uri)
protected int parseInt(String str,
String type)
throws SAXException
SAXException
protected void checkAndConsumeBNode(URI bnode)
throws SAXException
SAXException
protected URI newURI(String u)
throws URISyntaxException
URISyntaxException
protected void additionalParsingHook()
throws SAXException
SAXException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||