Class LCSubstringSolver

java.lang.Object
com.googlecode.concurrenttrees.solver.LCSubstringSolver

public class LCSubstringSolver extends Object
Finds the longest common substring in a collection of documents. See Longest common substring problem.

This class internally extends ConcurrentRadixTree and combines it with elements from ConcurrentSuffixTree, but implements its own traversal algorithm.

  • Field Details

  • Constructor Details

    • LCSubstringSolver

      public LCSubstringSolver(NodeFactory nodeFactory)
      Creates a new LCSubstringSolver which will use the given NodeFactory to create nodes.
      Parameters:
      nodeFactory - An object which creates Node objects on-demand, and which might return node implementations optimized for storing the values supplied to it for the creation of each node
  • Method Details

    • add

      public boolean add(CharSequence document)
      Adds a CharSequence document to the solver.
      Parameters:
      document - The CharSequence to add to the solver
      Returns:
      True if the document was added, false if it was not because it had been added previously
    • addSuffixesToRadixTree

      void addSuffixesToRadixTree(String keyAsString)
    • getLongestCommonSubstring

      public CharSequence getLongestCommonSubstring()
      Finds the longest common substring in the documents added to the solver so far.
      Returns:
      The longest common substring
    • createSetForOriginalKeys

      protected Set<String> createSetForOriginalKeys()