de.fuberlin.wiwiss.semmf.engine
Class StringMatcher

java.lang.Object
  extended by de.fuberlin.wiwiss.semmf.engine.StringMatcher
All Implemented Interfaces:
Matcher

public class StringMatcher
extends java.lang.Object
implements Matcher

A class providing functionality for matching two semantically corresponding String values.

Version:
1.3 last modified 29.11.2006
Author:
Radoslaw Oldakowski

Field Summary
static boolean CASE_SENSITIVE
          These constants should be used while instancing a new StringMatcher
private  boolean caseSensitive
          Setting for a particular instance of StringMatcher
static boolean IGNORE_CASE
           
 
Constructor Summary
StringMatcher()
          Constructor with default setting = ignore case
StringMatcher(boolean caseSensitive)
          Constructor.
 
Method Summary
 float calcSim(com.hp.hpl.jena.rdf.model.RDFNode n1, com.hp.hpl.jena.rdf.model.RDFNode n2)
          Calculates the similarity of two given RDFNodes from Jena2 framework.
private  float calcStringSim(java.lang.String s1, java.lang.String s2)
          Calculates the similarity of two given strings according to the setting (case (in)sensitive) of this StringMatcher.
 boolean isCaseSensitive()
          Returns true if the matcher performs case sensitive matching
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CASE_SENSITIVE

public static final boolean CASE_SENSITIVE
These constants should be used while instancing a new StringMatcher

See Also:
Constant Field Values

IGNORE_CASE

public static final boolean IGNORE_CASE
See Also:
Constant Field Values

caseSensitive

private boolean caseSensitive
Setting for a particular instance of StringMatcher

Constructor Detail

StringMatcher

public StringMatcher()
Constructor with default setting = ignore case


StringMatcher

public StringMatcher(boolean caseSensitive)
Constructor. While insstancing a StringMatcher use the predefined constants

Parameters:
caseSensitive - indicates if the matching should be case sensitive or not.
Method Detail

calcStringSim

private float calcStringSim(java.lang.String s1,
                            java.lang.String s2)
Calculates the similarity of two given strings according to the setting (case (in)sensitive) of this StringMatcher. There are only two results possible, that is 1 if the given strings are identical or 0 if there are different.

Parameters:
s1 - string serialization of the node from the query graph
s2 - string serialization of the node from the resource graph
Returns:
the similarity of these nodes

isCaseSensitive

public boolean isCaseSensitive()
Returns true if the matcher performs case sensitive matching

Returns:
boolean

calcSim

public float calcSim(com.hp.hpl.jena.rdf.model.RDFNode n1,
                     com.hp.hpl.jena.rdf.model.RDFNode n2)
Calculates the similarity of two given RDFNodes from Jena2 framework. The similarity is based on the string serialization of these objects. Thus, in the case of two literals not only their value but moreover their language and datatype will be respected.

Specified by:
calcSim in interface Matcher
Parameters:
n1 - node from the query graph
n2 - node from the resource graph
Returns:
the similarity of these nodes