Java 类org.apache.lucene.analysis.phonetic.DoubleMetaphoneFilter 实例源码

项目:elasticsearch_my    文件:PhoneticTokenFilterFactory.java   
@Override
public TokenStream create(TokenStream tokenStream) {
    if (encoder == null) {
        if (ruletype != null && nametype != null) {
            if (languageset != null) {
                final LanguageSet languages = LanguageSet.from(new HashSet<>(Arrays.asList(languageset)));
                return new BeiderMorseFilter(tokenStream, new PhoneticEngine(nametype, ruletype, true), languages);
            }
            return new BeiderMorseFilter(tokenStream, new PhoneticEngine(nametype, ruletype, true));
        }
        if (maxcodelength > 0) {
            return new DoubleMetaphoneFilter(tokenStream, maxcodelength, !replace);
        }
    } else {
        return new PhoneticFilter(tokenStream, encoder, !replace);
    }
    throw new IllegalArgumentException("encoder error");
}
项目:NYBC    文件:TestDoubleMetaphoneFilterFactory.java   
/**
 * Ensure that reset() removes any state (buffered tokens)
 */
public void testReset() throws Exception {
  DoubleMetaphoneFilterFactory factory = new DoubleMetaphoneFilterFactory();
  factory.init(new HashMap<String, String>());
  TokenStream inputStream = new MockTokenizer(new StringReader("international"), MockTokenizer.WHITESPACE, false);

  TokenStream filteredStream = factory.create(inputStream);
  CharTermAttribute termAtt = filteredStream.addAttribute(CharTermAttribute.class);
  assertEquals(DoubleMetaphoneFilter.class, filteredStream.getClass());

  filteredStream.reset();
  assertTrue(filteredStream.incrementToken());
  assertEquals(13, termAtt.length());
  assertEquals("international", termAtt.toString());
  filteredStream.reset();

  // ensure there are no more tokens, such as ANTRNXNL
  assertFalse(filteredStream.incrementToken());
}
项目:search    文件:TestDoubleMetaphoneFilterFactory.java   
public void testDefaults() throws Exception {
  DoubleMetaphoneFilterFactory factory = new DoubleMetaphoneFilterFactory(new HashMap<String, String>());
  TokenStream inputStream = new MockTokenizer(new StringReader("international"), MockTokenizer.WHITESPACE, false);

  TokenStream filteredStream = factory.create(inputStream);
  assertEquals(DoubleMetaphoneFilter.class, filteredStream.getClass());
  assertTokenStreamContents(filteredStream, new String[] { "international", "ANTR" });
}
项目:search    文件:TestDoubleMetaphoneFilterFactory.java   
public void testSettingSizeAndInject() throws Exception {
  Map<String,String> parameters = new HashMap<>();
  parameters.put("inject", "false");
  parameters.put("maxCodeLength", "8");
  DoubleMetaphoneFilterFactory factory = new DoubleMetaphoneFilterFactory(parameters);

  TokenStream inputStream = new MockTokenizer(new StringReader("international"), MockTokenizer.WHITESPACE, false);

  TokenStream filteredStream = factory.create(inputStream);
  assertEquals(DoubleMetaphoneFilter.class, filteredStream.getClass());
  assertTokenStreamContents(filteredStream, new String[] { "ANTRNXNL" });
}
项目:NYBC    文件:TestDoubleMetaphoneFilterFactory.java   
public void testDefaults() throws Exception {
  DoubleMetaphoneFilterFactory factory = new DoubleMetaphoneFilterFactory();
  factory.init(new HashMap<String, String>());
  TokenStream inputStream = new MockTokenizer(new StringReader("international"), MockTokenizer.WHITESPACE, false);

  TokenStream filteredStream = factory.create(inputStream);
  assertEquals(DoubleMetaphoneFilter.class, filteredStream.getClass());
  assertTokenStreamContents(filteredStream, new String[] { "international", "ANTR" });
}
项目:NYBC    文件:TestDoubleMetaphoneFilterFactory.java   
public void testSettingSizeAndInject() throws Exception {
  DoubleMetaphoneFilterFactory factory = new DoubleMetaphoneFilterFactory();
  Map<String, String> parameters = new HashMap<String, String>();
  parameters.put("inject", "false");
  parameters.put("maxCodeLength", "8");
  factory.init(parameters);

  TokenStream inputStream = new MockTokenizer(new StringReader("international"), MockTokenizer.WHITESPACE, false);

  TokenStream filteredStream = factory.create(inputStream);
  assertEquals(DoubleMetaphoneFilter.class, filteredStream.getClass());
  assertTokenStreamContents(filteredStream, new String[] { "ANTRNXNL" });
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestDoubleMetaphoneFilterFactory.java   
public void testDefaults() throws Exception {
  DoubleMetaphoneFilterFactory factory = new DoubleMetaphoneFilterFactory(new HashMap<String, String>());
  TokenStream inputStream = new MockTokenizer(new StringReader("international"), MockTokenizer.WHITESPACE, false);

  TokenStream filteredStream = factory.create(inputStream);
  assertEquals(DoubleMetaphoneFilter.class, filteredStream.getClass());
  assertTokenStreamContents(filteredStream, new String[] { "international", "ANTR" });
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestDoubleMetaphoneFilterFactory.java   
public void testSettingSizeAndInject() throws Exception {
  Map<String,String> parameters = new HashMap<String,String>();
  parameters.put("inject", "false");
  parameters.put("maxCodeLength", "8");
  DoubleMetaphoneFilterFactory factory = new DoubleMetaphoneFilterFactory(parameters);

  TokenStream inputStream = new MockTokenizer(new StringReader("international"), MockTokenizer.WHITESPACE, false);

  TokenStream filteredStream = factory.create(inputStream);
  assertEquals(DoubleMetaphoneFilter.class, filteredStream.getClass());
  assertTokenStreamContents(filteredStream, new String[] { "ANTRNXNL" });
}
项目:search    文件:DoubleMetaphoneFilterFactory.java   
@Override
public DoubleMetaphoneFilter create(TokenStream input) {
  return new DoubleMetaphoneFilter(input, maxCodeLength, inject);
}
项目:NYBC    文件:DoubleMetaphoneFilterFactory.java   
@Override
public DoubleMetaphoneFilter create(TokenStream input) {
  return new DoubleMetaphoneFilter(input, maxCodeLength, inject);
}
项目:read-open-source-code    文件:DoubleMetaphoneFilterFactory.java   
@Override
public DoubleMetaphoneFilter create(TokenStream input) {
  return new DoubleMetaphoneFilter(input, maxCodeLength, inject);
}
项目:read-open-source-code    文件:DoubleMetaphoneFilterFactory.java   
@Override
public DoubleMetaphoneFilter create(TokenStream input) {
  return new DoubleMetaphoneFilter(input, maxCodeLength, inject);
}
项目:Maskana-Gestor-de-Conocimiento    文件:DoubleMetaphoneFilterFactory.java   
@Override
public DoubleMetaphoneFilter create(TokenStream input) {
  return new DoubleMetaphoneFilter(input, maxCodeLength, inject);
}