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


Java TokenFilterFactory类代码示例

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


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

示例1: getTokenFilterFactory

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
public synchronized TokenFilterFactory getTokenFilterFactory(final Version version) {
TokenFilterFactory factory = cache.get(version);
if (factory == null) {
    final String finalName = name().toLowerCase(Locale.ROOT);
    if (isMultiTermAware()) {
        factory = new MultiTermAwareTokenFilterFactory() {
            @Override
            public String name() {
                return finalName;
            }

            @Override
            public TokenStream create(TokenStream tokenStream) {
                return PreBuiltTokenFilters.this.create(tokenStream, version);
            }

            @Override
            public Object getMultiTermComponent() {
                return this;
            }
        };
    } else {
        factory = new TokenFilterFactory() {
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:PreBuiltTokenFilters.java

示例2: getShingleFilterFactory

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
private static ShingleTokenFilterFactory.Factory getShingleFilterFactory(Analyzer analyzer) {
    if (analyzer instanceof NamedAnalyzer) {
        analyzer = ((NamedAnalyzer)analyzer).analyzer();
    }
    if (analyzer instanceof CustomAnalyzer) {
        final CustomAnalyzer a = (CustomAnalyzer) analyzer;
        final TokenFilterFactory[] tokenFilters = a.tokenFilters();
        for (TokenFilterFactory tokenFilterFactory : tokenFilters) {
            if (tokenFilterFactory instanceof ShingleTokenFilterFactory) {
                return ((ShingleTokenFilterFactory)tokenFilterFactory).getInnerFactory();
            } else if (tokenFilterFactory instanceof ShingleTokenFilterFactory.Factory) {
                return (ShingleTokenFilterFactory.Factory) tokenFilterFactory;
            }
        }
    }
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:PhraseSuggestionBuilder.java

示例3: containsBrokenAnalysis

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
private static boolean containsBrokenAnalysis(Analyzer analyzer) {
    // TODO maybe we need a getter on Namedanalyzer that tells if this uses broken Analysis
    if (analyzer instanceof NamedAnalyzer) {
        analyzer = ((NamedAnalyzer) analyzer).analyzer();
    }
    if (analyzer instanceof CustomAnalyzer) {
        final CustomAnalyzer a = (CustomAnalyzer) analyzer;
        TokenFilterFactory[] tokenFilters = a.tokenFilters();
        for (TokenFilterFactory tokenFilterFactory : tokenFilters) {
            if (tokenFilterFactory instanceof WordDelimiterTokenFilterFactory
                    || tokenFilterFactory instanceof EdgeNGramTokenFilterFactory) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:FragmentBuilderHelper.java

示例4: getShingleFilterFactory

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
public static ShingleTokenFilterFactory.Factory getShingleFilterFactory(Analyzer analyzer) {
    if (analyzer instanceof NamedAnalyzer) {
        analyzer = ((NamedAnalyzer)analyzer).analyzer();
    }
    if (analyzer instanceof CustomAnalyzer) {
        final CustomAnalyzer a = (CustomAnalyzer) analyzer;
        final TokenFilterFactory[] tokenFilters = a.tokenFilters();
        for (TokenFilterFactory tokenFilterFactory : tokenFilters) {
            if (tokenFilterFactory instanceof ShingleTokenFilterFactory) {
                return ((ShingleTokenFilterFactory)tokenFilterFactory).getInnerFactory();
            } else if (tokenFilterFactory instanceof ShingleTokenFilterFactory.Factory) {
                return (ShingleTokenFilterFactory.Factory) tokenFilterFactory;
            }
        }
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:SuggestUtils.java

示例5: testTokenizerFilter

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
@Test
public void testTokenizerFilter() throws IOException {

    String source = "eins zwei drei";

    String[] expected = {
            "d800000000001214",
            "4a00000000000000",
            "c0000000000a100"
    };
    AnalysisService analysisService = MapperTestUtils.analysisService("eudex_analysis.json");
    TokenFilterFactory tokenFilterFactory = analysisService.tokenFilter("my_phonetic");
    Tokenizer tokenizer = analysisService.tokenizer("my_phonetic").create();
    tokenizer.setReader(new StringReader(source));
    assertSimpleTSOutput(tokenFilterFactory.create(tokenizer), expected);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-phonetic-eudex,代码行数:17,代码来源:EudexAnalyzerTests.java

示例6: testOne

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
@Test
public void testOne() throws IOException {

    String source = "Das ist ein Bindestrich-Wort.";

    String[] expected = {
            "Das",
            "ist",
            "ein",
            "Bindestrich-Wort",
            "BindestrichWort",
            "Wort",
            "Bindestrich"
    };
    String resource = "org/xbib/elasticsearch/index/analysis/hyphen/hyphen_tokenizer.json";
    Tokenizer tokenizer = tokenizerFactory(resource, "my_hyphen_tokenizer").create();
    tokenizer.setReader(new StringReader(source));
    TokenFilterFactory tokenFilter = tokenFilterFactory(resource, "hyphen");
    TokenStream tokenStream = tokenFilter.create(tokenizer);
    assertSimpleTSOutput(tokenStream, expected);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-hyphen,代码行数:22,代码来源:HyphenTokenizerTests.java

示例7: testTwo

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
@Test
public void testTwo() throws IOException {

    String source = "Das E-Book muss dringend zum Buchbinder.";

    String[] expected = {
            "Das",
            "E-Book",
            "EBook",
            "Book",
            "muss",
            "dringend",
            "zum",
            "Buchbinder"
    };
    String resource = "org/xbib/elasticsearch/index/analysis/hyphen/hyphen_tokenizer.json";
    Tokenizer tokenizer = tokenizerFactory(resource, "my_hyphen_tokenizer").create();
    tokenizer.setReader(new StringReader(source));
    TokenFilterFactory tokenFilter = tokenFilterFactory(resource, "hyphen");
    assertSimpleTSOutput(tokenFilter.create(tokenizer), expected);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-hyphen,代码行数:22,代码来源:HyphenTokenizerTests.java

示例8: testFour

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
@Test
public void testFour() throws IOException {

    String source = "So wird's was: das Elasticsearch-Buch erscheint beim O'Reilly-Verlag.";

    String[] expected = {
            "So",
            "wird's",
            "was",
            "das",
            "Elasticsearch-Buch",
            "ElasticsearchBuch",
            "Buch",
            "Elasticsearch",
            "erscheint",
            "beim",
            "O'Reilly-Verlag"
    };
    String resource = "org/xbib/elasticsearch/index/analysis/hyphen/hyphen_tokenizer.json";
    Tokenizer tokenizer = tokenizerFactory(resource, "my_hyphen_tokenizer").create();
    tokenizer.setReader(new StringReader(source));
    TokenFilterFactory tokenFilter = tokenFilterFactory(resource, "hyphen");
    assertSimpleTSOutput(tokenFilter.create(tokenizer), expected);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-hyphen,代码行数:25,代码来源:HyphenTokenizerTests.java

示例9: testSix

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
@Test
public void testSix() throws IOException {

    String source = "E-Book";

    String[] expected = {
            "E-Book",
            "EBook",
            "Book"
    };

    String resource = "org/xbib/elasticsearch/index/analysis/hyphen/hyphen_tokenizer.json";
    Tokenizer tokenizer = tokenizerFactory(resource, "my_hyphen_tokenizer").create();
    tokenizer.setReader(new StringReader(source));
    TokenFilterFactory tokenFilter = tokenFilterFactory(resource, "hyphen");
    assertSimpleTSOutput(tokenFilter.create(tokenizer), expected);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-hyphen,代码行数:18,代码来源:HyphenTokenizerTests.java

示例10: testSeven

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
@Test
public void testSeven() throws IOException {
    String source = "Procter & Gamble ist Procter&Gamble. Schwarz - weiss ist schwarz-weiss";

    String[] expected = {
            "Procter",
            "Gamble",
            "ist",
            "Procter&Gamble",
            "Schwarz",
            "weiss",
            "ist",
            "schwarz-weiss",
            "schwarzweiss",
            "weiss",
            "schwarz"
    };

    String resource = "org/xbib/elasticsearch/index/analysis/hyphen/hyphen_tokenizer.json";
    Tokenizer tokenizer = tokenizerFactory(resource, "my_hyphen_tokenizer").create();
    tokenizer.setReader(new StringReader(source));
    TokenFilterFactory tokenFilter = tokenFilterFactory(resource, "hyphen");
    assertSimpleTSOutput(tokenFilter.create(tokenizer), expected);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-hyphen,代码行数:25,代码来源:HyphenTokenizerTests.java

示例11: testOpenNLPAnalysis

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
@Test
public void testOpenNLPAnalysis() throws Exception {
    AnalysisService analysisService = MapperTestUtils.analysisService(getResource());
    TokenizerFactory tokenizerFactory = analysisService.tokenizer("opennlp");
    MatcherAssert.assertThat(tokenizerFactory, instanceOf(OpenNLPTokenizerFactory.class));
    this.tokenizerFactory = (OpenNLPTokenizerFactory) tokenizerFactory;
    TokenFilterFactory filterFactory = analysisService.tokenFilter("opennlp");
    MatcherAssert.assertThat(filterFactory, instanceOf(OpenNLPTokenFilterFactory.class));
    this.filterFactory = (OpenNLPTokenFilterFactory) filterFactory;

    TokenFilterFactory filterpayloadsfilterFactory = analysisService.tokenFilter("filterpayloads");
    MatcherAssert.assertThat(filterpayloadsfilterFactory, instanceOf(FilterPayloadsTokenFilterFactory.class));
    TokenFilterFactory strippayloadsfilterFactory = analysisService.tokenFilter("strippayloads");
    MatcherAssert.assertThat(strippayloadsfilterFactory, instanceOf(StripPayloadsTokenFilterFactory.class));

    analyze();
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-opennlp,代码行数:18,代码来源:BaseOpenNLPAnalysis.java

示例12: JapaneseBaseFormFilterFactory

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
public JapaneseBaseFormFilterFactory(final IndexSettings indexSettings, final Environment env, final String name,
        final Settings settings, final FessAnalysisService fessAnalysisService) {
    super(indexSettings, name, settings);

    for (final String factoryClass : FACTORIES) {
        final Class<?> tokenFilterFactoryClass = fessAnalysisService.loadClass(factoryClass);
        if (tokenFilterFactoryClass != null) {
            if (logger.isInfoEnabled()) {
                logger.info("{} is found.", factoryClass);
            }
            tokenFilterFactory = AccessController.doPrivileged((PrivilegedAction<TokenFilterFactory>) () -> {
                try {
                    final Constructor<?> constructor = tokenFilterFactoryClass.getConstructor(IndexSettings.class, Environment.class,
                            String.class, Settings.class);
                    return (TokenFilterFactory) constructor.newInstance(indexSettings, env, name, settings);
                } catch (final Exception e) {
                    throw new ElasticsearchException("Failed to load " + factoryClass, e);
                }
            });
            break;
        } else if (logger.isDebugEnabled()) {
            logger.debug("{} is not found.", factoryClass);
        }
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-analysis-fess,代码行数:26,代码来源:JapaneseBaseFormFilterFactory.java

示例13: JapanesePartOfSpeechFilterFactory

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
public JapanesePartOfSpeechFilterFactory(final IndexSettings indexSettings, final Environment env, final String name,
        final Settings settings, final FessAnalysisService fessAnalysisService) {
    super(indexSettings, name, settings);

    for (final String factoryClass : FACTORIES) {
        final Class<?> TokenFilterFactoryClass = fessAnalysisService.loadClass(factoryClass);
        if (TokenFilterFactoryClass != null) {
            if (logger.isInfoEnabled()) {
                logger.info("{} is found.", factoryClass);
            }
            tokenFilterFactory = AccessController.doPrivileged((PrivilegedAction<TokenFilterFactory>) () -> {
                try {
                    final Constructor<?> constructor = TokenFilterFactoryClass.getConstructor(IndexSettings.class, Environment.class,
                            String.class, Settings.class);
                    return (TokenFilterFactory) constructor.newInstance(indexSettings, env, name, settings);
                } catch (final Exception e) {
                    throw new ElasticsearchException("Failed to load " + factoryClass, e);
                }
            });
            break;
        } else if (logger.isDebugEnabled()) {
            logger.debug("{} is not found.", factoryClass);
        }
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-analysis-fess,代码行数:26,代码来源:JapanesePartOfSpeechFilterFactory.java

示例14: JapaneseKatakanaStemmerFactory

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
public JapaneseKatakanaStemmerFactory(final IndexSettings indexSettings, final Environment env, final String name,
        final Settings settings, final FessAnalysisService fessAnalysisService) {
    super(indexSettings, name, settings);

    for (final String factoryClass : FACTORIES) {
        final Class<?> tokenizerFactoryClass = fessAnalysisService.loadClass(factoryClass);
        if (tokenizerFactoryClass != null) {
            if (logger.isInfoEnabled()) {
                logger.info("{} is found.", factoryClass);
            }
            tokenFilterFactory = AccessController.doPrivileged((PrivilegedAction<TokenFilterFactory>) () -> {
                try {
                    final Constructor<?> constructor =
                            tokenizerFactoryClass.getConstructor(IndexSettings.class, Environment.class, String.class, Settings.class);
                    return (TokenFilterFactory) constructor.newInstance(indexSettings, env, name, settings);
                } catch (final Exception e) {
                    throw new ElasticsearchException("Failed to load " + factoryClass, e);
                }

            });
            break;
        } else if (logger.isDebugEnabled()) {
            logger.debug("{} is not found.", factoryClass);
        }
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-analysis-fess,代码行数:27,代码来源:JapaneseKatakanaStemmerFactory.java

示例15: JapaneseReadingFormFilterFactory

import org.elasticsearch.index.analysis.TokenFilterFactory; //导入依赖的package包/类
public JapaneseReadingFormFilterFactory(final IndexSettings indexSettings, final Environment env, final String name,
        final Settings settings, final FessAnalysisService fessAnalysisService) {
    super(indexSettings, name, settings);

    for (final String factoryClass : FACTORIES) {
        final Class<?> tokenFilterFactoryClass = fessAnalysisService.loadClass(factoryClass);
        if (tokenFilterFactoryClass != null) {
            if (logger.isInfoEnabled()) {
                logger.info("{} is found.", factoryClass);
            }
            tokenFilterFactory = AccessController.doPrivileged((PrivilegedAction<TokenFilterFactory>) () -> {
                try {
                    final Constructor<?> constructor = tokenFilterFactoryClass.getConstructor(IndexSettings.class, Environment.class,
                            String.class, Settings.class);
                    return (TokenFilterFactory) constructor.newInstance(indexSettings, env, name, settings);
                } catch (final Exception e) {
                    throw new ElasticsearchException("Failed to load " + factoryClass, e);
                }
            });
            break;
        } else if (logger.isDebugEnabled()) {
            logger.debug("{} is not found.", factoryClass);
        }
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-analysis-fess,代码行数:26,代码来源:JapaneseReadingFormFilterFactory.java


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