Exemplo n.º 1
0
 private static DictRadix<MorphData> loadFromPath(final File path) {
   try {
     return Loader.loadDictionaryFromHSpellData(path, true);
   } catch (IOException ex) {
     throw new IllegalStateException("Failed to read data", ex);
   }
 }
Exemplo n.º 2
0
 private static DictRadix<MorphData> loadFromEnvVariable() throws IOException {
   String hspellPath = System.getenv(DEFAULT_HSPELL_ENV_VARIABLE);
   if (hspellPath == null) {
     throw new IllegalStateException(
         "Failed to load hspell dictionary files. They should be configured "
             + "in classpath or by "
             + DEFAULT_HSPELL_ENV_VARIABLE
             + " environment variable");
   }
   return Loader.loadDictionaryFromHSpellData(new File(hspellPath), true);
 }
Exemplo n.º 3
0
 private static DictRadix<MorphData> loadFromClasspath(final String pathInClasspath) {
   try {
     return Loader.loadDictionaryFromClasspath(pathInClasspath, true);
   } catch (IOException ex) {
     try {
       // Try to use environment variable if failed with classpath
       return loadFromEnvVariable();
     } catch (IOException e) {
       throw new IllegalStateException("Failed to read data", ex);
     }
   }
 }