本文整理汇总了Java中dk.brics.automaton.Automaton类的典型用法代码示例。如果您正苦于以下问题:Java Automaton类的具体用法?Java Automaton怎么用?Java Automaton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Automaton类属于dk.brics.automaton包,在下文中一共展示了Automaton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dfaToDkAutomaton
import dk.brics.automaton.Automaton; //导入依赖的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: answerEquivalenceQuery
import dk.brics.automaton.Automaton; //导入依赖的package包/类
@Override
public Query<HashableValue> answerEquivalenceQuery(Machine machine) {
numEquiv ++;
Automaton conjecture = UtilMachine.dfaToDkAutomaton(machine);
Automaton result = automaton.clone().minus(conjecture.clone());
String counterexample = result.getShortestExample(true);
Word wordCE = alphabet.getEmptyWord();
boolean isEq = true;
if(counterexample == null) {
result = conjecture.clone().minus(automaton.clone());
counterexample = result.getShortestExample(true);
}
if(counterexample != null) {
wordCE = parseString(counterexample);
isEq = false;
}
Query<HashableValue> ceQuery = new QuerySimple<>(wordCE);
ceQuery.answerQuery(new HashableValueBoolean(isEq));
return ceQuery;
}
示例3: modAutomata
import dk.brics.automaton.Automaton; //导入依赖的package包/类
private boolean modAutomata(String rexp1, String rexp2, Op op) {
Automaton a = new RegExp(rexp1).toAutomaton();
Automaton b = new RegExp(rexp2).toAutomaton();
Automaton c = null;
switch(op) {
case CONCAT:
c = a.concatenate(b);
break;
case UNION:
c = a.union(b);
break;
case ISECT:
c = a.intersection(b);
break;
}
Assert.assertNotNull(c);
return compareRexpAutomaton(c);
}
示例4: languageTagAutomaton
import dk.brics.automaton.Automaton; //导入依赖的package包/类
protected static Automaton languageTagAutomaton() {
return new RegExp(
"("+
"([a-zA-Z]{2,3}"+
"("+
"(-[a-zA-Z]{3}){0,3}"+ // extlang
")?"+
")|"+
"[a-zA-Z]{4}|"+ // 4ALPHA
"[a-zA-Z]{5,8}"+ // 5*8ALPHA
")"+ // language
"(-[a-zA-Z]{4})?"+ // script
"(-([a-zA-Z]{2}|[0-9]{3}))?"+ // region
"(-([a-zA-Z0-9]{5,8}|([0-9][a-z0-9]{3})))*"+ // variant
"(-([a-wy-zA-WY-Z0-9](-[a-zA-Z0-9]{2,8})+))*"+ // extension
"(-x(-[a-zA-Z0-9]{1,8})+)?" // privateuse
).toAutomaton();
}
示例5: toAutomaton
import dk.brics.automaton.Automaton; //导入依赖的package包/类
public static Automaton toAutomaton(RDFPlainLiteralLengthValueSpaceSubset valueSpaceSubset) {
List<RDFPlainLiteralLengthInterval> intervals=valueSpaceSubset.m_intervals;
Automaton result=null;
for (int intervalIndex=intervals.size()-1;intervalIndex>=0;--intervalIndex) {
RDFPlainLiteralLengthInterval interval=intervals.get(intervalIndex);
Automaton stringPart;
if (interval.m_maxLength==Integer.MAX_VALUE) {
if (interval.m_minLength==0)
stringPart=s_anyString;
else
stringPart=s_anyString.intersection(BasicOperations.repeat(s_anyChar,interval.m_minLength));
}
else
stringPart=s_anyString.intersection(BasicOperations.repeat(s_anyChar,interval.m_minLength,interval.m_maxLength));
Automaton intervalAutomaton;
if (interval.m_languageTagMode==RDFPlainLiteralLengthInterval.LanguageTagMode.ABSENT)
intervalAutomaton=stringPart.concatenate(s_emptyLangTag);
else
intervalAutomaton=stringPart.concatenate(s_nonemptyLangTag);
if (result==null)
result=intervalAutomaton;
else
result=result.intersection(intervalAutomaton);
}
return result;
}
示例6: checkRedundancy
import dk.brics.automaton.Automaton; //导入依赖的package包/类
private boolean checkRedundancy(Automaton safeAutomaton, ConstraintsBag safeBag, Automaton candidateAutomaton, Constraint candidateCon) {
redundancyChecksPerformed++;
logger.trace("Checking redundancy of " + candidateCon);
// If candidateCon is not redundant, i.e., if the language of safeAutomaton is not a subset of the language of automaton, then candidateCon can be included
if (!safeAutomaton.subsetOf(candidateAutomaton)) {
return true;
} else {
logger.warn(candidateCon + " is redundant. It is already implied" +
( safeBag.howManyConstraints() < ConflictAndRedundancyResolver.MAXIMUM_VISIBLE_CONSTRAINTS_FOR_REDUNDANCY_CHECK
? " by " + LinearConstraintsIndexFactory.getAllConstraints(safeBag)
: " by the current set of constraints."
)
);
this.redundantConstraints.add(candidateCon);
candidateCon.setRedundant(true);
return false;
}
}
示例7: buildAutomatonByDimensionalityHeuristic
import dk.brics.automaton.Automaton; //导入依赖的package包/类
@Deprecated
public static Automaton buildAutomatonByDimensionalityHeuristic(ProcessModel model) {
TreeMap<Character, Collection<String>> regExpsMap = new TreeMap<Character, Collection<String>>();
// FIXME This is just for testing purposes!!
/*
CharacterRelatedConstraintsBag impliedIndexedBag = ConstraintsIndexFactory.indexByImpliedTaskChar(bag);
for (Constraint con : bag.getConstraintsOf(new TaskChar('a'))) {
if (con.hasReasonablePositiveSupport(threshold) && con.isOfInterest(interest))
regExps.add(con.getRegularExpression());
}
for (Constraint con : impliedIndexedBag.getConstraintsOf(new TaskChar('a'))) {
if (con.hasReasonablePositiveSupport(threshold) && con.isOfInterest(interest))
regExps.add(con.getRegularExpression());
}
*/
for (TaskChar tChr : model.bag.getTaskChars()) {
Collection<String> regExps = new ArrayList<String>();
for (Constraint con : model.bag.getConstraintsOf(tChr)) {
regExps.add(con.getRegularExpression());
}
regExpsMap.put(tChr.identifier, regExps);
}
return AutomatonFactory.fromRegularExpressionsByDimensionalityHeuristicInMultiThreading(regExpsMap, model.getTaskCharArchive().getIdentifiersAlphabet());
}
示例8: ExpandParameters
import dk.brics.automaton.Automaton; //导入依赖的package包/类
ExpandParameters(String pattern) {
template = new ParameterizedString(pattern);
if (isRE(pattern)) {
// Replace ${username} and ${shardeduserid} with ":PLACEHOLDER:"
// as : is not legal in a reference and the string :PLACEHOLDER:
// is not likely to be a valid part of the regex. This later
// allows the pattern prefix to be clipped, saving time on
// evaluation.
String replacement = ":PLACEHOLDER:";
Map<String, String> params =
ImmutableMap.of(
RefPattern.USERID_SHARDED, replacement,
RefPattern.USERNAME, replacement);
Automaton am = RefPattern.toRegExp(template.replace(params)).toAutomaton();
String rePrefix = am.getCommonPrefix();
prefix = rePrefix.substring(0, rePrefix.indexOf(replacement));
} else {
prefix = pattern.substring(0, pattern.indexOf("${"));
}
}
示例9: fromRegularExpressionsByDimensionalityHeuristicInMultiThreading
import dk.brics.automaton.Automaton; //导入依赖的package包/类
public static Automaton fromRegularExpressionsByDimensionalityHeuristicInMultiThreading(
AbstractMap<Character, Collection<String>> regExpsMap,
Collection<Character> alphabet) {
SortedSet<Automaton> partialAutomata = new TreeSet<Automaton>(
new DimensionalityHeuristicBasedAutomataIntersector.AutomataAscendingDimensionComparator());
Automaton processAutomaton = null;
for (Automaton otherProcessAutomaton : partialAutomata) {
if (processAutomaton == null) {
processAutomaton = otherProcessAutomaton;
} else {
logger.trace("Intersecting automaton...");
processAutomaton = processAutomaton
.intersection(otherProcessAutomaton);
processAutomaton.minimize();
logger.trace("Automaton states: "
+ processAutomaton.getNumberOfStates()
+ "; automaton transitions: "
+ processAutomaton.getNumberOfTransitions());
}
}
return processAutomaton;
}
示例10: fromRegularExpressions
import dk.brics.automaton.Automaton; //导入依赖的package包/类
public static Automaton fromRegularExpressions(Collection<String> regExps,
Collection<Character> basicAlphabet, boolean withWildCard, int minLen, int maxLen) {
boolean traceLengthLimitSet = (minLen != NO_TRACE_LENGTH_CONSTRAINT || maxLen != NO_TRACE_LENGTH_CONSTRAINT);
Collection<String> regularExpressions = new ArrayList<String>(
regExps.size() +
(traceLengthLimitSet ? 2 : 1)
);
// limit the alphabet
regularExpressions.add(AutomatonUtils.createRegExpLimitingTheAlphabet(basicAlphabet, withWildCard));
regularExpressions.addAll(regExps);
// limit the minimum and maximum length of runs, if needed
if (traceLengthLimitSet) {
regularExpressions.add(AutomatonUtils.createRegExpLimitingRunLength(minLen, maxLen));
}
return new CallableAutomataMaker(regularExpressions).makeAutomaton();
}
示例11: getSubstringAutomaton
import dk.brics.automaton.Automaton; //导入依赖的package包/类
/**
* returns a non case-sensitive automaton that is based on a
* @param a an automaton that might be case-sensitive
* @param ltrans a label translator
* @return the non case-sensitive version of a
*/
public static Automaton getSubstringAutomaton(Automaton a,
LabelTranslator ltrans) {
AutomatonTrans substr = new AutomatonTrans(a, ltrans);
assert(substr != null);
substr.convertToSubstringAutomaton();
return substr.auto;
}
示例12: getCamelCaseAutomaton
import dk.brics.automaton.Automaton; //导入依赖的package包/类
/**
* converts automaton a to a non case-sensitive automaton
* @param a an automaton that might be case-sensitie
* @param ltrans a label translator
* @return the non case-sensitive version of a
*/
public static Automaton getCamelCaseAutomaton(Automaton a,
LabelTranslator ltrans) {
AutomatonTrans ccas = new AutomatonTrans(a, ltrans);
assert(ccas != null);
ccas.convertToCamelCaseAutomaton();
return ccas.auto;
}
示例13: getLenAutomaton
import dk.brics.automaton.Automaton; //导入依赖的package包/类
/**
* returns the length automaton for a given automaton
* @param a an automaton
* @param ltrans a label translator
* @return len automaton
*/
public static Automaton getLenAutomaton(Automaton a,
LabelTranslator ltrans) {
AutomatonTrans ccas = new AutomatonTrans(a, ltrans);
assert(ccas != null);
ccas.convertToLenAutomaton();
return ccas.auto;
}
示例14: getSuffixAutomaton
import dk.brics.automaton.Automaton; //导入依赖的package包/类
/**
* returns an automaton that accepts all the suffixes from a
* @param a an automaton
* @param ltrans a label translator
* @return an automaton that accepts all suffix strings from a
*/
public static Automaton getSuffixAutomaton(Automaton a, LabelTranslator
ltrans) {
AutomatonTrans sfx = new AutomatonTrans(a, ltrans);
assert(sfx != null);
sfx.convertToSuffixAutomaton();
return sfx.auto;
}
示例15: compareRexpAutomaton
import dk.brics.automaton.Automaton; //导入依赖的package包/类
private boolean compareRexpAutomaton(Automaton a0) {
LOGGER.debug("old Automaton:" + a0.toDot());
LOGGER.debug("is det" + a0.isDeterministic());
String s0 = Autorex.getRegexFromAutomaton(a0);
LOGGER.debug("Regexp 1 " + s0);
RegExp r0new = new RegExp(s0);
Automaton a0new = r0new.toAutomaton();
LOGGER.debug("new Automaton:" + a0new.toDot());
return a0new.equals(a0);
}