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


Java Operations.union方法代码示例

本文整理汇总了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);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestRegexpQuery.java

示例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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:Regex.java

示例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);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:CategoryContextMapping.java

示例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;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:GeolocationContextMapping.java

示例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);
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:TestAutomatonQuery.java

示例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);
  }
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:TestGraphTokenizers.java

示例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);
  }
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:TestGraphTokenizers.java

示例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())));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:XContentMapValues.java


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