private void loadStopWordSet() { try (BufferedReader reader = Files.newBufferedReader(stopWordPath, Charset.forName("UTF-8"))) { stopWords = WordlistLoader.getWordSet(reader, new CharArraySet(INITIAL_CAPACITY, ignoreCase)); lastModifed = Files.getLastModifiedTime(stopWordPath).toMillis(); } catch (Exception e) { throw new IllegalArgumentException("Failed to read " + stopWordPath, e); } }
private void loadKeywordSet() { try (BufferedReader reader = Files.newBufferedReader(keywordPath, Charset.forName("UTF-8"))) { keywordSet = WordlistLoader.getWordSet(reader); lastModifed = Files.getLastModifiedTime(keywordPath).toMillis(); } catch (Exception e) { throw new IllegalArgumentException("Failed to read " + keywordPath, e); } }
/** * Builds an analyzer with the given stop words. */ public GermanAnalyzer(File stopwords) throws IOException { stopSet = WordlistLoader.getWordSet(stopwords); }
/** * Builds an exclusionlist from the words contained in the given file. */ public void setStemExclusionTable(File exclusionlist) throws IOException { exclusionSet = WordlistLoader.getWordSet(exclusionlist); }
private List<String> getLines(ResourceLoader loader, String resource) throws IOException { return WordlistLoader.getLines(loader.openResource(resource), StandardCharsets.UTF_8); }
/** * Creates a CharArraySet from a file. * * @param stopwords * the stopwords file to load * * @param matchVersion * the Lucene version for cross version compatibility * @return a CharArraySet containing the distinct stopwords from the given * file * @throws IOException * if loading the stopwords throws an {@link IOException} */ public static CharArraySet loadStopwordSet(File stopwords, Version matchVersion) throws IOException { Reader reader = null; try { reader = IOUtils.getDecodingReader(stopwords, IOUtils.CHARSET_UTF_8); return WordlistLoader.getWordSet(reader, matchVersion); } finally { IOUtils.close(reader); } }
/** * Creates a CharArraySet from a file. * * @param stopwords * the stopwords reader to load * * @param matchVersion * the Lucene version for cross version compatibility * @return a CharArraySet containing the distinct stopwords from the given * reader * @throws IOException * if loading the stopwords throws an {@link IOException} */ public static CharArraySet loadStopwordSet(Reader stopwords, Version matchVersion) throws IOException { try { return WordlistLoader.getWordSet(stopwords, matchVersion); } finally { IOUtils.close(stopwords); } }
/** * Builds an analyzer with the stop words from the given file. * * @see WordlistLoader#getWordSet(Reader, Version) * @param matchVersion * Lucene version to match See {@link <a href="#version">above</a>} * @param stopwords * File to read stop words from * @deprecated Use {@link #StandardAnalyzer(Version, Reader)} instead. */ @Deprecated public StandardAnalyzer(Version matchVersion, File stopwords) throws IOException { this(matchVersion, WordlistLoader.getWordSet(IOUtils.getDecodingReader(stopwords, IOUtils.CHARSET_UTF_8), matchVersion)); }
/** * Builds an analyzer with the stop words from the given reader. * * @see WordlistLoader#getWordSet(Reader, Version) * @param matchVersion * Lucene version to match See {@link <a href="#version">above</a>} * @param stopwords * Reader to read stop words from */ public StandardAnalyzer(Version matchVersion, Reader stopwords) throws IOException { this(matchVersion, WordlistLoader.getWordSet(stopwords, matchVersion)); }
/** * Builds an analyzer which writes to the given spelling dictionary, using the * stop words from the given file. * * @see WordlistLoader#getWordSet(File) */ public SpellWritingAnalyzer(File stopwords, SpellWriter spellWriter) throws IOException { this(WordlistLoader.getWordSet(stopwords), spellWriter); }
/** * Builds an analyzer which writes to the given spelling dictionary, using the * stop words from the given reader. * * @see WordlistLoader#getWordSet(Reader) */ public SpellWritingAnalyzer(Reader stopwords, SpellWriter spellWriter) throws IOException { this(WordlistLoader.getWordSet(stopwords), spellWriter); }
/** Builds an analyzer with the stop words from the given file. * @see WordlistLoader#getWordSet(File) * @param matchVersion Lucene version to match See {@link * <a href="#version">above</a>} * @param stopwords File to read stop words from */ public ClassicAnalyzer(final Version matchVersion, final File stopwords) throws IOException { this(matchVersion, WordlistLoader.getWordSet(stopwords)); }
/** Builds an analyzer with the stop words from the given reader. * @see WordlistLoader#getWordSet(Reader) * @param matchVersion Lucene version to match See {@link * <a href="#version">above</a>} * @param stopwords Reader to read stop words from */ public ClassicAnalyzer(final Version matchVersion, final Reader stopwords) throws IOException { this(matchVersion, WordlistLoader.getWordSet(stopwords)); }
/** Builds an analyzer with the stop words from the given file. * @see WordlistLoader#getWordSet(File) * @param matchVersion Lucene version to match See {@link * <a href="#version">above</a>} * @param stopwords File to read stop words from */ public StandardAnalyzer(final Version matchVersion, final File stopwords) throws IOException { this(matchVersion, WordlistLoader.getWordSet(stopwords)); }
/** Builds an analyzer with the stop words from the given reader. * @see WordlistLoader#getWordSet(Reader) * @param matchVersion Lucene version to match See {@link * <a href="#version">above</a>} * @param stopwords Reader to read stop words from */ public StandardAnalyzer(final Version matchVersion, final Reader stopwords) throws IOException { this(matchVersion, WordlistLoader.getWordSet(stopwords)); }