当前位置: 首页>>代码示例>>Java>>正文


Java State.getTransitions方法代码示例

本文整理汇总了Java中dk.brics.automaton.State.getTransitions方法的典型用法代码示例。如果您正苦于以下问题:Java State.getTransitions方法的具体用法?Java State.getTransitions怎么用?Java State.getTransitions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dk.brics.automaton.State的用法示例。


在下文中一共展示了State.getTransitions方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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) );
	}
}
 
开发者ID:cdc08x,项目名称:MINERful,代码行数:22,代码来源:WeightedAutomatonStats.java

示例3: getAllPossibleSteps

import dk.brics.automaton.State; //导入方法依赖的package包/类
public static ArrayList<Character> getAllPossibleSteps(State state) {
	Collection<Transition> transitions = state.getTransitions();
	ArrayList<Character> enabledTransitions = new ArrayList<Character>();
	for (Transition transition : transitions) {
		for (char c = transition.getMin(); c <= transition.getMax(); c++) {
			enabledTransitions.add(c);
		}
	}
	return enabledTransitions;
}
 
开发者ID:cdc08x,项目名称:MINERful,代码行数:11,代码来源:AutomatonUtils.java

示例4: visitTransitions

import dk.brics.automaton.State; //导入方法依赖的package包/类
public void visitTransitions(NavigableMap<State, ActivationStatusAwareState> statesTranslationMap, NavigableSet<State> visitedStates, State currentState) {
	if (visitedStates.contains(currentState))
		return;

	ActivationStatusAwareState
		currentStAwaState = statesTranslationMap.get(currentState),
		destStAwaState = null;
	State destinationState = null;

	this.decideActivationStatus(currentState, currentStAwaState);

	for (Transition trans : currentState.getTransitions()) {
		destinationState = trans.getDest();
		
		if (!statesTranslationMap.containsKey(destinationState)) {
			destStAwaState = makeNewState();
			statesTranslationMap.put(destinationState, destStAwaState);
		} else {
			destStAwaState = statesTranslationMap.get(destinationState);
		}
		for (char evt = trans.getMin(); evt <= trans.getMax(); evt++) {
			currentStAwaState.addTransition(new RelevanceAwareTransition(evt, destStAwaState,
					translationMap.get(evt).toString()));
			this.alphabet.add(evt);
		}

		visitedStates.add(currentState);

		// Recursive call: after this call, the reachable states have all been visited and assigned an activation status  
		visitTransitions(statesTranslationMap, visitedStates, destinationState);
	}

	this.decideRelevanceOfTransitions(currentStAwaState);

	return;
}
 
开发者ID:cdc08x,项目名称:MINERful,代码行数:37,代码来源:VacuityAwareAutomaton.java

示例5: unfoldTransitions

import dk.brics.automaton.State; //导入方法依赖的package包/类
public void unfoldTransitions(
		NavigableMap<State, WeightedState> statesTranslationMap, NavigableSet<State> visitedStates, State currentState) {
	if (visitedStates.contains(currentState))
		return;

	WeightedState currentWState = statesTranslationMap.get(currentState), destinationWState = null;
	State destinationState = null;

	if (currentState.isAccept())
		currentWState.setAccept(true);

	for (Transition trans : currentState.getTransitions()) {
		destinationState = trans.getDest();
		if (!statesTranslationMap.containsKey(destinationState)) {
			destinationWState = new WeightedState();
			statesTranslationMap.put(destinationState, destinationWState);
		} else {
			destinationWState = statesTranslationMap.get(destinationState);
		}
		for (char evt = trans.getMin(); evt <= trans.getMax(); evt++) {
			currentWState.addTransition(new WeightedTransition(evt,
					destinationWState, translationMap.get(evt).toString()));
		}

		visitedStates.add(currentState);
		unfoldTransitions(statesTranslationMap, visitedStates,
				destinationState);
	}
}
 
开发者ID:cdc08x,项目名称:MINERful,代码行数:30,代码来源:WeightedAutomaton.java

示例6: buildStats

import dk.brics.automaton.State; //导入方法依赖的package包/类
private void buildStats() {
	this.stateStats = new DescriptiveStatistics();
	this.transiStats = new DescriptiveStatistics();

	for (State state : this.automaton.getStates()) {
		this.stateStats.addValue(((WeightedState) state).getWeight());
		for (Transition trans: state.getTransitions()) {
			/*
			 * In BPI 2012, it happened that most of weights (vast majority,
			 * amounting to more than 82.5%) were equal to 0. This entailed
			 * the presence of 6 quantile-boundaries equal to 0.0 and only
			 * one having a higher value. However, this made it impossible
			 * to distinguish between, e.g., transitions which were
			 * traversed 8100 times from transitions traversed twice.
			 * Therefore, we decide to remove from the quantile-boundary-computation all those values that amount to 0.
			 * Motivation is, we do not care about never-enacted behaviour!
			 * This prevents the imbalance.
			 */
			if (((WeightedTransition) trans).getWeight() > 0)
				this.transiStats.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! 
		stateQuantileBoundaries[q] = stateStats.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! 
		transQuantileBoundaries[q] = transiStats.getPercentile((double) MAX_PERCENTAGE / AMOUNT_OF_QUANTILES * (q + 1) );
	}
}
 
开发者ID:cdc08x,项目名称:MINERful,代码行数:33,代码来源:WeightedAutomatonStats.java

示例7: setAlphabet

import dk.brics.automaton.State; //导入方法依赖的package包/类
/**
 * Part of the initialization of the message space:
 * Writes all characters of the alphabet to a private instance variable. 
 */
private void setAlphabet() {
	Set<Character> alphabet = new HashSet<Character>();
	//for each transition add characters to set
	for (State state : dfa.getStates()) {
		for (Transition transition : state.getTransitions()) {
			for (char i = transition.getMin(); i<=transition.getMax(); i++) {
				alphabet.add(i);
			}
		}
	}
	this.alphabet = new ArrayList<Character>(alphabet);
}
 
开发者ID:EVGStudents,项目名称:FPE,代码行数:17,代码来源:StringMessageSpace.java

示例8: printDot

import dk.brics.automaton.State; //导入方法依赖的package包/类
private String printDot(State state, Map<State, String> statesIdMap, Character emphasizedActivity) {
	StringBuilder sBuilder = new StringBuilder();
	boolean goForNot = false, goForNotRequiredNow = false;
	NavigableMap<State, Collection<Character>> howToGetThere = new TreeMap<State, Collection<Character>>();
	String stateNodeName = statesIdMap.get(state);
	Collection<Character>
		outGoingWays = new TreeSet<Character>(),
		outGoingWaysToOneState = null,
		howNotToGetThere = null;
	EmphasizableLabelPojo eLaPo = null;
	
	// Get the output transitions, and labels.
	
	for (Transition trans : state.getTransitions()) {
		if (!howToGetThere.containsKey(trans.getDest()))
			howToGetThere.put(trans.getDest(), new ArrayList<Character>());
		outGoingWaysToOneState = this.transMap.headMap(trans.getMax(),true).tailMap(trans.getMin(),true).keySet();
		outGoingWays.addAll(outGoingWaysToOneState);
		howToGetThere.put(trans.getDest(), outGoingWaysToOneState);
	}

	Set<State> reachableStates = howToGetThere.keySet();
	String
		actiNodeName = null,
		targetStateNodeName = null, blaurghStateName = null,
		compensatingStateName = null;
	int activityCounter = 0;
	for (State reachableState : reachableStates) {
		goForNotRequiredNow = false;
		targetStateNodeName = statesIdMap.get(reachableState);

		// Then, for each reached state, check numbers: how many are the outgoing connections?
		// If they are more than half of the alphabet size, start considering the "not" transitions
		if (howToGetThere.get(reachableState).size() > (this.getAlphabetSize() / 2)) {
			goForNotRequiredNow = true;
		} else {
			goForNotRequiredNow = false;
		}
		goForNot = goForNot || goForNotRequiredNow;
		
		
		// Add the new activity node
		if (goForNotRequiredNow) {
		} else {
			eLaPo = buildActivityLabel(howToGetThere.get(reachableState), emphasizedActivity);
			actiNodeName = String.format(DOT_TEMPLATES.getProperty("activityNodeNameTemplate"), stateNodeName, ++activityCounter);
			sBuilder.append(String.format(DOT_TEMPLATES.getProperty("activityNodeTemplate"), actiNodeName, eLaPo.label));
			if (eLaPo.emphasized) {
				sBuilder.append(String.format(DOT_TEMPLATES.getProperty("emphasizedTransitionTemplate"), stateNodeName, actiNodeName, targetStateNodeName));
			}
			else {
				sBuilder.append(String.format(DOT_TEMPLATES.getProperty("transitionTemplate"), stateNodeName, actiNodeName, targetStateNodeName));
			}
		}
	}
	
	if (goForNot) {
		// good transitions (the remaining guys) are thus labelled with "*"
		actiNodeName = String.format(DOT_TEMPLATES.getProperty("activityNodeNameTemplate"), stateNodeName, ++activityCounter);
		compensatingStateName = String.format(DOT_TEMPLATES.getProperty("compensatingActivityWrapperStateNodeTemplate"), stateNodeName, actiNodeName);
		sBuilder.append(String.format(DOT_TEMPLATES.getProperty("compensationForNotTransitionTemplate"), stateNodeName, compensatingStateName, targetStateNodeName));

		howNotToGetThere = this.makeItHowNotToGetThere(outGoingWays);
		
		if (howNotToGetThere.size() > 0) {
			eLaPo = buildActivityLabel(howNotToGetThere, emphasizedActivity);
			blaurghStateName = String.format(DOT_TEMPLATES.getProperty("blaurghStateNodeTemplate"), stateNodeName);
			// "not" transitions lead to blaurgh states
			actiNodeName = String.format(DOT_TEMPLATES.getProperty("activityNodeNameTemplate"), stateNodeName, ++activityCounter);
			sBuilder.append(String.format(DOT_TEMPLATES.getProperty("activityNodeTemplate"), actiNodeName, eLaPo.label));
			if (eLaPo.emphasized)
				sBuilder.append(String.format(DOT_TEMPLATES.getProperty("emphasizedNotTransitionTemplate"), stateNodeName, actiNodeName, blaurghStateName));
			else
				sBuilder.append(String.format(DOT_TEMPLATES.getProperty("notTransitionTemplate"), stateNodeName, actiNodeName, blaurghStateName));
		}
	}
	
	return sBuilder.toString();
}
 
开发者ID:cdc08x,项目名称:MINERful,代码行数:80,代码来源:AutomatonDotPrinter.java

示例9: cacheRegex

import dk.brics.automaton.State; //导入方法依赖的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);
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:46,代码来源:RegexDistanceUtils.java

示例10: closeScope

import dk.brics.automaton.State; //导入方法依赖的package包/类
private Automaton closeScope(Automaton automaton) {
	// Make sure automaton is deterministic
	automaton.determinize();
	
	// Skip the starting character, as it is not part of the actual sequence
	State oldInit = automaton.getInitialState();
	State realInit = oldInit.step(startChar);
	
	// Duplicate the initial state, as it will *not* receive any epsilon-transitions
	// for the inner character
	State newInit = new State();
	newInit.setAccept(true);
	newInit.getTransitions().addAll(realInit.getTransitions());
	
	automaton.setInitialState(newInit);
	

	automaton.setDeterministic(false);
	
	for(State s : automaton.getStates()) {
		s.setAccept(true);
		if(s.step(endChar) != null) {
			s.getTransitions().clear();
			continue;
		}
		
		if(s != newInit) {
			State innerSucc = s.step(innerChar);
			if(innerSucc != null) {
				automaton.addEpsilons(Collections.singleton(new StatePair(s, innerSucc)));
			}
		}
		
		// Remove all transitions with special characters
		List<Transition> newTransitions = new ArrayList<>();
		Set<Transition> transSet = s.getTransitions();
		Iterator<Transition> transIt = transSet.iterator();
		
		while(transIt.hasNext()) {
			Transition t = transIt.next();
			State succ = t.getDest();
			
			if(t.getMax() > overallHigh) {
				transIt.remove();
				if(t.getMin() <= overallHigh) {
					newTransitions.add(new Transition(t.getMin(), overallHigh, succ));
				}
			}
		}
		
		transSet.addAll(newTransitions);
	}
	
	automaton.determinize();
	automaton.minimize();
	
	return automaton;
}
 
开发者ID:misberner,项目名称:duzzt,代码行数:59,代码来源:BricsCompiler.java


注:本文中的dk.brics.automaton.State.getTransitions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。