Class LCSubstringSolver
java.lang.Object
com.googlecode.concurrenttrees.solver.LCSubstringSolver
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final LCSubstringSolver.ConcurrentSuffixTreeImpl
<Set<String>> -
Constructor Summary
ConstructorsConstructorDescriptionLCSubstringSolver
(NodeFactory nodeFactory) Creates a newLCSubstringSolver
which will use the givenNodeFactory
to create nodes. -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(CharSequence document) Adds aCharSequence
document to the solver.(package private) void
addSuffixesToRadixTree
(String keyAsString) Finds the longest common substring in the documents added to the solver so far.
-
Field Details
-
suffixTree
-
originalDocuments
-
-
Constructor Details
-
LCSubstringSolver
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 Details
-
add
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
-
getLongestCommonSubstring
Finds the longest common substring in the documents added to the solver so far.- Returns:
- The longest common substring
-
createSetForOriginalKeys
-