Class AutomatonTestUtil
java.lang.Object
org.apache.lucene.tests.util.automaton.AutomatonTestUtil
Utilities for testing automata.
Capable of generating random regular expressions, and automata, and also provides a number of very basic unoptimized implementations (*slow) for testing.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Lets you retrieve random strings accepted by an Automaton. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Default maximum number of states thatOperations.determinize(org.apache.lucene.util.automaton.Automaton, int)
should create. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Checks that an automaton has no detached states that are unreachable from the initial state.static Automaton
Simple, original brics implementation of determinize()static Automaton
determinizeSimple
(Automaton a, Set<Integer> initialset) Simple, original brics implementation of determinize() Determinizes the given automaton using the given set of initial states.getFiniteStringsRecursive
(Automaton a, int limit) Simple, original implementation of getFiniteStrings.static boolean
Returns true if the automaton is deterministic.static boolean
Returns true if the language of this automaton is finite.static Automaton
Simple, original brics implementation of Brzozowski minimize()static Automaton
randomAutomaton
(Random random) return a random NFA/DFA for testingstatic String
Returns random string, including full unicode range.
-
Field Details
-
DEFAULT_MAX_DETERMINIZED_STATES
public static final int DEFAULT_MAX_DETERMINIZED_STATESDefault maximum number of states thatOperations.determinize(org.apache.lucene.util.automaton.Automaton, int)
should create.- See Also:
-
-
Constructor Details
-
AutomatonTestUtil
public AutomatonTestUtil()
-
-
Method Details
-
randomRegexp
Returns random string, including full unicode range. -
randomAutomaton
return a random NFA/DFA for testing -
minimizeSimple
Simple, original brics implementation of Brzozowski minimize() -
determinizeSimple
Simple, original brics implementation of determinize() -
determinizeSimple
Simple, original brics implementation of determinize() Determinizes the given automaton using the given set of initial states. -
getFiniteStringsRecursive
Simple, original implementation of getFiniteStrings.Returns the set of accepted strings, assuming that at most
limit
strings are accepted. If more thanlimit
strings are accepted, the first limit strings found are returned. Iflimit
<0, then the limit is infinite.This implementation is recursive: it uses one stack frame for each digit in the returned strings (ie, max is the max length returned string).
-
isFiniteSlow
Returns true if the language of this automaton is finite.WARNING: this method is slow, it will blow up if the automaton is large. this is only used to test the correctness of our faster implementation.
-
assertNoDetachedStates
Checks that an automaton has no detached states that are unreachable from the initial state. -
isDeterministicSlow
Returns true if the automaton is deterministic.
-