本文整理汇总了Java中dk.brics.automaton.Automaton.union方法的典型用法代码示例。如果您正苦于以下问题:Java Automaton.union方法的具体用法?Java Automaton.union怎么用?Java Automaton.union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dk.brics.automaton.Automaton
的用法示例。
在下文中一共展示了Automaton.union方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: testRandRegExp
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
@Test
public void testRandRegExp() {
for (int runs = 0; runs < 20; runs++) {
Automaton a = new Automaton();
Set<String> finiteStringSet = new HashSet<String>();
for (int i = 0; i < 10; i++) {
String s = genRandString();
finiteStringSet.add(s);
Automaton sa = new RegExp(s).toAutomaton();
a = a.union(sa);
}
String input = genRandString();
String mins = finiteStringSet.iterator().next();
double min = (double) Math.abs(StringUtils.getLevenshteinDistance(input, finiteStringSet.iterator().next()));
// find min levenshtein distance
for (String fs : finiteStringSet) {
int ld = Math.abs(StringUtils.getLevenshteinDistance(input, fs));
if (ld < min) {
min = ld;
mins = fs;
}
}
LOGGER.info("Min ld is: " + min + " input:" + input + " " + mins);
Prex am = new Prex(a, 1.0, 1.0, 1.0);
double cost = am.evaluateCost(input, false, false);
Assert.assertTrue(cost == min);
}
}
示例3: computeSimilarityAutomaton
import dk.brics.automaton.Automaton; //导入方法依赖的package包/类
/**
* Computes the similatiry {@link RunAutomaton} from the given similarities.
*
* @param similarities
* the mapping of similarities
* @return the computed {@link RunAutomaton}
*/
private RunAutomaton computeSimilarityAutomaton(Map<String, Map<Object, Set<Object>>> similarities) {
Automaton automaton = Automaton.makeEmpty();
for (String word : similarities.keySet()) {
automaton = automaton.union(Automaton.makeString(word, false));
}
final RunAutomaton runAutomaton = new RunAutomaton(automaton);
return runAutomaton;
}