use of org.apache.lucene.util.automaton.Automaton in project lucene-solr by apache.
the class TestGraphTokenizers method testOverlappedTokensSausage.
public void testOverlappedTokensSausage() throws Exception {
// Two tokens on top of each other (sausage):
final TokenStream ts = new CannedTokenStream(new Token[] { token("abc", 1, 1), token("xyz", 0, 1) });
final Automaton a1 = s2a("abc");
final Automaton a2 = s2a("xyz");
assertSameLanguage(Operations.union(a1, a2), ts);
}
use of org.apache.lucene.util.automaton.Automaton in project lucene-solr by apache.
the class TestRegexpQuery method testCustomProvider.
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);
}
Aggregations