Module org.apache.lucene.core
Package org.apache.lucene.util.graph
Class GraphTokenStreamFiniteStrings
- java.lang.Object
-
- org.apache.lucene.util.graph.GraphTokenStreamFiniteStrings
-
public final class GraphTokenStreamFiniteStrings extends java.lang.Object
Consumes a TokenStream and creates anAutomaton
where the transition labels are terms from theTermToBytesRefAttribute
. This class also provides helpers to explore the different paths of theAutomaton
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
GraphTokenStreamFiniteStrings.FiniteStringsTokenStream
-
Field Summary
Fields Modifier and Type Field Description private Automaton
det
private static int
MAX_RECURSION_LEVEL
Maximum level of recursion allowed in recursive operations.private AttributeSource[]
tokens
private Transition
transition
-
Constructor Summary
Constructors Constructor Description GraphTokenStreamFiniteStrings(TokenStream in)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]
articulationPoints()
Returns the articulation points (or cut vertices) of the graph: https://en.wikipedia.org/wiki/Biconnected_componentprivate static void
articulationPointsRecurse(Automaton a, int state, int d, int[] depth, int[] low, int[] parent, java.util.BitSet visited, IntArrayList points)
private Automaton
build(TokenStream in)
Build an automaton from the providedTokenStream
.java.util.Iterator<TokenStream>
getFiniteStrings()
Get all finite strings from the automaton.java.util.Iterator<TokenStream>
getFiniteStrings(int startState, int endState)
Get all finite strings that start atstartState
and end atendState
.java.util.List<AttributeSource>
getTerms(int state)
Returns the list of tokens that start at the provided stateTerm[]
getTerms(java.lang.String field, int state)
Returns the list of terms that start at the provided stateboolean
hasSidePath(int state)
Returns whether the provided state is the start of multiple side paths of different length (eg: new york, ny)
-
-
-
Field Detail
-
MAX_RECURSION_LEVEL
private static final int MAX_RECURSION_LEVEL
Maximum level of recursion allowed in recursive operations.- See Also:
- Constant Field Values
-
tokens
private AttributeSource[] tokens
-
det
private final Automaton det
-
transition
private final Transition transition
-
-
Constructor Detail
-
GraphTokenStreamFiniteStrings
public GraphTokenStreamFiniteStrings(TokenStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
hasSidePath
public boolean hasSidePath(int state)
Returns whether the provided state is the start of multiple side paths of different length (eg: new york, ny)
-
getTerms
public java.util.List<AttributeSource> getTerms(int state)
Returns the list of tokens that start at the provided state
-
getTerms
public Term[] getTerms(java.lang.String field, int state)
Returns the list of terms that start at the provided state
-
getFiniteStrings
public java.util.Iterator<TokenStream> getFiniteStrings() throws java.io.IOException
Get all finite strings from the automaton.- Throws:
java.io.IOException
-
getFiniteStrings
public java.util.Iterator<TokenStream> getFiniteStrings(int startState, int endState)
Get all finite strings that start atstartState
and end atendState
.
-
articulationPoints
public int[] articulationPoints()
Returns the articulation points (or cut vertices) of the graph: https://en.wikipedia.org/wiki/Biconnected_component
-
build
private Automaton build(TokenStream in) throws java.io.IOException
Build an automaton from the providedTokenStream
.- Throws:
java.io.IOException
-
articulationPointsRecurse
private static void articulationPointsRecurse(Automaton a, int state, int d, int[] depth, int[] low, int[] parent, java.util.BitSet visited, IntArrayList points)
-
-