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

Java LanguageSet类代码示例

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

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



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

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
/**
 * Applies the given phoneme expression to all phonemes in this phoneme builder.
 * <p>
 * This will lengthen phonemes that have compatible language sets to the expression, and drop those that are
 * incompatible.
 *
 * @param phonemeExpr   the expression to apply
 * @param maxPhonemes   the maximum number of phonemes to build up
 */
public void apply(final Rule.PhonemeExpr phonemeExpr, final int maxPhonemes) {
    final Set<Rule.Phoneme> newPhonemes = new LinkedHashSet<Rule.Phoneme>(maxPhonemes);

    EXPR: for (final Rule.Phoneme left : this.phonemes) {
        for (final Rule.Phoneme right : phonemeExpr.getPhonemes()) {
            final LanguageSet languages = left.getLanguages().restrictTo(right.getLanguages());
            if (!languages.isEmpty()) {
                final Rule.Phoneme join = new Phoneme(left, right, languages);
                if (newPhonemes.size() < maxPhonemes) {
                    newPhonemes.add(join);
                    if (newPhonemes.size() >= maxPhonemes) {
                        break EXPR;
                    }
                }
            }
        }
    }

    this.phonemes.clear();
    this.phonemes.addAll(newPhonemes);
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:31,代码来源:PhoneticEngine.java


示例3: apply

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
public void apply(PhonemeExpr phonemeExpr, int maxPhonemes) {
    Set<Phoneme> newPhonemes = new LinkedHashSet(maxPhonemes);
    loop0:
    for (Phoneme left : this.phonemes) {
        for (Phoneme right : phonemeExpr.getPhonemes()) {
            LanguageSet languages = left.getLanguages().restrictTo(right.getLanguages());
            if (!languages.isEmpty()) {
                Phoneme join = new Phoneme(left, right, languages);
                if (newPhonemes.size() < maxPhonemes) {
                    newPhonemes.add(join);
                    if (newPhonemes.size() >= maxPhonemes) {
                        break loop0;
                    }
                } else {
                    continue;
                }
            }
        }
    }
    this.phonemes.clear();
    this.phonemes.addAll(newPhonemes);
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:23,代码来源:PhoneticEngine.java


示例4: 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


示例5: 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


示例6: 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


示例7: parsePhoneme

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
private static Phoneme parsePhoneme(final String ph) {
    final int open = ph.indexOf("[");
    if (open >= 0) {
        if (!ph.endsWith("]")) {
            throw new IllegalArgumentException("Phoneme expression contains a '[' but does not end in ']'");
        }
        final String before = ph.substring(0, open);
        final String in = ph.substring(open + 1, ph.length() - 1);
        final Set<String> langs = new HashSet<String>(Arrays.asList(in.split("[+]")));

        return new Phoneme(before, Languages.LanguageSet.from(langs));
    }
    return new Phoneme(ph, Languages.ANY_LANGUAGE);
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:15,代码来源:Rule.java


示例8: 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


示例9: getInstance

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
public static List<Rule> getInstance(NameType nameType, RuleType rt, LanguageSet langs) {
    Map<String, List<Rule>> ruleMap = getInstanceMap(nameType, rt, langs);
    List<Rule> allRules = new ArrayList();
    for (List<Rule> rules : ruleMap.values()) {
        allRules.addAll(rules);
    }
    return allRules;
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:9,代码来源:Rule.java


示例10: 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


示例11: parsePhoneme

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
private static Phoneme parsePhoneme(final String ph) {
    final int open = ph.indexOf("[");
    if (open >= 0) {
        if (!ph.endsWith("]")) {
            throw new IllegalArgumentException("Phoneme expression contains a '[' but does not end in ']'");
        }
        final String before = ph.substring(0, open);
        final String in = ph.substring(open + 1, ph.length() - 1);
        final Set<String> langs = new HashSet<String>(Arrays.asList(in.split("[+]")));

        return new Phoneme(before, Languages.LanguageSet.from(langs));
    } else {
        return new Phoneme(ph, Languages.ANY_LANGUAGE);
    }
}
 
开发者ID:Konloch,项目名称:bytecode-viewer,代码行数:16,代码来源:Rule.java


示例12: Phoneme

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
public Phoneme(final CharSequence phonemeText, final Languages.LanguageSet languages) {
    this.phonemeText = new StringBuilder(phonemeText);
    this.languages = languages;
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:5,代码来源:Rule.java


示例13: getLanguages

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
public Languages.LanguageSet getLanguages() {
    return this.languages;
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:4,代码来源:Rule.java


示例14: empty

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
public static PhonemeBuilder empty(LanguageSet languages) {
    return new PhonemeBuilder(new Phoneme((CharSequence) "", languages));
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:4,代码来源:PhoneticEngine.java


示例15: encode

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
public String encode(String input, LanguageSet languageSet) {
    Map<String, List<Rule>> rules = Rule.getInstanceMap(this.nameType, RuleType.RULES, languageSet);
    Map<String, List<Rule>> finalRules1 = Rule.getInstanceMap(this.nameType, this.ruleType, "common");
    Map<String, List<Rule>> finalRules2 = Rule.getInstanceMap(this.nameType, this.ruleType, languageSet);
    input = input.toLowerCase(Locale.ENGLISH).replace('-', ' ').trim();
    if (this.nameType == NameType.GENERIC) {
        String remainder;
        if (input.length() < 2 || !input.substring(0, 2).equals("d'")) {
            for (String l : (Set) NAME_PREFIXES.get(this.nameType)) {
                if (input.startsWith(l + " ")) {
                    remainder = input.substring(l.length() + 1);
                    return "(" + encode(remainder) + ")-(" + encode(l + remainder) + ")";
                }
            }
        }
        remainder = input.substring(2);
        return "(" + encode(remainder) + ")-(" + encode("d" + remainder) + ")";
    }
    List<String> words = Arrays.asList(input.split("\\s+"));
    List<String> words2 = new ArrayList();
    switch (this.nameType) {
        case SEPHARDIC:
            for (String aWord : words) {
                String[] parts = aWord.split("'");
                words2.add(parts[parts.length - 1]);
            }
            words2.removeAll((Collection) NAME_PREFIXES.get(this.nameType));
            break;
        case ASHKENAZI:
            words2.addAll(words);
            words2.removeAll((Collection) NAME_PREFIXES.get(this.nameType));
            break;
        case GENERIC:
            words2.addAll(words);
            break;
        default:
            throw new IllegalStateException("Unreachable case: " + this.nameType);
    }
    if (this.concat) {
        input = join(words2, " ");
    } else if (words2.size() == 1) {
        input = (String) words.iterator().next();
    } else {
        StringBuilder result = new StringBuilder();
        for (String word : words2) {
            StringBuilder stringBuilder = result;
            stringBuilder.append("-").append(encode(word));
        }
        return result.substring(1);
    }
    PhonemeBuilder phonemeBuilder = PhonemeBuilder.empty(languageSet);
    int i = 0;
    while (i < input.length()) {
        RulesApplication rulesApplication = new RulesApplication(rules, input, phonemeBuilder, i, this.maxPhonemes).invoke();
        i = rulesApplication.getI();
        phonemeBuilder = rulesApplication.getPhonemeBuilder();
    }
    return applyFinalRules(applyFinalRules(phonemeBuilder, finalRules1), finalRules2).makeString();
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:60,代码来源:PhoneticEngine.java


示例16: guessLanguage

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
public String guessLanguage(String text) {
    LanguageSet ls = guessLanguages(text);
    return ls.isSingleton() ? ls.getAny() : Languages.ANY;
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:5,代码来源:Lang.java


示例17: Phoneme

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
public Phoneme(CharSequence phonemeText, LanguageSet languages) {
    this.phonemeText = new StringBuilder(phonemeText);
    this.languages = languages;
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:5,代码来源:Rule.java


示例18: getLanguages

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
public LanguageSet getLanguages() {
    return this.languages;
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:4,代码来源:Rule.java


示例19: getInstanceMap

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
public static Map<String, List<Rule>> getInstanceMap(NameType nameType, RuleType rt, LanguageSet langs) {
    return langs.isSingleton() ? getInstanceMap(nameType, rt, langs.getAny()) : getInstanceMap(nameType, rt, Languages.ANY);
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:4,代码来源:Rule.java


示例20: getInstance

import org.apache.commons.codec.language.bm.Languages.LanguageSet; //导入依赖的package包/类
/**
 * Gets rules for a combination of name type, rule type and languages.
 *
 * @param nameType
 *            the NameType to consider
 * @param rt
 *            the RuleType to consider
 * @param langs
 *            the set of languages to consider
 * @return a list of Rules that apply
 */
public static List<Rule> getInstance(final NameType nameType, final RuleType rt,
                                     final Languages.LanguageSet langs) {
    final Map<String, List<Rule>> ruleMap = getInstanceMap(nameType, rt, langs);
    final List<Rule> allRules = new ArrayList<Rule>();
    for (final List<Rule> rules : ruleMap.values()) {
        allRules.addAll(rules);
    }
    return allRules;
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:21,代码来源:Rule.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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