Class BasicOperations
- java.lang.Object
-
- org.apache.lucene.util.automaton.BasicOperations
-
public final class BasicOperations extends java.lang.ObjectBasic automata operations.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddEpsilons(Automaton a, java.util.Collection<StatePair> pairs)Adds epsilon transitions to the given automaton.static Automatoncomplement(Automaton a)Returns a (deterministic) automaton that accepts the complement of the language of the given automaton.static Automatonconcatenate(java.util.List<Automaton> l)Returns an automaton that accepts the concatenation of the languages of the given automata.static Automatonconcatenate(Automaton a1, Automaton a2)Returns an automaton that accepts the concatenation of the languages of the given automata.static voiddeterminize(Automaton a)Determinizes the given automaton.static Automatonintersection(Automaton a1, Automaton a2)Returns an automaton that accepts the intersection of the languages of the given automata.static booleanisEmpty(Automaton a)Returns true if the given automaton accepts no strings.static booleanisEmptyString(Automaton a)Returns true if the given automaton accepts the empty string and nothing else.static booleanisTotal(Automaton a)Returns true if the given automaton accepts all strings.static Automatonminus(Automaton a1, Automaton a2)Returns a (deterministic) automaton that accepts the intersection of the language ofa1and the complement of the language ofa2.static Automatonoptional(Automaton a)Returns an automaton that accepts the union of the empty string and the language of the given automaton.static Automatonrepeat(Automaton a)Returns an automaton that accepts the Kleene star (zero or more concatenated repetitions) of the language of the given automaton.static Automatonrepeat(Automaton a, int min)Returns an automaton that acceptsminor more concatenated repetitions of the language of the given automaton.static Automatonrepeat(Automaton a, int min, int max)Returns an automaton that accepts betweenminandmax(including both) concatenated repetitions of the language of the given automaton.static booleanrun(Automaton a, java.lang.String s)Returns true if the given string is accepted by the automaton.static booleansameLanguage(Automaton a1, Automaton a2)Returns true if these two automata accept exactly the same language.static booleansubsetOf(Automaton a1, Automaton a2)Returns true if the language ofa1is a subset of the language ofa2.static Automatonunion(java.util.Collection<Automaton> l)Returns an automaton that accepts the union of the languages of the given automata.static Automatonunion(Automaton a1, Automaton a2)Returns an automaton that accepts the union of the languages of the given automata.
-
-
-
Method Detail
-
concatenate
public static Automaton concatenate(Automaton a1, Automaton a2)
Returns an automaton that accepts the concatenation of the languages of the given automata.Complexity: linear in number of states.
-
concatenate
public static Automaton concatenate(java.util.List<Automaton> l)
Returns an automaton that accepts the concatenation of the languages of the given automata.Complexity: linear in total number of states.
-
optional
public static Automaton optional(Automaton a)
Returns an automaton that accepts the union of the empty string and the language of the given automaton.Complexity: linear in number of states.
-
repeat
public static Automaton repeat(Automaton a)
Returns an automaton that accepts the Kleene star (zero or more concatenated repetitions) of the language of the given automaton. Never modifies the input automaton language.Complexity: linear in number of states.
-
repeat
public static Automaton repeat(Automaton a, int min)
Returns an automaton that acceptsminor more concatenated repetitions of the language of the given automaton.Complexity: linear in number of states and in
min.
-
repeat
public static Automaton repeat(Automaton a, int min, int max)
Returns an automaton that accepts betweenminandmax(including both) concatenated repetitions of the language of the given automaton.Complexity: linear in number of states and in
minandmax.
-
complement
public static Automaton complement(Automaton a)
Returns a (deterministic) automaton that accepts the complement of the language of the given automaton.Complexity: linear in number of states (if already deterministic).
-
minus
public static Automaton minus(Automaton a1, Automaton a2)
Returns a (deterministic) automaton that accepts the intersection of the language ofa1and the complement of the language ofa2. As a side-effect, the automata may be determinized, if not already deterministic.Complexity: quadratic in number of states (if already deterministic).
-
intersection
public static Automaton intersection(Automaton a1, Automaton a2)
Returns an automaton that accepts the intersection of the languages of the given automata. Never modifies the input automata languages.Complexity: quadratic in number of states.
-
sameLanguage
public static boolean sameLanguage(Automaton a1, Automaton a2)
Returns true if these two automata accept exactly the same language. This is a costly computation! Note also that a1 and a2 will be determinized as a side effect.
-
subsetOf
public static boolean subsetOf(Automaton a1, Automaton a2)
Returns true if the language ofa1is a subset of the language ofa2. As a side-effect,a2is determinized if not already marked as deterministic.Complexity: quadratic in number of states.
-
union
public static Automaton union(Automaton a1, Automaton a2)
Returns an automaton that accepts the union of the languages of the given automata.Complexity: linear in number of states.
-
union
public static Automaton union(java.util.Collection<Automaton> l)
Returns an automaton that accepts the union of the languages of the given automata.Complexity: linear in number of states.
-
determinize
public static void determinize(Automaton a)
Determinizes the given automaton.Worst case complexity: exponential in number of states.
-
addEpsilons
public static void addEpsilons(Automaton a, java.util.Collection<StatePair> pairs)
Adds epsilon transitions to the given automaton. This method adds extra character interval transitions that are equivalent to the given set of epsilon transitions.- Parameters:
pairs- collection ofStatePairobjects representing pairs of source/destination states where epsilon transitions should be added
-
isEmptyString
public static boolean isEmptyString(Automaton a)
Returns true if the given automaton accepts the empty string and nothing else.
-
isEmpty
public static boolean isEmpty(Automaton a)
Returns true if the given automaton accepts no strings.
-
isTotal
public static boolean isTotal(Automaton a)
Returns true if the given automaton accepts all strings.
-
run
public static boolean run(Automaton a, java.lang.String s)
Returns true if the given string is accepted by the automaton.Complexity: linear in the length of the string.
Note: for full performance, use the
RunAutomatonclass.
-
-