本文整理汇总了Java中dk.brics.automaton.Automaton.getInitialState方法的典型用法代码示例。如果您正苦于以下问题:Java Automaton.getInitialState方法的具体用法?Java Automaton.getInitialState怎么用?Java Automaton.getInitialState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dk.brics.automaton.Automaton
的用法示例。
在下文中一共展示了Automaton.getInitialState方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialState
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
static PolyState initialState(List<Automaton> automata) {
final State[] initialStates = new State[automata.size()];
int c = 0;
for (final Automaton automaton: automata) {
initialStates[c++] = automaton.getInitialState();
}
return new PolyState(initialStates);
}
示例2: createFormula
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
public static Formula createFormula(Automaton A, int n) {
State root = A.getInitialState();
if (n==0) {
if (root.isAccept()) {
return new TrueFormula();
} else {
return new FalseFormula();
}
} else {
Formula ret = createFormula(root,1,n);
return ret==null? new FalseFormula() : ret;
}
}
示例3: createFormula
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
public static Constraint createFormula(Automaton A, String prefix, int n) {
State root = A.getInitialState();
if (n == 0) {
if (root.isAccept()) {
return SymbolicTrueConstraint.instance;
} else {
return SymbolicFalseConstraint.instance;
}
} else {
Constraint ret = createFormula(root, prefix, 0, n);
return ret == null ? SymbolicFalseConstraint.instance : ret;
}
}
示例4: refineAutomaton
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
private Automaton refineAutomaton(Automaton automaton) {
State initialState = automaton.getInitialState();
this.pruneOutRedundantTransitions(initialState);
automaton.minimize();
return automaton;
}
开发者ID:cdc08x,项目名称:MINERful,代码行数:8,代码来源:DimensionalityHeuristicBasedCallableBriefSubAutomataMaker.java
示例5: accepts
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
public static final boolean accepts(Automaton automaton, String string) {
State state = automaton.getInitialState();
for (char step : string.toCharArray()) {
state = state.step(step);
if (state == null)
return false;
}
return state.isAccept();
}
示例6: WeightedAutomaton
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
public WeightedAutomaton(Automaton automaton,
NavigableMap<Character, AbstractTaskClass> translationMap) {
this.translationMap = translationMap;
NavigableMap<State, WeightedState> statesTranslationMap = new TreeMap<State, WeightedState>();
NavigableSet<State> visitedStates = new TreeSet<State>();
WeightedState initWState = new WeightedState();
State initState = automaton.getInitialState();
this.setInitialState(initWState);
statesTranslationMap.put(initState, initWState);
unfoldTransitions(statesTranslationMap, visitedStates, initState);
}
示例7: pathRegex
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
public static void pathRegex(String regex) {
pathRegex = regex;
Automaton pathsAutomaton = (new RegExp(regex)).toAutomaton();
//System.out.println(pathsAutomaton.toDot());
pathsState = pathsAutomaton.getInitialState();
}
示例8: automatonToTSML
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
/**
*
* Creates a TSML-document based on an instance of the class {@link Automaton}.
*
* @param a Automaton to be used.
* @param automatonSource The Automaton used.
* @return TSML document.
*/
public String automatonToTSML(Automaton a, String automatonSource) {
Set<State> stateSet = a.getStates();
HashMap<State, Set<Transition>> transitionSet = new HashMap<State, Set<Transition>>();
StringBuilder tsmlBuilder = new StringBuilder();
tsmlBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
tsmlBuilder.append('\n');
tsmlBuilder.append("<tsml label=\"Converted from " + automatonSource + "\" layout=\"false\">");
tsmlBuilder.append('\n');
State initialState = a.getInitialState();
for (State state : stateSet) {
tsmlBuilder.append("<state weight=\"");
tsmlBuilder.append(DEFAULT_WEIGHT); // TODO: WEIGHT of a transition!
tsmlBuilder.append("\" ");
tsmlBuilder.append("id=\"state" + state.hashCode() + "\" ");
if (initialState.equals(state))
tsmlBuilder.append(" start=\"true\"");
if (state.isAccept())
tsmlBuilder.append(" accept=\"true\"");
tsmlBuilder.append(">\n<name><text>" + state.hashCode());
tsmlBuilder.append("</text></name>");
tsmlBuilder.append("</state>");
tsmlBuilder.append('\n');
transitionSet.put(state, state.getTransitions());
}
for (State source : transitionSet.keySet()) {
for (Transition t : transitionSet.get(source)) {
for (Character c = t.getMin(); c <= t.getMax(); c++) {
tsmlBuilder.append("<transition weight=\"");
tsmlBuilder.append(DEFAULT_WEIGHT); // TODO: WEIGHT of a transition!
tsmlBuilder.append("\" ");
// tsmlBuilder.append("id=\"transition_" + source.hashCode() + "_" + c.hashCode() + "_" + t.getDest().hashCode() + "\" ");
tsmlBuilder.append("id=\"" + this.transMap.get(c) + "\" ");
tsmlBuilder.append("source=\"state" + source.hashCode() + "\" ");
tsmlBuilder.append("target=\"state" + t.getDest().hashCode() + "\" >");
tsmlBuilder.append("<name><text>");
tsmlBuilder.append(this.transMap.get(c));
tsmlBuilder.append("</text></name>");
tsmlBuilder.append("</transition>");
tsmlBuilder.append('\n');
}
}
}
tsmlBuilder.append("</tsml>");
return tsmlBuilder.toString();
}
示例9: postConstructionInit
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
protected void postConstructionInit(Automaton automaton) {
this.alphabet = new TreeSet<Character>();
automaton.minimize();
NavigableMap<State, ActivationStatusAwareState> statesTranslationMap = new TreeMap<State, ActivationStatusAwareState>();
NavigableSet<State> visitedStates = new TreeSet<State>();
ActivationStatusAwareState initWState = makeNewState();
State initState = automaton.getInitialState();
this.setInitialState(initWState);
statesTranslationMap.put(initState, initWState);
visitTransitions(statesTranslationMap, visitedStates, initState);
}
示例10: cacheRegex
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
private static void cacheRegex(String regex) {
String r = expandRegex(regex);
Automaton automaton = new RegExp(r, RegExp.NONE).toAutomaton();
automaton.expandSingleton();
// We convert this to a graph without self-loops in order to determine the topological order
DirectedGraph<State, DefaultEdge> regexGraph = new DefaultDirectedGraph<State, DefaultEdge>(
DefaultEdge.class);
Set<State> visitedStates = new HashSet<State>();
Queue<State> states = new LinkedList<State>();
State initialState = automaton.getInitialState();
states.add(initialState);
while (!states.isEmpty()) {
State currentState = states.poll();
if (visitedStates.contains(currentState))
continue;
if (!regexGraph.containsVertex(currentState))
regexGraph.addVertex(currentState);
for (Transition t : currentState.getTransitions()) {
// Need to get rid of back edges, otherwise there is no topological order!
if (!t.getDest().equals(currentState)) {
regexGraph.addVertex(t.getDest());
regexGraph.addEdge(currentState, t.getDest());
states.add(t.getDest());
CycleDetector<State, DefaultEdge> det = new CycleDetector<State, DefaultEdge>(
regexGraph);
if (det.detectCycles()) {
regexGraph.removeEdge(currentState, t.getDest());
}
}
}
visitedStates.add(currentState);
}
TopologicalOrderIterator<State, DefaultEdge> iterator = new TopologicalOrderIterator<State, DefaultEdge>(
regexGraph);
List<State> topologicalOrder = new ArrayList<State>();
while (iterator.hasNext()) {
topologicalOrder.add(iterator.next());
}
regexStateCache.put(regex, topologicalOrder);
regexAutomatonCache.put(regex, automaton);
}