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


Java StopFilter.makeStopSet方法代码示例

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


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

示例1: testEndingHole

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testEndingHole() throws Exception {
  // Just deletes "of"
  Analyzer a = new Analyzer() {
      @Override
      public TokenStreamComponents createComponents(String field, Reader reader) {
        Tokenizer tokenizer = new MockTokenizer(reader);
        CharArraySet stopSet = StopFilter.makeStopSet("of");
        return new TokenStreamComponents(tokenizer, new StopFilter(tokenizer, stopSet));
      }
    };

  Iterable<Input> keys = AnalyzingSuggesterTest.shuffle(
      new Input("wizard of oz", 50)
  );
  FreeTextSuggester sug = new FreeTextSuggester(a, a, 3, (byte) 0x20);
  sug.build(new InputArrayIterator(keys));
  assertEquals("wizard _ oz/1.00",
               toString(sug.lookup("wizard of", 10)));

  // Falls back to unigram model, with backoff 0.4 times
  // prop 0.5:
  assertEquals("oz/0.20",
               toString(sug.lookup("wizard o", 10)));
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:TestFreeTextSuggester.java

示例2: testTwoEndingHoles

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testTwoEndingHoles() throws Exception {
  // Just deletes "of"
  Analyzer a = new Analyzer() {
      @Override
      public TokenStreamComponents createComponents(String field, Reader reader) {
        Tokenizer tokenizer = new MockTokenizer(reader);
        CharArraySet stopSet = StopFilter.makeStopSet("of");
        return new TokenStreamComponents(tokenizer, new StopFilter(tokenizer, stopSet));
      }
    };

  Iterable<Input> keys = AnalyzingSuggesterTest.shuffle(
      new Input("wizard of of oz", 50)
  );
  FreeTextSuggester sug = new FreeTextSuggester(a, a, 3, (byte) 0x20);
  sug.build(new InputArrayIterator(keys));
  assertEquals("",
               toString(sug.lookup("wizard of of", 10)));
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:TestFreeTextSuggester.java

示例3: testEndIsStopWord

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testEndIsStopWord() throws Exception {
                            
  CharArraySet stopWords = StopFilter.makeStopSet("to");
  TokenStream stream = new MockTokenizer(new StringReader("go to "));
  TokenStream filter = new SuggestStopFilter(stream, stopWords);

  filter = new SuggestStopFilter(stream, stopWords);
  assertTokenStreamContents(filter,
                            new String[] {"go"},
                            new int[] {0},
                            new int[] {2},
                            null,
                            new int[] {1},
                            null,
                            6,
                            new boolean[] {false},
                            true);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestSuggestStopFilter.java

示例4: testMidStopWord

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMidStopWord() throws Exception {
                            
  CharArraySet stopWords = StopFilter.makeStopSet("to");
  TokenStream stream = new MockTokenizer(new StringReader("go to school"));
  TokenStream filter = new SuggestStopFilter(stream, stopWords);

  filter = new SuggestStopFilter(stream, stopWords);
  assertTokenStreamContents(filter,
                            new String[] {"go", "school"},
                            new int[] {0, 6},
                            new int[] {2, 12},
                            null,
                            new int[] {1, 2},
                            null,
                            12,
                            new boolean[] {false, false},
                            true);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestSuggestStopFilter.java

示例5: testMultipleStopWords

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWords() throws Exception {
                            
  CharArraySet stopWords = StopFilter.makeStopSet("to", "the", "a");
  TokenStream stream = new MockTokenizer(new StringReader("go to a the school"));
  TokenStream filter = new SuggestStopFilter(stream, stopWords);

  filter = new SuggestStopFilter(stream, stopWords);
  assertTokenStreamContents(filter,
                            new String[] { "go", "school" },
                            new int[] {0, 12},
                            new int[] {2, 18},
                            null,
                            new int[] {1, 4},
                            null,
                            18,
                            new boolean[] {false, false},
                            true);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestSuggestStopFilter.java

示例6: testMultipleStopWordsEnd

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWordsEnd() throws Exception {
                            
  CharArraySet stopWords = StopFilter.makeStopSet("to", "the", "a");
  TokenStream stream = new MockTokenizer(new StringReader("go to a the"));
  TokenStream filter = new SuggestStopFilter(stream, stopWords);

  filter = new SuggestStopFilter(stream, stopWords);
  assertTokenStreamContents(filter,
                            new String[] { "go", "the"},
                            new int[] {0, 8},
                            new int[] {2, 11},
                            null,
                            new int[] {1, 3},
                            null,
                            11,
                            new boolean[] {false, true},
                            true);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestSuggestStopFilter.java

示例7: testMultipleStopWordsEnd2

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWordsEnd2() throws Exception {
                            
  CharArraySet stopWords = StopFilter.makeStopSet("to", "the", "a");
  TokenStream stream = new MockTokenizer(new StringReader("go to a the "));
  TokenStream filter = new SuggestStopFilter(stream, stopWords);

  filter = new SuggestStopFilter(stream, stopWords);
  assertTokenStreamContents(filter,
                            new String[] { "go"},
                            new int[] {0},
                            new int[] {2},
                            null,
                            new int[] {1},
                            null,
                            12,
                            new boolean[] {false},
                            true);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestSuggestStopFilter.java

示例8: testEndingHole

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testEndingHole() throws Exception {
  // Just deletes "of"
  Analyzer a = new Analyzer() {
      @Override
      public TokenStreamComponents createComponents(String field, Reader reader) {
        Tokenizer tokenizer = new MockTokenizer(reader);
        CharArraySet stopSet = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "of");
        return new TokenStreamComponents(tokenizer, new StopFilter(TEST_VERSION_CURRENT, tokenizer, stopSet));
      }
    };

  Iterable<Input> keys = shuffle(
      new Input("wizard of oz", 50)
  );
  FreeTextSuggester sug = new FreeTextSuggester(a, a, 3, (byte) 0x20);
  sug.build(new InputArrayIterator(keys));
  assertEquals("wizard _ oz/1.00",
               toString(sug.lookup("wizard of", 10)));

  // Falls back to unigram model, with backoff 0.4 times
  // prop 0.5:
  assertEquals("oz/0.20",
               toString(sug.lookup("wizard o", 10)));
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:25,代码来源:TestFreeTextSuggester.java

示例9: testTwoEndingHoles

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testTwoEndingHoles() throws Exception {
  // Just deletes "of"
  Analyzer a = new Analyzer() {
      @Override
      public TokenStreamComponents createComponents(String field, Reader reader) {
        Tokenizer tokenizer = new MockTokenizer(reader);
        CharArraySet stopSet = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "of");
        return new TokenStreamComponents(tokenizer, new StopFilter(TEST_VERSION_CURRENT, tokenizer, stopSet));
      }
    };

  Iterable<Input> keys = shuffle(
      new Input("wizard of of oz", 50)
  );
  FreeTextSuggester sug = new FreeTextSuggester(a, a, 3, (byte) 0x20);
  sug.build(new InputArrayIterator(keys));
  assertEquals("",
               toString(sug.lookup("wizard of of", 10)));
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:20,代码来源:TestFreeTextSuggester.java

示例10: testEndIsStopWord

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testEndIsStopWord() throws Exception {
                            
  CharArraySet stopWords = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "to");
  TokenStream stream = new MockTokenizer(new StringReader("go to "));
  TokenStream filter = new SuggestStopFilter(stream, stopWords);

  filter = new SuggestStopFilter(stream, stopWords);
  assertTokenStreamContents(filter,
                            new String[] {"go"},
                            new int[] {0},
                            new int[] {2},
                            null,
                            new int[] {1},
                            null,
                            6,
                            new boolean[] {false},
                            true);
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:19,代码来源:TestSuggestStopFilter.java

示例11: testMidStopWord

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMidStopWord() throws Exception {
                            
  CharArraySet stopWords = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "to");
  TokenStream stream = new MockTokenizer(new StringReader("go to school"));
  TokenStream filter = new SuggestStopFilter(stream, stopWords);

  filter = new SuggestStopFilter(stream, stopWords);
  assertTokenStreamContents(filter,
                            new String[] {"go", "school"},
                            new int[] {0, 6},
                            new int[] {2, 12},
                            null,
                            new int[] {1, 2},
                            null,
                            12,
                            new boolean[] {false, false},
                            true);
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:19,代码来源:TestSuggestStopFilter.java

示例12: testMultipleStopWords

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWords() throws Exception {
                            
  CharArraySet stopWords = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "to", "the", "a");
  TokenStream stream = new MockTokenizer(new StringReader("go to a the school"));
  TokenStream filter = new SuggestStopFilter(stream, stopWords);

  filter = new SuggestStopFilter(stream, stopWords);
  assertTokenStreamContents(filter,
                            new String[] { "go", "school" },
                            new int[] {0, 12},
                            new int[] {2, 18},
                            null,
                            new int[] {1, 4},
                            null,
                            18,
                            new boolean[] {false, false},
                            true);
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:19,代码来源:TestSuggestStopFilter.java

示例13: testMultipleStopWordsEnd

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWordsEnd() throws Exception {
                            
  CharArraySet stopWords = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "to", "the", "a");
  TokenStream stream = new MockTokenizer(new StringReader("go to a the"));
  TokenStream filter = new SuggestStopFilter(stream, stopWords);

  filter = new SuggestStopFilter(stream, stopWords);
  assertTokenStreamContents(filter,
                            new String[] { "go", "the"},
                            new int[] {0, 8},
                            new int[] {2, 11},
                            null,
                            new int[] {1, 3},
                            null,
                            11,
                            new boolean[] {false, true},
                            true);
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:19,代码来源:TestSuggestStopFilter.java

示例14: testMultipleStopWordsEnd2

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWordsEnd2() throws Exception {
                            
  CharArraySet stopWords = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "to", "the", "a");
  TokenStream stream = new MockTokenizer(new StringReader("go to a the "));
  TokenStream filter = new SuggestStopFilter(stream, stopWords);

  filter = new SuggestStopFilter(stream, stopWords);
  assertTokenStreamContents(filter,
                            new String[] { "go"},
                            new int[] {0},
                            new int[] {2},
                            null,
                            new int[] {1},
                            null,
                            12,
                            new boolean[] {false},
                            true);
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:19,代码来源:TestSuggestStopFilter.java

示例15: LuceneAnalyzerUtil

import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
/**
 * Creates an analyzer instance based on user provided stop words. If @param addToDefault is set to true, then 
 * user provided stop words will be added to the Lucene default stopset.
 */
public LuceneAnalyzerUtil(StemFilterType stemFilterType, List<String> stopWords, boolean addToDefault) {
  LuceneAnalyzerUtil.stemFilterType = stemFilterType;
  if(addToDefault) {
    stopSet.addAll(stopWords);
  }
  else {
    stopSet = StopFilter.makeStopSet(stopWords);
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:14,代码来源:LuceneAnalyzerUtil.java


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