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


Java RegExp.ALL属性代码示例

本文整理汇总了Java中org.apache.lucene.util.automaton.RegExp.ALL属性的典型用法代码示例。如果您正苦于以下问题:Java RegExp.ALL属性的具体用法?Java RegExp.ALL怎么用?Java RegExp.ALL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.lucene.util.automaton.RegExp的用法示例。


在下文中一共展示了RegExp.ALL属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

示例2: testCustomProvider

public void testCustomProvider() throws IOException {
  AutomatonProvider myProvider = new AutomatonProvider() {
    // automaton that matches quick or brown
    private Automaton quickBrownAutomaton = BasicOperations.union(Arrays
        .asList(BasicAutomata.makeString("quick"),
        BasicAutomata.makeString("brown"),
        BasicAutomata.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);
  assertEquals(1, searcher.search(query, 5).totalHits);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:18,代码来源:TestRegexpQuery.java

示例3: newRegexpQuery

/**
 * Builds a new RegexpQuery instance
 * @param regexp Regexp term
 * @return new RegexpQuery instance
 */
protected Query newRegexpQuery(Term regexp) {
  RegexpQuery query = new RegexpQuery(regexp, RegExp.ALL,
    maxDeterminizedStates);
  query.setRewriteMethod(multiTermRewriteMethod);
  return query;
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:QueryParserBase.java

示例4: toLuceneRegexpQuery

private Query toLuceneRegexpQuery(String fieldName, BytesRef value, Context context) {
    return new ConstantScoreQuery(
            new RegexpQuery(new Term(fieldName, value), RegExp.ALL));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:LuceneQueryBuilder.java

示例5: SpanRegexQueryWrapper

public SpanRegexQueryWrapper (String field, String re) {
    this(field, re, RegExp.ALL, false);
}
 
开发者ID:KorAP,项目名称:Krill,代码行数:3,代码来源:SpanRegexQueryWrapper.java

示例6: testQueryRewriteBug

/**
 * Query rewrite bug
 * 
 * Warning: This is not armoured by <base/s=t>!
 * 
 * @throws IOException
 */
@Test
public void testQueryRewriteBug () throws IOException {
    KrillIndex ki = new KrillIndex();
    ki.addDoc(createFieldDoc0()); // ceccecdeec
    /*
    ki.addDoc(createFieldDoc1()); // bbccdd || only not clause
    ki.addDoc(createFieldDoc2()); // beccea | only main clause
    */
    ki.commit();

    // See /queries/bugs/repetition_group_rewrite
    RegexpQuery requery = new RegexpQuery(new Term("base", "s:[ac]"),
            RegExp.ALL);
    SpanMultiTermQueryWrapper<RegexpQuery> query = new SpanMultiTermQueryWrapper<RegexpQuery>(
            requery);
    SpanExpansionQuery seq = new SpanExpansionQuery(query, 1, 1, 1, true);
    SpanRepetitionQuery rep = new SpanRepetitionQuery(seq, 2, 2, true);

    // spanRepetition(
    //   spanExpansion(
    //     SpanMultiTermQueryWrapper(base:/s:[ac]/),
    //     []{1, 1},
    //     right
    //   ){2,2}
    // )

    kr = ki.search(query, (short) 20);
    assertEquals(5, kr.getTotalResults());
    assertEquals(0, kr.getMatch(0).getStartPos());
    assertEquals(1, kr.getMatch(0).getEndPos());
    assertEquals(2, kr.getMatch(1).getStartPos());
    assertEquals(3, kr.getMatch(1).getEndPos());
    assertEquals(3, kr.getMatch(2).getStartPos());
    assertEquals(4, kr.getMatch(2).getEndPos());
    assertEquals(5, kr.getMatch(3).getStartPos());
    assertEquals(6, kr.getMatch(3).getEndPos());
    assertEquals(9, kr.getMatch(4).getStartPos());
    assertEquals(10, kr.getMatch(4).getEndPos());

    kr = ki.search(seq, (short) 20);
    assertEquals(5, kr.getTotalResults());
    assertEquals(0, kr.getMatch(0).getStartPos());
    assertEquals(2, kr.getMatch(0).getEndPos());
    assertEquals(2, kr.getMatch(1).getStartPos());
    assertEquals(4, kr.getMatch(1).getEndPos());
    assertEquals(3, kr.getMatch(2).getStartPos());
    assertEquals(5, kr.getMatch(2).getEndPos());
    assertEquals(5, kr.getMatch(3).getStartPos());
    assertEquals(7, kr.getMatch(3).getEndPos());
    assertEquals(9, kr.getMatch(4).getStartPos());
    assertEquals(11, kr.getMatch(4).getEndPos());

    kr = ki.search(rep, (short) 20);

    // for (Match km : kr.getMatches()){
    // System.out.println(
    // km.getStartPos() +
    // "," +
    // km.getEndPos() +
    // " " +
    // km.getSnippetBrackets()
    // );
    // };

    assertEquals("[[cecc]]ecdeec", kr.getMatch(0).getSnippetBrackets());
    assertEquals("cec[[cecd]]eec", kr.getMatch(1).getSnippetBrackets());
    assertEquals((long) 2, kr.getTotalResults());
}
 
开发者ID:KorAP,项目名称:Krill,代码行数:75,代码来源:TestSpanExpansionIndex.java

示例7: RegexpQuery

/**
 * Constructs a query for terms matching <code>term</code>.
 * <p>
 * By default, all regular expression features are enabled.
 * </p>
 * 
 * @param term regular expression.
 */
public RegexpQuery(Term term) {
  this(term, RegExp.ALL);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:RegexpQuery.java

示例8: newRegexpQuery

/**
 * Builds a new RegexpQuery instance
 * 
 * @param regexp
 *            Regexp term
 * @return new RegexpQuery instance
 */
protected Query newRegexpQuery(Term regexp) {
	RegexpQuery query = new RegexpQuery(regexp, RegExp.ALL, maxDeterminizedStates);
	query.setRewriteMethod(multiTermRewriteMethod);
	return query;
}
 
开发者ID:easynet-cn,项目名称:resource-query-parser,代码行数:12,代码来源:QueryParserBase.java


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