本文整理汇总了Java中dk.brics.automaton.State类的典型用法代码示例。如果您正苦于以下问题:Java State类的具体用法?Java State怎么用?Java State使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
State类属于dk.brics.automaton包,在下文中一共展示了State类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dfaToDkAutomaton
import dk.brics.automaton.State; //导入依赖的package包/类
private static Automaton dfaToDkAutomaton(TIntObjectMap<State> map, Machine machine) {
dk.brics.automaton.Automaton dkAut = new dk.brics.automaton.Automaton();
APList aps = machine.getInAPs();
for(int stateNr = 0; stateNr < machine.getStateSize(); stateNr ++) {
State state = getState(map, stateNr);
// initial states
if(machine.getInitialState() == stateNr) {
dkAut.setInitialState(state);
}
// final states
if(machine.getAcceptance().isFinal(stateNr)) {
state.setAccept(true);
}
for (int letter = 0; letter < aps.size(); letter ++) {
int succ = machine.getSuccessor(stateNr, letter);
State stateSucc = getState(map, succ);
state.addTransition(new Transition(aps.get(letter).toString().charAt(0),
stateSucc));
}
}
dkAut.setDeterministic(true);
return dkAut;
}
示例2: generate
import dk.brics.automaton.State; //导入依赖的package包/类
private void generate(StringBuilder builder, State state) {
List<Transition> transitions = state.getSortedTransitions(false);
if (transitions.size() == 0) {
assert state.isAccept();
return;
}
int nroptions = state.isAccept() ? transitions.size() : transitions.size() - 1;
int option = Xeger.getRandomInt(0, nroptions, random);
if (state.isAccept() && option == 0) { // 0 is considered stop
return;
}
// Moving on to next transition
Transition transition = transitions.get(option - (state.isAccept() ? 1 : 0));
appendChoice(builder, transition);
generate(builder, transition.getDest());
}
示例3: generate
import dk.brics.automaton.State; //导入依赖的package包/类
private void generate(StringBuilder builder, State state) {
List<Transition> transitions = state.getSortedTransitions(true);
if (transitions.size() == 0) {
assert state.isAccept();
return;
}
int nroptions = state.isAccept() ? transitions.size() : transitions.size() - 1;
int option = XegerUtils.getRandomInt(0, nroptions, random);
if (state.isAccept() && option == 0) { // 0 is considered stop
return;
}
// Moving on to next transition
Transition transition = transitions.get(option - (state.isAccept() ? 1 : 0));
appendChoice(builder, transition);
generate(builder, transition.getDest());
}
示例4: FullTransition
import dk.brics.automaton.State; //导入依赖的package包/类
public FullTransition(State src, Transition trans, State dest,
LabelTranslator ltrans) {
this.src = src;
this.trans = new HashSet<>();
this.ltrans = ltrans;
if(trans != null) {
this.trans.add(trans);
this.label = getTransitionLabel();
}
this.dest = dest;
this.tid = id ++;
this.isEpsilon = false;
this.kind = Kind.MATCH;
this.recentlyAdded = trans;
}
示例5: getCheckAutomaton
import dk.brics.automaton.State; //导入依赖的package包/类
@Override
public VacuityAwareWildcardAutomaton getCheckAutomaton() {
VacuityAwareWildcardAutomaton autom = new VacuityAwareWildcardAutomaton(
this.getRegularExpression(), TaskCharEncoderDecoder.getTranslationMap(this.getInvolvedTaskChars()), this.toString());
// TODO Tweaking to insert the loopback to the initial state
State state = autom.getInitialState();
int i = 0;
for (; i < this.getParameters().size() - 1; i++) {
state = state.step(this.parameters.get(i).getFirstTaskChar().identifier);
}
State stateToRemove = state.step(this.parameters.get(i).getFirstTaskChar().identifier);
state.getTransitions().remove(new Transition(this.parameters.get(i).getFirstTaskChar().identifier, stateToRemove));
RelevanceAwareTransition newTransition = new RelevanceAwareTransition(this.parameters.get(i).getFirstTaskChar().identifier, autom.getInitialState(), this.parameters.get(i).getFirstTaskChar().taskClass.toString());
newTransition.setRelevance(TransitionRelevance.RELEVANT);
state.addTransition(newTransition);
return autom;
}
示例6: pruneOutRedundantTransitions
import dk.brics.automaton.State; //导入依赖的package包/类
private void pruneOutRedundantTransitions(State initialState) {
boolean redundantTransitions = false;
State nextState = initialState.step(basingCharacter.charValue());
// Heuristic 1: if the automaton contains an action with the basingCharacter, the other are optional: we can exclude them!
if (nextState != null)
redundantTransitions = true;
if (redundantTransitions) {
Iterator<Transition> transIterator = initialState.getTransitions().iterator();
while (transIterator.hasNext()) {
transIterator.next();
transIterator.remove();
}
initialState.addTransition(new Transition(basingCharacter, nextState));
}
else {
Set<Transition> transitions = initialState.getTransitions();
if (transitions.size() == 0) {
return;
} else {
for (Transition transition : transitions) {
this.pruneOutRedundantTransitions(transition.getDest());
}
}
}
}
开发者ID:cdc08x,项目名称:MINERful,代码行数:27,代码来源:DimensionalityHeuristicBasedCallableBriefSubAutomataMaker.java
示例7: buildIllegalityStats
import dk.brics.automaton.State; //导入依赖的package包/类
private void buildIllegalityStats() {
this.stateIllegalityStats = new DescriptiveStatistics();
this.transIllegalityStats = new DescriptiveStatistics();
for (State state : this.automaton.getStates()) {
this.stateIllegalityStats.addValue(((WeightedState) state).getWeight());
for (Transition trans: state.getTransitions()) {
if (((WeightedTransition) trans).getWeight() > 0)
this.transIllegalityStats.addValue(((WeightedTransition) trans).getWeight());
}
}
for (int q = 0; q < AMOUNT_OF_QUANTILES - 1 ; q++) { // say we want quartiles. Then AMOUNT_OF_QUANTILES = 4. We want boundary values for 25, 50 and 75 => q values have to be 0, 1, 2 because the percentile is calculated as MAX_PERCENTAGE / AMOUNT_OF_QUANTILES * (q + 1) -- see the +1 there? Good!
stateIllegalityQuantileBoundaries[q] = stateIllegalityStats.getPercentile((double) MAX_PERCENTAGE / AMOUNT_OF_QUANTILES * (q + 1) );
}
for (int q = 0; q < AMOUNT_OF_QUANTILES - 1 ; q++) { // say we want quartiles. Then AMOUNT_OF_QUANTILES = 4. We want boundary values for 25, 50 and 75 => q values have to be 0, 1, 2 because the percentile is calculated as MAX_PERCENTAGE / AMOUNT_OF_QUANTILES * (q + 1) -- see the +1 there? Good!
transIllegalityQuantileBoundaries[q] = transIllegalityStats.getPercentile((double) MAX_PERCENTAGE / AMOUNT_OF_QUANTILES * (q + 1) );
}
}
示例8: generate
import dk.brics.automaton.State; //导入依赖的package包/类
private void generate(final StringBuilder builder, final State state) {
final List<Transition> transitions = state.getSortedTransitions(true);
if (transitions.isEmpty()) {
assert state.isAccept();
return;
}
final int nroptions = state.isAccept() ? transitions.size() : transitions.size() - 1;
final int option = XegerUtils.getRandomInt(0, nroptions, random);
if (state.isAccept() && option == 0) { // 0 is considered stop
return;
}
// Moving on to next transition
final Transition transition = transitions.get(option - (state.isAccept() ? 1 : 0));
appendChoice(builder, transition);
generate(builder, transition.getDest());
}
示例9: generate
import dk.brics.automaton.State; //导入依赖的package包/类
private void generate(StringBuilder builder, State state) {
List<Transition> transitions = state.getSortedTransitions(true);
if (transitions.size() == 0) {
assert state.isAccept();
return;
}
int nroptions = state.isAccept() ? transitions.size() :
transitions.size() - 1;
int option = XegerUtils.getRandomInt(0, nroptions, random);
if (state.isAccept() && option == 0) { // 0 is considered stop
return;
}
// Moving on to next transition
Transition transition = transitions.get(option -
(state.isAccept() ? 1 : 0));
appendChoice(builder, transition);
generate(builder, transition.getDest());
}
示例10: isNull
import dk.brics.automaton.State; //导入依赖的package包/类
public boolean isNull() {
for (State state: this.states) {
if (state != null) {
return false;
}
}
return true;
}
示例11: step
import dk.brics.automaton.State; //导入依赖的package包/类
public PolyState step(char token) {
State[] nextStates = new State[states.length];
for (int c = 0, clen = states.length; c < clen; ++c) {
State prevState = states[c];
nextStates[c] = (prevState == null) ? null : prevState.step(token);
}
return new PolyState(nextStates);
}
示例12: toAcceptValues
import dk.brics.automaton.State; //导入依赖的package包/类
public int[] toAcceptValues() {
List<Integer> acceptValues = new ArrayList<>();
for (int stateId = 0, stateCount = states.length; stateId < stateCount; ++stateId) {
State curState = this.states[stateId];
if ((curState != null) && (curState.isAccept())) {
acceptValues.add(stateId);
}
}
int[] acceptValuesArr = new int[acceptValues.size()];
for (int c=0; c<acceptValues.size(); c++) {
acceptValuesArr[c] = acceptValues.get(c);
}
return acceptValuesArr;
}
示例13: initialState
import dk.brics.automaton.State; //导入依赖的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);
}
示例14: AutomatonNode
import dk.brics.automaton.State; //导入依赖的package包/类
public AutomatonNode(NodeKind kind, State s, int level) {
this.s = s;
this.level = level;
this.id = sid++;
this.kind = kind;
this.color = Color.WHITE;
this.d = 0;
this.f = 0;
}
示例15: createFormula
import dk.brics.automaton.State; //导入依赖的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;
}
}