Class LCSubstringSolver
- java.lang.Object
-
- com.googlecode.concurrenttrees.solver.LCSubstringSolver
-
public class LCSubstringSolver extends java.lang.Object
Finds the longest common substring in a collection of documents. See Longest common substring problem. This class internally extendsConcurrentRadixTree
and combines it with elements fromConcurrentSuffixTree
, but implements its own traversal algorithm.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
LCSubstringSolver.ConcurrentSuffixTreeImpl<V>
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.Set<java.lang.String>
originalDocuments
(package private) LCSubstringSolver.ConcurrentSuffixTreeImpl<java.util.Set<java.lang.String>>
suffixTree
-
Constructor Summary
Constructors Constructor Description LCSubstringSolver(NodeFactory nodeFactory)
Creates a newLCSubstringSolver
which will use the givenNodeFactory
to create nodes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(java.lang.CharSequence document)
Adds aCharSequence
document to the solver.(package private) void
addSuffixesToRadixTree(java.lang.String keyAsString)
protected java.util.Set<java.lang.String>
createSetForOriginalKeys()
java.lang.CharSequence
getLongestCommonSubstring()
Finds the longest common substring in the documents added to the solver so far.
-
-
-
Field Detail
-
suffixTree
final LCSubstringSolver.ConcurrentSuffixTreeImpl<java.util.Set<java.lang.String>> suffixTree
-
originalDocuments
final java.util.Set<java.lang.String> originalDocuments
-
-
Constructor Detail
-
LCSubstringSolver
public LCSubstringSolver(NodeFactory nodeFactory)
Creates a newLCSubstringSolver
which will use the givenNodeFactory
to create nodes.- Parameters:
nodeFactory
- An object which createsNode
objects on-demand, and which might return node implementations optimized for storing the values supplied to it for the creation of each node
-
-
Method Detail
-
add
public boolean add(java.lang.CharSequence document)
Adds aCharSequence
document to the solver.- Parameters:
document
- TheCharSequence
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(java.lang.String keyAsString)
-
getLongestCommonSubstring
public java.lang.CharSequence getLongestCommonSubstring()
Finds the longest common substring in the documents added to the solver so far.- Returns:
- The longest common substring
-
createSetForOriginalKeys
protected java.util.Set<java.lang.String> createSetForOriginalKeys()
-
-