Class SpecialOperations
- java.lang.Object
-
- org.apache.pinot.segment.local.utils.nativefst.automaton.SpecialOperations
-
public final class SpecialOperations extends Object
Special automata operations.
-
-
Method Summary
Modifier and Type Method Description static Automatoncompress(Automaton a, String set, char c)Returns an automaton that accepts the compressed language of the given automaton.static StringgetCommonPrefix(Automaton a)Returns the longest string that is a prefix of all accepted strings and visits each state at most once.static booleanisFinite(Automaton a)Returns true if the language of this automaton is finite.static Automatonoverlap(Automaton a1, Automaton a2)Returns an automaton that accepts the overlap of strings that in more than one way can be split into a left part being accepted bya1and a right part being accepted bya2.static Set<State>reverse(Automaton a)Reverses the language of the given (non-singleton) automaton while returning the set of new initial states.static Automatonsubst(Automaton a, char c, String s)Returns an automaton where all transitions of the given char are replaced by a string.static Automatonsubst(Automaton a, Map<Character,Set<Character>> map)Returns an automaton where all transition labels have been substituted.static Automatontrim(Automaton a, String set, char c)Returns an automaton that accepts the trimmed language of the given automaton.
-
-
-
Method Detail
-
reverse
public static Set<State> reverse(Automaton a)
Reverses the language of the given (non-singleton) automaton while returning the set of new initial states.
-
overlap
public static Automaton overlap(Automaton a1, Automaton a2)
Returns an automaton that accepts the overlap of strings that in more than one way can be split into a left part being accepted bya1and a right part being accepted bya2.
-
trim
public static Automaton trim(Automaton a, String set, char c)
Returns an automaton that accepts the trimmed language of the given automaton. The resulting automaton is constructed as follows: 1) Whenever accharacter is allowed in the original automaton, one or moresetcharacters are allowed in the new automaton. 2) The automaton is prefixed and postfixed with any number ofsetcharacters.- Parameters:
set- set of characters to be trimmedc- canonical trim character (assumed to be inset)
-
compress
public static Automaton compress(Automaton a, String set, char c)
Returns an automaton that accepts the compressed language of the given automaton. Whenever accharacter is allowed in the original automaton, one or moresetcharacters are allowed in the new automaton.- Parameters:
set- set of characters to be compressedc- canonical compress character (assumed to be inset)
-
subst
public static Automaton subst(Automaton a, Map<Character,Set<Character>> map)
Returns an automaton where all transition labels have been substituted.Each transition labeled
cis changed to a set of transitions, one for each character inmap(c). Ifmap(c)is null, then the transition is unchanged.- Parameters:
map- map from characters to sets of characters (where characters areCharacterobjects)
-
subst
public static Automaton subst(Automaton a, char c, String s)
Returns an automaton where all transitions of the given char are replaced by a string.- Parameters:
c- chars- string- Returns:
- new automaton
-
isFinite
public static boolean isFinite(Automaton a)
Returns true if the language of this automaton is finite.
-
-