本文整理汇总了Java中org.apache.lucene.util.automaton.Operations.union方法的典型用法代码示例。如果您正苦于以下问题:Java Operations.union方法的具体用法?Java Operations.union怎么用?Java Operations.union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.util.automaton.Operations
的用法示例。
在下文中一共展示了Operations.union方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCustomProvider
import org.apache.lucene.util.automaton.Operations; //导入方法依赖的package包/类
public void testCustomProvider() throws IOException {
AutomatonProvider myProvider = new AutomatonProvider() {
// automaton that matches quick or brown
private Automaton quickBrownAutomaton = Operations.union(Arrays
.asList(Automata.makeString("quick"),
Automata.makeString("brown"),
Automata.makeString("bob")));
@Override
public Automaton getAutomaton(String name) {
if (name.equals("quickBrown")) return quickBrownAutomaton;
else return null;
}
};
RegexpQuery query = new RegexpQuery(newTerm("<quickBrown>"), RegExp.ALL,
myProvider, DEFAULT_MAX_DETERMINIZED_STATES);
assertEquals(1, searcher.search(query, 5).totalHits);
}
示例2: simpleMatchToAutomaton
import org.apache.lucene.util.automaton.Operations; //导入方法依赖的package包/类
/**
* Return an Automaton that matches the union of the provided patterns.
*/
public static Automaton simpleMatchToAutomaton(String... patterns) {
if (patterns.length < 1) {
throw new IllegalArgumentException("There must be at least one pattern, zero given");
}
List<Automaton> automata = new ArrayList<>();
for (String pattern : patterns) {
automata.add(simpleMatchToAutomaton(pattern));
}
return Operations.union(automata);
}
示例3: toAutomaton
import org.apache.lucene.util.automaton.Operations; //导入方法依赖的package包/类
@Override
public Automaton toAutomaton() {
List<Automaton> automatons = new ArrayList<>();
for (CharSequence value : values) {
automatons.add(Automata.makeString(value.toString()));
}
return Operations.union(automatons);
}
示例4: toAutomaton
import org.apache.lucene.util.automaton.Operations; //导入方法依赖的package包/类
@Override
public Automaton toAutomaton() {
Automaton automaton;
if(precisions == null || precisions.length == 0) {
automaton = Automata.makeString(location);
} else {
automaton = Automata.makeString(location.substring(0, Math.max(1, Math.min(location.length(), precisions[0]))));
for (int i = 1; i < precisions.length; i++) {
final String cell = location.substring(0, Math.max(1, Math.min(location.length(), precisions[i])));
automaton = Operations.union(automaton, Automata.makeString(cell));
}
}
return automaton;
}
示例5: testNFA
import org.apache.lucene.util.automaton.Operations; //导入方法依赖的package包/类
/**
* Test that a nondeterministic automaton works correctly. (It should will be
* determinized)
*/
public void testNFA() throws IOException {
// accept this or three, the union is an NFA (two transitions for 't' from
// initial state)
Automaton nfa = Operations.union(Automata.makeString("this"),
Automata.makeString("three"));
assertAutomatonHits(2, nfa);
}
示例6: testSynOverHole
import org.apache.lucene.util.automaton.Operations; //导入方法依赖的package包/类
public void testSynOverHole() throws Exception {
final TokenStream ts = new CannedTokenStream(
new Token[] {
token("a", 1, 1),
token("X", 0, 2),
token("b", 2, 1),
});
final Automaton a1 = Operations.union(join(s2a("a"), SEP_A, HOLE_A), s2a("X"));
final Automaton expected = Operations.concatenate(a1, join(SEP_A, s2a("b")));
assertSameLanguage(expected, ts);
}
示例7: testSynOverHole2
import org.apache.lucene.util.automaton.Operations; //导入方法依赖的package包/类
public void testSynOverHole2() throws Exception {
final TokenStream ts = new CannedTokenStream(
new Token[] {
token("xyz", 1, 1),
token("abc", 0, 3),
token("def", 2, 1),
});
final Automaton expected = Operations.union(
join(s2a("xyz"), SEP_A, HOLE_A, SEP_A, s2a("def")), s2a("abc"));
assertSameLanguage(expected, ts);
}
示例8: makeMatchDotsInFieldNames
import org.apache.lucene.util.automaton.Operations; //导入方法依赖的package包/类
/** Make matches on objects also match dots in field names.
* For instance, if the original simple regex is `foo`, this will translate
* it into `foo` OR `foo.*`. */
private static Automaton makeMatchDotsInFieldNames(Automaton automaton) {
return Operations.union(
automaton,
Operations.concatenate(Arrays.asList(automaton, Automata.makeChar('.'), Automata.makeAnyString())));
}