本文整理汇总了Java中org.apache.commons.codec.language.bm.PhoneticEngine类的典型用法代码示例。如果您正苦于以下问题:Java PhoneticEngine类的具体用法?Java PhoneticEngine怎么用?Java PhoneticEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhoneticEngine类属于org.apache.commons.codec.language.bm包,在下文中一共展示了PhoneticEngine类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import org.apache.commons.codec.language.bm.PhoneticEngine; //导入依赖的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.PhoneticEngine; //导入依赖的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.PhoneticEngine; //导入依赖的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.PhoneticEngine; //导入依赖的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: testEmptyTerm
import org.apache.commons.codec.language.bm.PhoneticEngine; //导入依赖的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
示例6: testCustomAttribute
import org.apache.commons.codec.language.bm.PhoneticEngine; //导入依赖的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
示例7: testEmptyTerm
import org.apache.commons.codec.language.bm.PhoneticEngine; //导入依赖的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
示例8: populate
import org.apache.commons.codec.language.bm.PhoneticEngine; //导入依赖的package包/类
@Override
protected void populate(Timer timer) throws Exception {
PhoneticEngine encoder = BeiderMorseCache.INSTANCE
.getEncoder(encoderKey);
String terms = null;
synchronized (encoder) {
terms = encoder.encode(term);
}
if (terms == null)
return;
tokens = StringUtils.split(terms, '|');
}
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:13,代码来源:BeiderMorseCacheItem.java
示例9: main
import org.apache.commons.codec.language.bm.PhoneticEngine; //导入依赖的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
示例10: testCustomAttribute
import org.apache.commons.codec.language.bm.PhoneticEngine; //导入依赖的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
示例11: createComponents
import org.apache.commons.codec.language.bm.PhoneticEngine; //导入依赖的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
示例12: BeiderMorseFilter
import org.apache.commons.codec.language.bm.PhoneticEngine; //导入依赖的package包/类
/**
* Calls
* {@link #BeiderMorseFilter(TokenStream, PhoneticEngine, org.apache.commons.codec.language.bm.Languages.LanguageSet)}
*
* @param input TokenStream to filter
* @param engine configured PhoneticEngine with BM settings.
*/
public BeiderMorseFilter(TokenStream input, PhoneticEngine engine) {
this(input, engine, null);
}
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:BeiderMorseFilter.java
注:本文中的org.apache.commons.codec.language.bm.PhoneticEngine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论