org.jscience.ml.tigerxml.tools
Class GeneralTools

java.lang.Object
  extended by org.jscience.ml.tigerxml.tools.GeneralTools

public class GeneralTools
extends java.lang.Object

Provides methods that might generally be useful when utilizing the org.jscience.ml.tigerxml. This class is for static use.


Constructor Summary
GeneralTools()
           
 
Method Summary
static java.lang.String getTimeStamp()
          Generate and return a string with current date and time.
static java.lang.String map2String(java.util.Map map)
          Converts a Map to a String.
static java.lang.String map2String(java.util.Map map, java.lang.String prefix)
          Converts a Map to a String.
static int minEditDistance(java.util.ArrayList listA, java.util.ArrayList listB)
          Compute the Minumum Edit Distance between two ArrayLists.
protected static int minimum(int a, int b, int c)
          Returns the minimum of three integer values.
static java.util.ArrayList sortNodes(java.util.ArrayList unsortedNodes)
          This static method accepts a list of GraphNodes and sorts it according to linear precedence.
static java.util.ArrayList sortTerminals(java.util.ArrayList unsortedTerminals)
          Sorts a given list of Terminals according to linear precedence.
static java.lang.String timeConvert(long time)
          Converts a time value given in ms into minutes and seconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralTools

public GeneralTools()
Method Detail

minimum

protected static int minimum(int a,
                             int b,
                             int c)
Returns the minimum of three integer values.


sortNodes

public static final java.util.ArrayList sortNodes(java.util.ArrayList unsortedNodes)
This static method accepts a list of GraphNodes and sorts it according to linear precedence.

In order to get a sorted copy of an ArrayList of Terminals use #sortTerminals(ArrayListunsortedTerminals)

Parameters:
unsortedNodes - The GraphNode ArrayList to be sorted.

sortTerminals

public static final java.util.ArrayList sortTerminals(java.util.ArrayList unsortedTerminals)
Sorts a given list of Terminals according to linear precedence. Applies Insertion Sort by using the position in the sentence as the sort key. Returns a sorted ArrayList without touching the original ArrayList.

Parameters:
unsortedTerminals - The ArrayList of terminal nodes to be sorted
Returns:
sortedTerminals The sorted version of unsortedTerminals

minEditDistance

public static final int minEditDistance(java.util.ArrayList listA,
                                        java.util.ArrayList listB)
Compute the Minumum Edit Distance between two ArrayLists. The returned integer is the number of operations (substitution, deletion or insertion) necessary to transform one list to the other. Note that the objects in the ArrayLists are treated as identical if and only if they refer to the same object (listA.get(i)==listB.get(j) has the value true).

The Minimum Edit Distance has been used as a measure for similarity between strings. For a detailed description of the algorithm see:

Robert A. Wagner and Michael J. Fischer. 1974.
The string-to-string correction problem.
Journal of the ACM, 21(1):168 173.

Parameters:
listA - The first ArrayList.
listB - The second ArrayList.
Returns:
The minimum number of operations to transform listA to listB.

timeConvert

public static java.lang.String timeConvert(long time)
Converts a time value given in ms into minutes and seconds.

Parameters:
time - A numerical value (long) representing milliseconds.
Returns:
A string like this: "15m30.110s"

getTimeStamp

public static final java.lang.String getTimeStamp()
Generate and return a string with current date and time.

Returns:
A String containing the current date and time.

map2String

public static java.lang.String map2String(java.util.Map map)
Converts a Map to a String. Maps can be AbstractMap, Attributes, HashMap, Hashtable, IdentityHashMap, RenderingHints, TreeMap or WeakHashMap

Parameters:
map - The Map to be printed.
Returns:
The String representing the given Map.

map2String

public static java.lang.String map2String(java.util.Map map,
                                          java.lang.String prefix)
Converts a Map to a String. Maps can be AbstractMap, Attributes, HashMap, Hashtable, IdentityHashMap, RenderingHints, TreeMap or WeakHashMap. Use prefix to add a String in front of each line.

Parameters:
map - The Map to be printed.
prefix - A String preceding each line.
Returns:
The String representing the given Map.