Class LCSPairing

java.lang.Object
com.betterdiff.core.pairing.Pairing
com.betterdiff.lyrics.pairing.LCSPairing
All Implemented Interfaces:
com.betterdiff.core.pairing.PairingPhase

public class LCSPairing
extends com.betterdiff.core.pairing.Pairing
Pairing based on longest common subsequence value (LCS) of two strings. The process can be simplified into these steps: 1) Both strings are shortened by selected method (ShorteningMethod). The method is selected based on the length of both strings. 2) LCS value is computed. 3) LCS value is multiplied by the length of the longer string. This value represents the percentage of equality. If the percentage is above 95% then an extra check is performed. Extra check. When two strings are vastly different in their length then LCS tend to be of a length of the shorter string. Due to this the percentage of equality is too inaccurate. Therefore a special computation is performed instead. This computation is based on the difference of length rather then on the longer string only. 4) When the percentage of equality is greater than weightMatching then the strings are considered similar and paired together. Note. LCSPairing is designed for lyrics or historical texts, because it's expected that the differences will be rather smaller with words misspelled, or moved, or deleted, rather than semantically different, but textually similar, like it would be with programming codes or generally random strings.
Author:
troomar
  • Constructor Summary

    Constructors
    Constructor Description
    LCSPairing​(com.betterdiff.core.preparation.PreparationPhase preparation, com.betterdiff.core.Callback callback)
    Default constructor with weight matching level of 70 (default value).
    LCSPairing​(com.betterdiff.core.preparation.PreparationPhase preparation, com.betterdiff.core.Callback callback, int weightMatching)
    Constructor with custom weight matching level.
  • Method Summary

    Modifier and Type Method Description
    Integer getWeightMatching()
    Returns set weight matching for this pairing.

    Methods inherited from class com.betterdiff.core.pairing.Pairing

    getChunkText, getPairedChunks, getProtocol, process

    Methods inherited from class java.lang.Object

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

    • LCSPairing

      public LCSPairing​(com.betterdiff.core.preparation.PreparationPhase preparation, com.betterdiff.core.Callback callback)
      Default constructor with weight matching level of 70 (default value).
      Parameters:
      preparation - Finished preparation phase.
      callback - Callback for logging purpose.
    • LCSPairing

      public LCSPairing​(com.betterdiff.core.preparation.PreparationPhase preparation, com.betterdiff.core.Callback callback, int weightMatching)
      Constructor with custom weight matching level.
      Parameters:
      preparation - Finished preparation phase.
      callback - Callback for logging purpose.
      weightMatching - Level of similarity when strings are considered similar. 0 means no similarity whatsoever, 95+ equality only. Default value is 70 (similarity of approx. 2/3)
  • Method Details

    • getWeightMatching

      public Integer getWeightMatching()
      Returns set weight matching for this pairing.
      Returns:
      Similarity level.