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


Java LanguageSet.from方法代码示例

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


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

示例1: create

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入方法依赖的package包/类
@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");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:PhoneticTokenFilterFactory.java

示例2: BeiderMorseFilterFactory

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入方法依赖的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

示例3: testLanguageSet

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入方法依赖的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

示例4: init

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入方法依赖的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

示例5: guessLanguages

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入方法依赖的package包/类
public LanguageSet guessLanguages(String input) {
    String text = input.toLowerCase(Locale.ENGLISH);
    Set<String> langs = new HashSet(this.languages.getLanguages());
    for (LangRule rule : this.rules) {
        if (rule.matches(text)) {
            if (rule.acceptOnMatch) {
                langs.retainAll(rule.languages);
            } else {
                langs.removeAll(rule.languages);
            }
        }
    }
    LanguageSet ls = LanguageSet.from(langs);
    return ls.equals(Languages.NO_LANGUAGES) ? Languages.ANY_LANGUAGE : ls;
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:16,代码来源:Lang.java

示例6: parsePhoneme

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入方法依赖的package包/类
private static Phoneme parsePhoneme(String ph) {
    int open = ph.indexOf("[");
    if (open < 0) {
        return new Phoneme((CharSequence) ph, Languages.ANY_LANGUAGE);
    }
    if (ph.endsWith("]")) {
        return new Phoneme(ph.substring(0, open), LanguageSet.from(new HashSet(Arrays.asList(ph.substring(open + 1, ph.length() - 1).split("[+]")))));
    }
    throw new IllegalArgumentException("Phoneme expression contains a '[' but does not end in ']'");
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:11,代码来源:Rule.java


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