Example usage for org.apache.lucene.analysis.hunspell Dictionary Dictionary

List of usage examples for org.apache.lucene.analysis.hunspell Dictionary Dictionary

Introduction

In this page you can find the example usage for org.apache.lucene.analysis.hunspell Dictionary Dictionary.

Prototype

public Dictionary(Directory tempDir, String tempFileNamePrefix, InputStream affix, InputStream dictionary)
        throws IOException, ParseException 

Source Link

Document

Creates a new Dictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files.

Usage

From source file:org.elasticsearch.indices.analysis.AnalysisModuleTests.java

License:Apache License

public void testRegisterHunspellDictionary() throws Exception {
    Settings settings = Settings.builder()
            .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
    Environment environment = new Environment(settings);
    InputStream aff = getClass().getResourceAsStream("/indices/analyze/conf_dir/hunspell/en_US/en_US.aff");
    InputStream dic = getClass().getResourceAsStream("/indices/analyze/conf_dir/hunspell/en_US/en_US.dic");
    Dictionary dictionary;/*from   w  w w . ja  v a 2 s .co m*/
    try (Directory tmp = new SimpleFSDirectory(environment.tmpFile())) {
        dictionary = new Dictionary(tmp, "hunspell", aff, dic);
    }
    AnalysisModule module = new AnalysisModule(environment, singletonList(new AnalysisPlugin() {
        @Override
        public Map<String, Dictionary> getHunspellDictionaries() {
            return singletonMap("foo", dictionary);
        }
    }));
    assertSame(dictionary, module.getHunspellService().getDictionary("foo"));
}