/** * Returns true if the given string is a stop word. * * @param word the word to test * @return true if the word is a stopword */ @Override protected synchronized boolean is(String word) { for (Pattern pattern: m_Patterns) { if (pattern.matcher(word.trim().toLowerCase()).matches()) { if (m_Debug) debug(pattern.pattern() + " --> true"); return true; } else { if (m_Debug) debug(pattern.pattern() + " --> false"); } } return false; } }
/** * Performs intialization of the scheme. */ @Override protected void initialize() { List<String> patterns; super.initialize(); m_Patterns = new ArrayList<Pattern>(); patterns = read(); for (String pattern: patterns) { m_Patterns.add(Pattern.compile(pattern)); } }
/** * Used to create an instance of a specific stopwords scheme. * * @return a suitably configured <code>StopwordsHandler</code> value */ @Override public StopwordsHandler getStopwords() { RegExpFromFile result; result = new RegExpFromFile(); result.setStopwords(new File(getTmpDirectory() + File.separator + "RegExpFromFile.txt")); return result; }
/** * Used to create an instance of a specific stopwords scheme. * * @return a suitably configured <code>StopwordsHandler</code> value */ @Override public StopwordsHandler getStopwords() { RegExpFromFile result; result = new RegExpFromFile(); result.setStopwords(new File(getTmpDirectory() + File.separator + "RegExpFromFile.txt")); return result; }
/** * Used to create an instance of a specific stopwords scheme. * * @return a suitably configured <code>StopwordsHandler</code> value */ @Override public StopwordsHandler getStopwords() { MultiStopwords result; StopwordsHandler[] handlers; result = new MultiStopwords(); handlers = new StopwordsHandler[3]; handlers[0] = new Rainbow(); handlers[1] = new WordsFromFile(); ((WordsFromFile) handlers[1]).setStopwords(new File(getTmpDirectory() + File.separator + "WordsFromFile.txt")); handlers[2] = new RegExpFromFile(); ((RegExpFromFile) handlers[2]).setStopwords(new File(getTmpDirectory() + File.separator + "RegExpFromFile.txt")); result.setStopwords(handlers); return result; }
/** * Performs intialization of the scheme. */ @Override protected void initialize() { List<String> patterns; super.initialize(); m_Patterns = new ArrayList<Pattern>(); patterns = read(); for (String pattern: patterns) { m_Patterns.add(Pattern.compile(pattern)); } }
/** * Returns true if the given string is a stop word. * * @param word the word to test * @return true if the word is a stopword */ @Override protected synchronized boolean is(String word) { for (Pattern pattern: m_Patterns) { if (pattern.matcher(word.trim().toLowerCase()).matches()) { if (m_Debug) debug(pattern.pattern() + " --> true"); return true; } else { if (m_Debug) debug(pattern.pattern() + " --> false"); } } return false; } }
/** * Used to create an instance of a specific stopwords scheme. * * @return a suitably configured <code>StopwordsHandler</code> value */ @Override public StopwordsHandler getStopwords() { MultiStopwords result; StopwordsHandler[] handlers; result = new MultiStopwords(); handlers = new StopwordsHandler[3]; handlers[0] = new Rainbow(); handlers[1] = new WordsFromFile(); ((WordsFromFile) handlers[1]).setStopwords(new File(getTmpDirectory() + File.separator + "WordsFromFile.txt")); handlers[2] = new RegExpFromFile(); ((RegExpFromFile) handlers[2]).setStopwords(new File(getTmpDirectory() + File.separator + "RegExpFromFile.txt")); result.setStopwords(handlers); return result; }