edu.stanford.nlp.util
Class LongestCommonSubstring

java.lang.Object
  extended byedu.stanford.nlp.util.LongestCommonSubstring

public class LongestCommonSubstring
extends Object

Similarity metric based on longest-common-substrings between two strings. Based on Edit Distance code taken from http://www.merriampark.com/ld.htm and the algorithm described in http://www2.toki.or.id/book/AlgDesignManual/BOOK/BOOK5/NODE208.HTM This class can be used as a Similarity class, or as a static class for computing arbitrary LCS.


Constructor Summary
LongestCommonSubstring()
           
 
Method Summary
static int LCS(String s, String t)
          Computes the longest common substring of s and t.
static void main(String[] args)
          For internal debugging purposes only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LongestCommonSubstring

public LongestCommonSubstring()
Method Detail

LCS

public static int LCS(String s,
                      String t)
Computes the longest common substring of s and t. The longest common substring of a and b is the longest run of characters that appear in order inside both a and b. Both a and b may have other extraneous characters along the way. This is like edit distance but with no substitution and a higher number means more similar. For example, the LCS of "abcD" and "aXbc" is 3 (abc).


main

public static void main(String[] args)
For internal debugging purposes only.



Stanford NLP Group