messif.objects.impl
Class ObjectStringEditDist

java.lang.Object
  extended by messif.objects.UniqueID
      extended by messif.objects.AbstractObject
          extended by messif.objects.LocalAbstractObject
              extended by messif.objects.impl.ObjectString
                  extended by messif.objects.impl.ObjectStringEditDist
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<UniqueID>, BinarySerializable, Clearable

public class ObjectStringEditDist
extends ObjectString

Object with string content and edit distance metric function. See relevant literature (e.g. a book "Similarity Search: The Metric Space Approach") for a definition of the edit distance function.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class messif.objects.LocalAbstractObject
LocalAbstractObject.DataEqualObject
 
Field Summary
 
Fields inherited from class messif.objects.impl.ObjectString
text
 
Fields inherited from class messif.objects.LocalAbstractObject
counterDistanceComputations, counterLowerBoundDistanceComputations, counterUpperBoundDistanceComputations, MAX_DISTANCE, MIN_DISTANCE, suppData, UNKNOWN_DISTANCE
 
Constructor Summary
ObjectStringEditDist()
          Creates a new instance of ObjectStringEditDist with randomly generated string content.
ObjectStringEditDist(java.io.BufferedReader stream)
          Creates a new instance of ObjectString from text stream.
ObjectStringEditDist(int minLength, int maxLength)
          Creates a new instance of ObjectStringEditDist with randomly generated string content.
ObjectStringEditDist(java.lang.String text)
          Creates a new instance of ObjectStringEditDist.
 
Method Summary
protected  float getDistanceImpl(LocalAbstractObject obj, float distThreshold)
          The actual implementation of the metric function (see LocalAbstractObject.getDistance(messif.objects.LocalAbstractObject) for full explanation).
protected  float getDistanceLowerBoundImpl(LocalAbstractObject obj, int accuracy)
          Implementation that actually computes the lower bound on the metric distance.
protected  float getDistanceUpperBoundImpl(LocalAbstractObject obj, int accuracy)
          Implementation that actually computes the upper bound on the metric distance.
protected  int getChangeWeight(char chr1, char chr2)
          Returns the weight of changing char1 into char2 during the edit distance computation.
protected  int getInsertDeleteWeight()
          Returns the weight of deleting or inserting a character during the edit distance computation.
 
Methods inherited from class messif.objects.impl.ObjectString
binarySerialize, cloneRandomlyModify, dataEquals, dataHashCode, generateRandom, getBinarySize, getSize, getStringData, getStringLength, toString, writeData
 
Methods inherited from class messif.objects.LocalAbstractObject
clearSurplusData, clone, clone, create, create, createMetaDistancesHolder, excludeUsingPrecompDist, getDistance, getDistance, getDistance, getDistanceFilter, getDistanceFilter, getDistanceFilter, getDistanceLowerBound, getDistanceUpperBound, getMaxDistance, getNormDistance, getRandomChar, getRandomNormal, chainDestroy, chainFilter, includeUsingPrecompDist, readObjectComments, unchainFilter, write, write
 
Methods inherited from class messif.objects.AbstractObject
clone, getLocatorURI, getNoDataObject, getObjectID, getObjectKey, setObjectKey
 
Methods inherited from class messif.objects.UniqueID
compareTo, equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectStringEditDist

public ObjectStringEditDist(java.lang.String text)
Creates a new instance of ObjectStringEditDist.

Parameters:
text - the string content of the new object

ObjectStringEditDist

public ObjectStringEditDist()
Creates a new instance of ObjectStringEditDist with randomly generated string content.


ObjectStringEditDist

public ObjectStringEditDist(int minLength,
                            int maxLength)
Creates a new instance of ObjectStringEditDist with randomly generated string content. The string content is genereated with at least minLength characters and at most maxLength characters.

Parameters:
minLength - minimal length of the randomly generated string content
maxLength - maximal length of the randomly generated string content

ObjectStringEditDist

public ObjectStringEditDist(java.io.BufferedReader stream)
                     throws java.io.EOFException,
                            java.io.IOException
Creates a new instance of ObjectString from text stream.

Parameters:
stream - the stream from which to read lines of text
Throws:
java.io.EOFException - if the end-of-file of the given stream is reached
java.io.IOException - if there was an I/O error during reading from the stream
Method Detail

getChangeWeight

protected int getChangeWeight(char chr1,
                              char chr2)
Returns the weight of changing char1 into char2 during the edit distance computation. The returned value must be greater than or equal to zero and must be symetric, that is getChangeWeight(x,y) == getChangeWeight(y,x).

Parameters:
chr1 - the source character
chr2 - the target character
Returns:
the weight of changing char1 into char2

getInsertDeleteWeight

protected int getInsertDeleteWeight()
Returns the weight of deleting or inserting a character during the edit distance computation. The returned value must be greater than or equal to zero.

Returns:
the weight of deleting or inserting a character

getDistanceImpl

protected float getDistanceImpl(LocalAbstractObject obj,
                                float distThreshold)
Description copied from class: LocalAbstractObject
The actual implementation of the metric function (see LocalAbstractObject.getDistance(messif.objects.LocalAbstractObject) for full explanation). The implementation should not increment distanceComputations statistics.

Specified by:
getDistanceImpl in class LocalAbstractObject
Parameters:
obj - the object to compute distance to
distThreshold - the threshold value on the distance
Returns:
the actual distance between obj and this if the distance is lower than distThreshold

getDistanceLowerBoundImpl

protected float getDistanceLowerBoundImpl(LocalAbstractObject obj,
                                          int accuracy)
Description copied from class: LocalAbstractObject
Implementation that actually computes the lower bound on the metric distance.

Overrides:
getDistanceLowerBoundImpl in class LocalAbstractObject
Parameters:
obj - the object to compute lower-bound distance to
accuracy - the level of precision to use for lower-bound
Returns:
the lower bound of the distance between this object and obj

getDistanceUpperBoundImpl

protected float getDistanceUpperBoundImpl(LocalAbstractObject obj,
                                          int accuracy)
Description copied from class: LocalAbstractObject
Implementation that actually computes the upper bound on the metric distance.

Overrides:
getDistanceUpperBoundImpl in class LocalAbstractObject
Parameters:
obj - the object to compute upper-bound distance to
accuracy - the level of precision to use for upper-bound
Returns:
the upper bound of the distance between this object and obj