Class LCS

java.lang.Object
Services.Dependencies.LCS

public class LCS extends Object
Utility class for computing the Longest Common Substring (LCS) similarity between two character sequences.

This implementation returns a normalized similarity value between 0 and 1, calculated as the length of the longest common substring divided by the maximum length of the two input sequences.

  • Constructor Summary

    Constructors
    Constructor
    Description
    LCS()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    LCSubStr(char[] X, char[] Y, int m, int n)
    Computes the normalized longest common substring (LCS) similarity between two character arrays.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LCS

      public LCS()
  • Method Details

    • LCSubStr

      public static float LCSubStr(char[] X, char[] Y, int m, int n)
      Computes the normalized longest common substring (LCS) similarity between two character arrays.

      The method uses dynamic programming to calculate the length of the longest contiguous substring shared by X and Y. The result is then normalized by dividing by the maximum length of the two input arrays.

      Parameters:
      X - first character array
      Y - second character array
      m - length of the first array X
      n - length of the second array Y
      Returns:
      a float value between 0 and 1 representing the normalized longest common substring similarity