Home

Awesome

PRISSMA

Context-Aware Adaptation for Linked Data

PRISSMA is a presentation-level framework for Linked Data adaptation.

It is a Java rendering engine for RDF that selects the most appropriate presentation of RDF triples according to mobile context.

PRISSMA is compatible with the Fresnel vocabulary and is based on a graph edit distance algorithm that finds optimal error-tolerant subgraph isomorphisms between RDF context graphs.

PRISSMA is optimized for Android platforms, but can be used in regular Java Projects as well.

Installation

PRISSMA is a Java library, optimized for Android applications.

Minimum Requirements

Download

The latest PRISSMA release is v1.0.0. Download it and add it to your build path.

Make sure config.properties is included in your build path and that it contains the parameter values needed by the search algorithm (e.g. similarity threshold, cost of edit distance operations, etc).

Build from Source

Check out sources:

$ git clone https://github.com/lukostaz/prissma.git

PRISSMA depends on the Simmetrics and WS4J libraries, that are not available in Maven central. Simmetrics 1.6.2 and WS4J 1.0.1 are provided under libs/. You can install it in your local Maven repository:

$ cd prissma

$ mvn install:install-file \
      -Dfile=libs/simmetrics-1.6.2.jar \
      -DgroupId=simmetrics \
      -DartifactId=simmetrics \
      -Dversion=1.6.2 \
      -Dpackaging=jar

$ mvn install:install-file \
      -Dfile=libs/ws4j-1.0.1.jar \
      -DgroupId=ws4j \
      -DartifactId=ws4j \
      -Dversion=1.0.1 \
      -Dpackaging=jar

PRISSMA depends on the xerces-impl Android-optimized version available available here. A copy of the library is available under libs/. Add it to local Maven repository:

$ mvn install:install-file \
      -Dfile=libs/xercesImpl-repack.jar \
      -DgroupId=xerces \
      -DartifactId=xercesImpl-repack \
      -Dversion=1.0.0 \
      -Dpackaging=jar

Build and install the library in local Maven repository:

$ mvn install

Add the following dependency in your pom.xml:

<dependency>
    <groupId>fr.inria.wimmics</groupId>
    <artifactId>PRISSMA</artifactId>
    <version>1.0.0</version>
</dependency>

Designing Prisms

Prisms are context-aware presentation metadata for Linked Data visualization based on Fresnel and PRISSMA.

Prisms can be created manually, or with PRISSMA Studio.

Example

Prism to style a dbpedia:Museum when a user is walking in Paris.

First, define the Prism general information:

:museumPrism a prissma:Prism ;
   fresnel:purpose :walkingInParis ;
   fresnel:stylesheetLink  <style.css>.

Add some Fresnel Lenses:

:museumlens a fresnel:Lens;
   fresnel:group :museumPrism;
   fresnel:classLensDomain dbpedia:Museum;
   fresnel:showProperties (  
                     dbpprop:location 
                     dbpprop:publictransit 
                     ex:telephone
                     ex:openingHours
                     ex:ticketPrice ) .

Add Fresnel styling metadata:

:addressFormat a fresnel:Format ;
   fresnel:group :museumPrism ;
   fresnel:propertyFormatDomain 
                     dbpprop:location ;
   fresnel:label "Address" ;
   fresnel:labelStyle 
       "css-class1"^^fresnel:styleClass ;
   fresnel:valueStyle 
       "css-class2"^^fresnel:styleClass .

Finally, define a prissma:Context entity with the PRISSMA vocabulary:

# PRISSMA context description
:walkingInParisArtLover a prissma:Context ;
   prissma:user :artLover ; 
   prissma:environment :parisWalking .
    
:artLover a prissma:User ;
   foaf:interest "art".

:parisWalking a prissma:Environment ;
   prissma:poi :paris ;
   prissma:motion "walking" .
	
:paris geo:lat "48.8567" ;
   geo:long "2.3508" ;
   prissma:radius "5000" .

Save the Prism locally, and store it in the Decomposition structure as explained below.

API Overview

Make sure config.properties is included in your build path and that it contains the parameters values needed by the search algorithm (e.g. similarity threshold, cost of edit distance operations, etc).

Step 1: Decomposing Prisms

// Instantiate a decomposer
Decomposer decomposer = new Decomposer();
// The Decomposition is the shared data structure for Prisms
Decomposition decomp = new Decomposition();

// The inputPrism Jena Model is the Prism read from local repository
Model inputPrism = ModelFactory.createDefaultModel();

// Get the path of the Prism local repository on Android devices.
// If executed on desktop environment p is a regular file path string.
String p = Environment.getExternalStorageDirectory().getAbsolutePath();
InputStream in = FileManager.get().open( p + "/PRISSMA/prisms/prism.ttl" );

// Decompose the Prism
if (in != null) {
    inputPrism.read(in, null,  "TURTLE");
    decomp = decomposer.decompose(inputPrism, decomp);
}

Step 2: Running the search algorithm

// Read input context
Model actualCtx = ModelFactory.createDefaultModel();
InputStream inCtx = FileManager.get().open( p + "/PRISSMA/ctx/ctx1.ttl" );
if (inCtx != null) {
    actualCtx.read(inCtx, null,  "TURTLE");
}

// Instantiate an error-tolerant matcher with a decomposition
Matcher matcher = new Matcher(decomp);
// get the prissma:Context element, i.e. the root element of input context
RDFNode ctxRoot = ContextUnitConverter.getRootCtxNode(actualCtx);
// Covnert core PRISSMA entities to their PRISSMA classes
ctxRoot = ContextUnitConverter.switchToClasses(ctxRoot, decomp);
// Execute error-tolerant match against Prisms in the decomposition
matcher.search(ctxRoot);

Step 3: Rendering resources

// inputResource is the desired RDF resource to display.
Model prism = readPrismFromFS(matcher.results);
Renderer r = new Renderer();
String html = r.renderHTML(prism, inputResource, true);

Publications

Licence

Copyright (C) 2013-2015 Luca Costabello, v1.0.0

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, see <http://www.gnu.org/licenses/>.

Contacts

Further details on the PRISSMA Project Page, or contact Luca Costabello.