• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NameType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.codec.language.bm.NameType的典型用法代码示例。如果您正苦于以下问题:Java NameType类的具体用法?Java NameType怎么用?Java NameType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NameType类属于org.apache.commons.codec.language.bm包,在下文中一共展示了NameType类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: BeiderMorseFilterFactory

import org.apache.commons.codec.language.bm.NameType; //导入依赖的package包/类
/** Creates a new BeiderMorseFilterFactory */
public BeiderMorseFilterFactory(Map<String,String> args) {
  super(args);
  // PhoneticEngine = NameType + RuleType + concat
  // we use common-codec's defaults: GENERIC + APPROX + true
  NameType nameType = NameType.valueOf(get(args, "nameType", NameType.GENERIC.toString()));
  RuleType ruleType = RuleType.valueOf(get(args, "ruleType", RuleType.APPROX.toString()));
  
  boolean concat = getBoolean(args, "concat", true);
  engine = new PhoneticEngine(nameType, ruleType, concat);
  
  // LanguageSet: defaults to automagic, otherwise a comma-separated list.
  Set<String> langs = getSet(args, "languageSet");
  languageSet = (null == langs || (1 == langs.size() && langs.contains("auto"))) ? null : LanguageSet.from(langs);
  if (!args.isEmpty()) {
    throw new IllegalArgumentException("Unknown parameters: " + args);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:BeiderMorseFilterFactory.java


示例2: testLanguageSet

import org.apache.commons.codec.language.bm.NameType; //导入依赖的package包/类
/** restrict the output to a set of possible origin languages */
public void testLanguageSet() throws Exception {
  final LanguageSet languages = LanguageSet.from(new HashSet<String>() {{
    add("italian"); add("greek"); add("spanish");
  }});
  Analyzer analyzer = new Analyzer() {
    @Override
    protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
      Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
      return new TokenStreamComponents(tokenizer, 
          new BeiderMorseFilter(tokenizer, 
              new PhoneticEngine(NameType.GENERIC, RuleType.EXACT, true), languages));
    }
  };
  assertAnalyzesTo(analyzer, "Angelo",
      new String[] { "andZelo", "angelo", "anxelo" },
      new int[] { 0, 0, 0, },
      new int[] { 6, 6, 6, },
      new int[] { 1, 0, 0, });
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:TestBeiderMorseFilter.java


示例3: init

import org.apache.commons.codec.language.bm.NameType; //导入依赖的package包/类
@Override
public void init(Map<String,String> args) {
  super.init(args);
  
  // PhoneticEngine = NameType + RuleType + concat
  // we use common-codec's defaults: GENERIC + APPROX + true
  String nameTypeArg = args.get("nameType");
  NameType nameType = (nameTypeArg == null) ? NameType.GENERIC : NameType.valueOf(nameTypeArg);

  String ruleTypeArg = args.get("ruleType");
  RuleType ruleType = (ruleTypeArg == null) ? RuleType.APPROX : RuleType.valueOf(ruleTypeArg);
  
  boolean concat = getBoolean("concat", true);
  engine = new PhoneticEngine(nameType, ruleType, concat);
  
  // LanguageSet: defaults to automagic, otherwise a comma-separated list.
  String languageSetArg = args.get("languageSet");
  if (languageSetArg == null || languageSetArg.equals("auto")) {
    languageSet = null;
  } else {
    languageSet = LanguageSet.from(new HashSet<String>(Arrays.asList(languageSetArg.split(","))));
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:24,代码来源:BeiderMorseFilterFactory.java


示例4: testEmptyTerm

import org.apache.commons.codec.language.bm.NameType; //导入依赖的package包/类
public void testEmptyTerm() throws IOException {
  Analyzer a = new Analyzer() {
    @Override
    protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
      Tokenizer tokenizer = new KeywordTokenizer(reader);
      return new TokenStreamComponents(tokenizer, new BeiderMorseFilter(tokenizer, new PhoneticEngine(NameType.GENERIC, RuleType.EXACT, true)));
    }
  };
  checkOneTerm(a, "", "");
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:TestBeiderMorseFilter.java


示例5: testCustomAttribute

import org.apache.commons.codec.language.bm.NameType; //导入依赖的package包/类
public void testCustomAttribute() throws IOException {
  TokenStream stream = new MockTokenizer(new StringReader("D'Angelo"), MockTokenizer.KEYWORD, false);
  stream = new PatternKeywordMarkerFilter(stream, Pattern.compile(".*"));
  stream = new BeiderMorseFilter(stream, new PhoneticEngine(NameType.GENERIC, RuleType.EXACT, true));
  KeywordAttribute keyAtt = stream.addAttribute(KeywordAttribute.class);
  stream.reset();
  int i = 0;
  while(stream.incrementToken()) {
    assertTrue(keyAtt.isKeyword());
    i++;
  }
  assertEquals(12, i);
  stream.end();
  stream.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:TestBeiderMorseFilter.java


示例6: testEmptyTerm

import org.apache.commons.codec.language.bm.NameType; //导入依赖的package包/类
public void testEmptyTerm() throws IOException {
  Analyzer a = new Analyzer() {
    @Override
    protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
      Tokenizer tokenizer = new KeywordTokenizer(reader);
      return new TokenStreamComponents(tokenizer, new BeiderMorseFilter(tokenizer, new PhoneticEngine(NameType.GENERIC, RuleType.EXACT, true)));
    }
  };
  checkOneTermReuse(a, "", "");
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:11,代码来源:TestBeiderMorseFilter.java


示例7: main

import org.apache.commons.codec.language.bm.NameType; //导入依赖的package包/类
public static void main(String[] args) {
	PhoneticEngine encoder = new PhoneticEngine(NameType.GENERIC,
			RuleType.APPROX, true, 20);
	for (int i = 0; i < 10; i++) {
		System.out.println(encoder.encode("test"));
		System.out.println(encoder.encode("sample"));
	}
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:9,代码来源:BeiderMorseTokenFilter.java


示例8: testCustomAttribute

import org.apache.commons.codec.language.bm.NameType; //导入依赖的package包/类
public void testCustomAttribute() throws IOException {
  TokenStream stream = new KeywordTokenizer(new StringReader("D'Angelo"));
  stream = new PatternKeywordMarkerFilter(stream, Pattern.compile(".*"));
  stream = new BeiderMorseFilter(stream, new PhoneticEngine(NameType.GENERIC, RuleType.EXACT, true));
  KeywordAttribute keyAtt = stream.addAttribute(KeywordAttribute.class);
  stream.reset();
  int i = 0;
  while(stream.incrementToken()) {
    assertTrue(keyAtt.isKeyword());
    i++;
  }
  assertEquals(12, i);
  stream.end();
  stream.close();
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:16,代码来源:TestBeiderMorseFilter.java


示例9: PhoneticTokenFilterFactory

import org.apache.commons.codec.language.bm.NameType; //导入依赖的package包/类
public PhoneticTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
    super(indexSettings, name, settings);
    this.languageset = null;
    this.nametype = null;
    this.ruletype = null;
    this.maxcodelength = 0;
    this.replace = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "replace", true, deprecationLogger);
    // weird, encoder is null at last step in SimplePhoneticAnalysisTests, so we set it to metaphone as default
    String encodername = settings.get("encoder", "metaphone");
    if ("metaphone".equalsIgnoreCase(encodername)) {
        this.encoder = new Metaphone();
    } else if ("soundex".equalsIgnoreCase(encodername)) {
        this.encoder = new Soundex();
    } else if ("caverphone1".equalsIgnoreCase(encodername)) {
        this.encoder = new Caverphone1();
    } else if ("caverphone2".equalsIgnoreCase(encodername)) {
        this.encoder = new Caverphone2();
    } else if ("caverphone".equalsIgnoreCase(encodername)) {
        this.encoder = new Caverphone2();
    } else if ("refined_soundex".equalsIgnoreCase(encodername) || "refinedSoundex".equalsIgnoreCase(encodername)) {
        this.encoder = new RefinedSoundex();
    } else if ("cologne".equalsIgnoreCase(encodername)) {
        this.encoder = new ColognePhonetic();
    } else if ("double_metaphone".equalsIgnoreCase(encodername) || "doubleMetaphone".equalsIgnoreCase(encodername)) {
        this.encoder = null;
        this.maxcodelength = settings.getAsInt("max_code_len", 4);
    } else if ("bm".equalsIgnoreCase(encodername) || "beider_morse".equalsIgnoreCase(encodername) || "beidermorse".equalsIgnoreCase(encodername)) {
        this.encoder = null;
        this.languageset = settings.getAsArray("languageset");
        String ruleType = settings.get("rule_type", "approx");
        if ("approx".equalsIgnoreCase(ruleType)) {
            ruletype = RuleType.APPROX;
        } else if ("exact".equalsIgnoreCase(ruleType)) {
            ruletype = RuleType.EXACT;
        } else {
            throw new IllegalArgumentException("No matching rule type [" + ruleType + "] for beider morse encoder");
        }
        String nameType = settings.get("name_type", "generic");
        if ("GENERIC".equalsIgnoreCase(nameType)) {
            nametype = NameType.GENERIC;
        } else if ("ASHKENAZI".equalsIgnoreCase(nameType)) {
            nametype = NameType.ASHKENAZI;
        } else if ("SEPHARDIC".equalsIgnoreCase(nameType)) {
            nametype = NameType.SEPHARDIC;
        }
    } else if ("koelnerphonetik".equalsIgnoreCase(encodername)) {
        this.encoder = new KoelnerPhonetik();
    } else if ("haasephonetik".equalsIgnoreCase(encodername)) {
        this.encoder = new HaasePhonetik();
    } else if ("nysiis".equalsIgnoreCase(encodername)) {
        this.encoder = new Nysiis();
    } else if ("daitch_mokotoff".equalsIgnoreCase(encodername)) {
        this.encoder = new DaitchMokotoffSoundex();
    } else {
        throw new IllegalArgumentException("unknown encoder [" + encodername + "] for phonetic token filter");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:58,代码来源:PhoneticTokenFilterFactory.java


示例10: createComponents

import org.apache.commons.codec.language.bm.NameType; //导入依赖的package包/类
@Override
protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
  Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
  return new TokenStreamComponents(tokenizer, 
      new BeiderMorseFilter(tokenizer, new PhoneticEngine(NameType.GENERIC, RuleType.EXACT, true)));
}
 
开发者ID:europeana,项目名称:search,代码行数:7,代码来源:TestBeiderMorseFilter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ErrorReceiver类代码示例发布时间:2022-05-23
下一篇:
Java AbstractCompile类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap