Operations

object Operations

Automata operations.

Types

Link copied to clipboard
data class OpsTimingSummary(val unionListNs: Long, val unionListCopyNs: Long, val unionListRemoveDeadNs: Long, val unionListMergeAcceptNs: Long, val getLiveStatesNs: Long, val getLiveStatesFromInitialNs: Long, val getLiveStatesToAcceptNs: Long, val getLiveStatesToAcceptReverseCreateStatesNs: Long, val getLiveStatesToAcceptReverseTransitionsNs: Long, val getLiveStatesToAcceptReverseGetNextTransitionNs: Long, val getLiveStatesToAcceptReverseAddTransitionNs: Long, val getLiveStatesToAcceptReverseFinishNs: Long, val getLiveStatesToAcceptSeedAcceptStatesNs: Long, val getLiveStatesToAcceptBfsNs: Long, val getLiveStatesToAcceptBfsGetNextTransitionNs: Long, val removeDeadStatesNs: Long, val removeDeadBuildStatesNs: Long, val removeDeadCopyTransitionsNs: Long, val removeDeadGetNextTransitionNs: Long, val removeDeadAddTransitionNs: Long, val mergeAcceptNoTransitionsNs: Long, val mergeAcceptScanAcceptNs: Long, val mergeAcceptCopyStatesNs: Long, val mergeAcceptRemapStatesNs: Long, val mergeAcceptCopyTransitionsNs: Long, val mergeAcceptGetNextTransitionNs: Long, val mergeAcceptRemapDestNs: Long, val mergeAcceptAddTransitionNs: Long, val reverseBuilderFinishTotalNs: Long, val reverseBuilderFinishCreateStatesNs: Long, val reverseBuilderFinishSortTransitionsNs: Long, val reverseBuilderFinishEmitTransitionsNs: Long, val reverseBuilderFinishFinishStateNs: Long)

Properties

Link copied to clipboard

Default maximum effort that Operations.determinize should spend before giving up and throwing TooComplexToDeterminizeException.

Functions

Link copied to clipboard
fun complement(a: Automaton, determinizeWorkLimit: Int): Automaton

Returns a (deterministic) automaton that accepts the complement of the language of the given automaton.

Link copied to clipboard

Returns an automaton that accepts the concatenation of the languages of the given automata.

Link copied to clipboard
fun determinize(a: Automaton, workLimit: Int): Automaton

Determinizes the given automaton.

Link copied to clipboard

Returns the longest string that is a prefix of all accepted strings and visits each state at most once. The automaton must not have dead states. If this automaton has already been converted to UTF-8 (e.g. using UTF32ToUTF8) then you should use .getCommonPrefixBytesRef instead.

Link copied to clipboard

Returns the longest BytesRef that is a prefix of all accepted strings and visits each state at most once.

Link copied to clipboard

Returns the longest BytesRef that is a suffix of all accepted strings. Worst case complexity: quadratic with number of states+transitions.

Link copied to clipboard

If this automaton accepts a single input, return it. Else, return null. The automaton must be deterministic.

Link copied to clipboard

Returns true if this automaton has any states that cannot be reached from the initial state or cannot reach an accept state. Cost is O(numTransitions+numStates).

Link copied to clipboard

Returns true if there are dead states reachable from an initial state.

Link copied to clipboard

Returns true if there are dead states that reach an accept state.

Link copied to clipboard

Returns an automaton that accepts the intersection of the languages of the given automata. Never modifies the input automata languages.

Link copied to clipboard

Returns true if the given automaton accepts no strings.

Link copied to clipboard

Returns true if the given automaton accepts all strings.

fun isTotal(a: Automaton, minAlphabet: Int, maxAlphabet: Int): Boolean

Returns true if the given automaton accepts all strings for the specified min/max range of the alphabet.

Link copied to clipboard

Merge all accept states that don't have outgoing transitions to a single shared state. This is a subset of minimization that is much cheaper. This helper is useful because operations like concatenation need to connect accept states of an automaton with the start state of the next one, so having fewer accept states makes the produced automata simpler.

Link copied to clipboard
fun minus(a1: Automaton, a2: Automaton, determinizeWorkLimit: Int): Automaton

Returns a (deterministic) automaton that accepts the intersection of the language of a1 * and the complement of the language of a2. As a side-effect, the automata may be determinized, if not already deterministic.

Link copied to clipboard

Returns an automaton that accepts the union of the empty string and the language of the given automaton. This may create a dead state.

Link copied to clipboard

Removes transitions to dead states (a state is "dead" if it is not reachable from the initial state or no accept state is reachable from it.)

Link copied to clipboard

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.

fun repeat(a: Automaton, count: Int): Automaton

Returns an automaton that accepts min or more concatenated repetitions of the language of the given automaton.

fun repeat(a: Automaton, min: Int, max: Int): Automaton

Returns an automaton that accepts between min and max (including both) concatenated repetitions of the language of the given automaton.

Link copied to clipboard
Link copied to clipboard

Returns an automaton accepting the reverse language.

Link copied to clipboard

Returns true if the given string is accepted by the automaton. The input must be deterministic.

Returns true if the given string (expressed as unicode codepoints) is accepted by the automaton. The input must be deterministic.

Link copied to clipboard
Link copied to clipboard

Returns the topological sort of all states reachable from the initial state. This method assumes that the automaton does not contain cycles, and will throw an IllegalArgumentException if a cycle is detected. The CPU cost is O(numTransitions), and the implementation is non-recursive, so it will not exhaust the java stack for automaton matching long strings. If there are dead states in the automaton, they will be removed from the returned array.

Link copied to clipboard

Returns a new automaton accepting the same language with added transitions to a dead state so that from every state and every label there is a transition.

Link copied to clipboard

Returns an automaton that accepts the union of the languages of the given automata.