de.fuberlin.wiwiss.semmf.engine
Class MatchingEngine

java.lang.Object
  extended by de.fuberlin.wiwiss.semmf.engine.MatchingEngine

public class MatchingEngine
extends java.lang.Object

Given a MatchingDescription this class performs semantic matching between a query graph and a set of resource graphs.

Version:
1.3 last modified 29.11.2006
Author:
Radoslaw Oldakowski

Nested Class Summary
private  class MatchingEngine.QueryCluster
           
private  class MatchingEngine.QueryGraph
           
private  class MatchingEngine.QueryNode
          A certain Node matching a particular pathExpr from a NodeMatchingDescription NOTE: There might be multiple QueryNodes matching the same pathExpr
private  class MatchingEngine.QueryProperty
           
 
Field Summary
private  GraphMatchingDescription gmd
          A MatchingDescription object containing all matching information based on which the engine performs the matching of a query graph against a set of resource graphs.
private  MatchingEngine.QueryGraph queryGraph
          This object stores all information from the query graph needed while matching against each resource graph.
private  com.hp.hpl.jena.rdf.model.Model queryModel
          Reference to the Jena Model holding the query graph
private  com.hp.hpl.jena.rdf.model.Model resModel
          Reference to the Jena Model holding all resource graphs
 
Constructor Summary
private MatchingEngine(GraphMatchingDescription gmd)
          Constructor.
  MatchingEngine(java.lang.String mdURL)
          Constructor
  MatchingEngine(java.lang.String mdURL, java.lang.String lang)
          Constructor
 
Method Summary
 MatchingResult exec()
          Executes the matching.
private  java.util.List findNodes(com.hp.hpl.jena.rdf.model.Model m, java.lang.String pathExpr)
          This method searches inside the Model m for RDFNodes matching the given RDQL path expression.
private  java.util.List findQueryNodes(java.lang.String pathExpr)
          Searches inside a query model for RDFNodes matching the given path expression
private  java.util.List findResGraphEntries(java.lang.String pathExpr)
           
private  java.util.List findResNodes(java.lang.String pathExpr, java.lang.String resGraphEntryURI)
          Searches inside a resource model for RDFNodes matching the given pathexpression
private  java.lang.String generateRDQLstring(java.lang.String pathExpr)
          Given a path expression this method generates a full RDQL query string.
private  com.hp.hpl.jena.rdf.model.RDFNode getPropertyValue(com.hp.hpl.jena.rdf.model.Model m, com.hp.hpl.jena.rdf.model.Resource r, java.lang.String propURI)
          This method is used to retrieve the value of a property of a given node (RDF resource).
private  MatchingEngine.QueryGraph loadQueryGraph(GraphMatchingDescription gmd)
          This method loads all values from the query graph into memory and stores them using instances of the helper classes.
private  void recalcClusterResult(ClusterMatchingResultImpl cmr, float weight)
          If a certain node has to be matched in a reversed manner and it so happens that not every resource graph contains this particular node than the weight of this node inside this cluster has to be redistributed over the remaining nodes with respect to their relative weights.
private static java.lang.String replaceAll(java.lang.String s, java.lang.String token, java.lang.String replacement)
          Replaces all occurances of a substring (token) inside an inputString
private  java.lang.String replaceGraphEntryPlaceholder(java.lang.String pathExpr, java.lang.String graphEntryURI)
          The general path expressions for resource nodes from a matching description contain a placeholder for the graph entry, which is replaced by this method with a particular graph entry URI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queryModel

private com.hp.hpl.jena.rdf.model.Model queryModel
Reference to the Jena Model holding the query graph


resModel

private com.hp.hpl.jena.rdf.model.Model resModel
Reference to the Jena Model holding all resource graphs


gmd

private GraphMatchingDescription gmd
A MatchingDescription object containing all matching information based on which the engine performs the matching of a query graph against a set of resource graphs.


queryGraph

private MatchingEngine.QueryGraph queryGraph
This object stores all information from the query graph needed while matching against each resource graph.

Constructor Detail

MatchingEngine

public MatchingEngine(java.lang.String mdURL)
Constructor

Parameters:
mdURL - location of the matching description in RDF/XML format

MatchingEngine

public MatchingEngine(java.lang.String mdURL,
                      java.lang.String lang)
Constructor

Parameters:
mdURL - location of the matching description
lang - serialization format of the matching description. Allowed values "RDF/XML", "N3", "N-TRIPLE".

MatchingEngine

private MatchingEngine(GraphMatchingDescription gmd)
Constructor.

Parameters:
gmd - object representing a matching description
Method Detail

exec

public MatchingResult exec()
Executes the matching.

Returns:
MatchingResult object

loadQueryGraph

private MatchingEngine.QueryGraph loadQueryGraph(GraphMatchingDescription gmd)
This method loads all values from the query graph into memory and stores them using instances of the helper classes.

Parameters:
gmd - GraphMatchingDescription
Returns:
an instance of the helper class QueryGraph

findResGraphEntries

private java.util.List findResGraphEntries(java.lang.String pathExpr)
Parameters:
pathExpr - path expression
Returns:
a List of RDFNodes which represent entries to resource graphs to be matched

findQueryNodes

private java.util.List findQueryNodes(java.lang.String pathExpr)
Searches inside a query model for RDFNodes matching the given path expression

Parameters:
pathExpr - RDQL path expression
Returns:
a List of RDFNodes

findResNodes

private java.util.List findResNodes(java.lang.String pathExpr,
                                    java.lang.String resGraphEntryURI)
Searches inside a resource model for RDFNodes matching the given pathexpression

Parameters:
pathExpr - RDQL path expression
resGraphEntryURI - URI of the entry node of a particular resource graph *
Returns:
a List of RDFNodes

findNodes

private java.util.List findNodes(com.hp.hpl.jena.rdf.model.Model m,
                                 java.lang.String pathExpr)
This method searches inside the Model m for RDFNodes matching the given RDQL path expression.

Parameters:
m - RDFModel on which the RDQL query is performed
pathExpr - RDQL path expression
Returns:
a List of all RDFNodes from Model m matching the given path expression

getPropertyValue

private com.hp.hpl.jena.rdf.model.RDFNode getPropertyValue(com.hp.hpl.jena.rdf.model.Model m,
                                                           com.hp.hpl.jena.rdf.model.Resource r,
                                                           java.lang.String propURI)
This method is used to retrieve the value of a property of a given node (RDF resource). NOTE: At this time only single property values are supported !!!!

Parameters:
m - Jena model in which the resource occurs
r - Jena Resource object
propURI - URI of the property
Returns:
Property value as an RDFNode object.

generateRDQLstring

private java.lang.String generateRDQLstring(java.lang.String pathExpr)
Given a path expression this method generates a full RDQL query string. NOTE: Because the path expression contains only full URI's the final query string does not contain any namespace declaration.

Parameters:
pathExpr - path expression
Returns:
a valid RDQL query string

replaceGraphEntryPlaceholder

private java.lang.String replaceGraphEntryPlaceholder(java.lang.String pathExpr,
                                                      java.lang.String graphEntryURI)
The general path expressions for resource nodes from a matching description contain a placeholder for the graph entry, which is replaced by this method with a particular graph entry URI

Parameters:
pathExpr - path expression
graphEntryURI - URI of the node which is the entry of the resource graph
Returns:
path expression for a particular resource graph

recalcClusterResult

private void recalcClusterResult(ClusterMatchingResultImpl cmr,
                                 float weight)
If a certain node has to be matched in a reversed manner and it so happens that not every resource graph contains this particular node than the weight of this node inside this cluster has to be redistributed over the remaining nodes with respect to their relative weights. This method redistributes the accumulated weight of all non existing nodes and recalculates the cluster similarity given the new node weights.

Parameters:
cmr - ClusterMatchingResult to be recalculated
weight - accumulated weight to be redistrubuted

replaceAll

private static java.lang.String replaceAll(java.lang.String s,
                                           java.lang.String token,
                                           java.lang.String replacement)
Replaces all occurances of a substring (token) inside an inputString

Parameters:
s - original string
token - String token to be replaced
replacement - String to replace the given token
Returns:
original string with the token replaced