1 / 28

JENA REIFICATION API

Reification. JENA REIFICATION API. Reification. In these slides we take a look at Reification and how Reification is done in the Jena API Reification (in Jena) is the ability to treat a Statement as a Resource Reify - to regard (something abstract) as a material or concrete thing

gwidon
Download Presentation

JENA REIFICATION API

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Reification JENA REIFICATION API

  2. Reification • In these slides we take a look at Reification and how Reification is done in the Jena API • Reification (in Jena) is the ability to treat a Statement as a Resource • Reify - to regard (something abstract) as a material or concrete thing • As in ‘to make it real’

  3. rdf:subject R1 rdf:type rdf:predicate rdf:Statement rdf:object Reification • Then additional assertions can be made about this Statement • A Statement can be reified multiple times which allows different “manifestations” of that statement to be treated differently if required Stripes rdf:label ‘Stripes’ rdf:type Zebra

  4. Reification • RDF represents a reified statement as four statements with particular RDF properties and objects: statement (S, P, O), reified by resource R, is given by: • R rdf:type rdf:Statement • R rdf:subject S • R rdf:predicate P • R rdf:object O

  5. Reification • The purpose of a reified statement is to provide additional detail about the statement of interest. User selected properties are necessary – like Dublin Core • R rdf:type rdf:Statement • R rdf:subject S • R rdf:predicate P • R rdf:object O • R dc:creator ‘steven’ • R dc:date ’09/30/2009’ Apparently Steven made the statement (S, P, O) on 9/30/2009

  6. Multiple Reifications • Multiple reification nodes may refer to the same statement. This can show multiple provenance paths or be part of mechanisms involved in accumulating confidence regarding the statement. Apparently the statement (S, P, O) was reported by both a politician and street vendor. It appears someone has varying opinions about the reliability of the two independent sources of the statement.

  7. XML Example <?xml version="1.0"?> <!DOCTYPE rdf:RDF [<!ENTITY dc "http://purl.org/dc/elements/1.1/" >]> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:exterms="http://www.example.org/terms/" xmlns:other=“uri:"> <rdf:Description rdf:about="http://www.example.org/index.html"> <exterms:creation-date>August 16, 1999</exterms:creation-date> <dc:language>en</dc:language> <dc:creator rdf:resource="http://www.example.org/staffid/85740"/> </rdf:Description> <rdf:Statement rdf:about="A1"> <rdf:subject rdf:resource="http://www.example.org/index.html"/> <rdf:predicate rdf:resource="&dc;creator"/> <rdf:object rdf:resource="http://www.example.org/staffid/85740"/> <dc:creator>"Marty"</dc:creator> <other:creatorConfidenceInFact>"95%"</other:creatorConfidenceInFact> </rdf:Statement> </rdf:RDF>

  8. Jena Reification • Jena represents a reified statement as a reification quad and each component is a quadlet • Users can directly manipulate the quads in Jena or use the additional support that Jena provides • Jena optimizes the storage for the reification quads avoiding having to store the extra four statements for a single reified statement

  9. Reification • Jena uses the ReifiedStatement interface to represent a reified statement as a Jena resource • Jena provides a function to find the statement that is being reified using the function • ReifiedStatement::getStatement()

  10. Reification • Creating Reified Statements from a Resource in Jena • Consider a resource R associated with a reified statement but is itself not a ReifiedStatement object, case in which the resource can itself be directly converted to a reified statement • (ReifiedStatement) R.as(ReifiedStatement.class) • Knowing a resource name allows a ReifiedStatement object to be constructed without actually knowing the statement

  11. Reification • Creating Reified Statements from a Resource in Jena • If no associated reified statements actually exist the “Cannot reify exception” is thrown • To find out if a reification is possible we can use the predicate, RDFNode::canAs(ReifiedStatement.class)

  12. Reification • Testing Statements for Reification in Jena • Users may wish to test if a certain statement is reified • Methods such as Statement::isReified() or Model::isReified(Statment) return true iff the statement is reified in the model • The first method tests that the statement is reified in its own model while the second method tests that the statement is reified in the given model, it doesn’t test it in any other model

  13. Reification • Listing Reified Statements in Jena • Works the same way as listStatements() does • Returns a RSIterator object where each element is a ReifiedStatement and nextRS() delivers the reified statement • Statement::listReifiedStatements() – lists all reifications of the statement in the current model

  14. Reification • Listing Reified Statements in Jena • Model::listReifiedStatements() – lists all reified statements in this model • Model::listReifiedStatements(Statement s) – lists all reified statements reifying “s” in this model

  15. Reification • Creating Reified Statements from Statements in Jena • Reified statements do not necessarily have to be created by asserting their quads into a model; they can be directly created from their statements • Statement::createReifiedStatement() • Statement::createReifiedStatement(String)

  16. Reification • Creating Reified Statements from Statements in Jena • Model::createReifiedStatement(Statement) • Model::createReifiedStatement(String, Statement) • Each of the above functions returns a ReifiedStatement object who’s getStatement() method delivers the original statement

  17. Reification • Creating Reified Statements from Statements in Jena • If the methods use the form in which the String is non-null, the ReifiedStatement created is a named resource and the String is its URI else it is a bnode • The methods created on the Statement above create a ReifiedStatement in that Statement’s model, the ones on the model create the ReifiedStatement in that statement’s model

  18. Reification • Creating Reified Statements from Statements in Jena • It is not permitted for two different (non-equal) statements to be reified onto the same resource, an attempt at it causes the “AlreadyReifiedException” • The method Model::getAnyReifiedStatement(Statement) returns a reified statement for the given statement if it exists or creates a new one via a bnode

  19. Reification • Reification when models are copied • When a model is added to another model, the ordinary statements as well as the reified statements are copied • To avoid this we can use the function Model::add(Model m, boolean suppress) • If suppress is true, then the reified statements are not copied

  20. Reification • Removing Reified Statement in Jena • Two ways to remove reified statements • Statement::removeReification() • Model::removeAllReifications(Statement) • All reified statements belonging to the given statement are removed from the model

  21. Reification • Removing Reified Statements in Jena • Model::removeReification(ReifiedStatement) • Remove a particular statement only • Like Model::addModel(Model), the method model.remove(Model m) removes all reified statements of m from model and model.remove(m, true) does not

  22. Reification • Reification Styles in Jena • Jena models allow reification quads to be manifested as ReifiedStatements • In the same way, explicitly created ReificationStatements are visible as statement quads

  23. Reification • Reification Styles in Jena • But this is not what we always want • For some applications each statement may be reified in the same model as the statement and then a listStatements() gives back a bunch of quadlets which is inefficient and confusing • A different approach is to create the reified statements in a different model • A third approach is to use Reification Styles

  24. Reification • Reification Styles • Each model has a Reification Style as given in ModelFactory • There are three different styles • Standard – behaves most closely to the RDF standard • Convenient – reification quadlets are not visible in the listStatements(). Quadlets that are added to the model contribute to the ReifiedStatement construction • Minimal – reification quadlets play no role at all in the construction of ReifiedStatements, which can then be created only by methods discussed earlier

  25. Reification • Reification Styles • The method ModelFactory.createDefaultModel() takes an optional Style argument whose default is Standard • Similar methods to create a model like createFileModelMaker() and createMemModelMaker() also take Style arguments which are applied to every model they create • To expose the hidden reification quads as statements the method ModelFactory.withHiddenStatements(Model m) creates a new model with the hidden reification quads exposed

  26. Reification • Reified Relationships • Reified Relationships is a key requirement in many domains today • One way of implementing reified relationships is to introduce a relationship class that connects a source/subject with a target/object so that additional attributes can be attached to the relationship objects

  27. Reification • Input and Output for Reification • Writers have access to the complete set of Statements and are able to write out the quad components • Readers can call createReifiedStatement() when they detect a reification

  28. Reification • Performance • Jena intends to capture the reification quad components and store them in a form optimized for reification • In the case where a statement is completely reified only the implementation representation of the statement is stored • The function createReifiedStatement() is expected to bypass the construction and detection of the quad components, so that usually they do not come into existence

More Related