Java Code Examples for org.apache.lucene.analysis.compound.HyphenationCompoundWordTokenFilter#getHyphenationTree()

The following examples show how to use org.apache.lucene.analysis.compound.HyphenationCompoundWordTokenFilter#getHyphenationTree() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HyphenationCompoundWordTokenFilterFactory.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public HyphenationCompoundWordTokenFilterFactory(Index index, IndexSettingsService indexSettingsService, Environment env, @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettingsService.getSettings(), env, name, settings);

    String hyphenationPatternsPath = settings.get("hyphenation_patterns_path", null);
    if (hyphenationPatternsPath == null) {
        throw new IllegalArgumentException("hyphenation_patterns_path is a required setting.");
    }

    Path hyphenationPatternsFile = env.configFile().resolve(hyphenationPatternsPath);

    try {
        hyphenationTree = HyphenationCompoundWordTokenFilter.getHyphenationTree(new InputSource(Files.newInputStream(hyphenationPatternsFile)));
    } catch (Exception e) {
        throw new IllegalArgumentException("Exception while reading hyphenation_patterns_path: " + e.getMessage());
    }
}
 
Example 2
Source File: HyphenationCompoundWordTokenFilterFactory.java    From crate with Apache License 2.0 6 votes vote down vote up
HyphenationCompoundWordTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) {
    super(indexSettings, env, name, settings);

    String hyphenationPatternsPath = settings.get("hyphenation_patterns_path", null);
    if (hyphenationPatternsPath == null) {
        throw new IllegalArgumentException("hyphenation_patterns_path is a required setting.");
    }

    Path hyphenationPatternsFile = env.configFile().resolve(hyphenationPatternsPath);

    try {
        InputStream in = Files.newInputStream(hyphenationPatternsFile);
        hyphenationTree = HyphenationCompoundWordTokenFilter.getHyphenationTree(new InputSource(in));
    } catch (Exception e) {
        throw new IllegalArgumentException("Exception while reading hyphenation_patterns_path.", e);
    }
}