private final boolean vowelinstem() { int i; for (i = 0; i <= j; i++) { if (!cons(i)) { return true; } } return false; }
private final void step2() { if (ends("y") && vowelinstem()) { b[k] = 'i'; } }
private void step1() { if (b[k] == 's') { if (ends("sses")) { k -= 2; } else if (ends("ies")) { setto("i"); } else if (b[k - 1] != 's') { k--; if (ends("eed")) { if (m() > 0) { k--; } else if ((ends("ed") || ends("ing")) && vowelinstem()) { k = j; if (ends("at")) { setto("ate"); } else if (ends("bl")) { setto("ble"); } else if (ends("iz")) { setto("ize"); } else if (doublec(k)) { k--; } else if (m() == 1 && cvc(k)) { setto("e");
private final void step4() { switch (b[k]) { case 'e': if (ends("icate")) { r("ic"); break; if (ends("ative")) { r(""); break; if (ends("alize")) { r("al"); break; if (ends("iciti")) { r("ic"); break; if (ends("ical")) { r("ic"); break; if (ends("ful")) { r(""); break; if (ends("ness")) { r(""); break;
/** * Test program for demonstrating the Stemmer. It reads text from a * a list of files, stems each word, and writes the result to standard * output. Note that the word stemmed is expected to be in lower case: * forcing lower case must be done outside the Stemmer class. * Usage: Stemmer file-name file-name ... */ public static void main(String[] args) throws IOException { Stemmer s = new Stemmer(); if (args[0].equals("-file")) { Iterator<Word> it = PTBTokenizer.newPTBTokenizer(new InputStreamReader(new FileInputStream(args[1]), "utf-8")); while (it.hasNext()) { Word token = it.next(); System.out.print(s.stem(token.word())); System.out.print(' '); } } else { for (String arg : args) { System.out.print(s.stem(arg)); System.out.print(' '); } } System.out.println(); }
/** * Stems <code>word</code> (which must be a <code>Word</code>, * or else * a ClassCastException will be thrown, and returns stemmed * <code>Word</code>. */ public Word apply(Word word) { return stem(word); }
/** * Stems <code>w</code> and returns stemmed <code>Word</code>. */ public Word stem(Word w) { return (new Word(stem(w.word()))); }
private final boolean doublec(int j) { if (j < 1) { return false; } if (b[j] != b[j - 1]) { return false; } return cons(j); }
private final boolean cons(int i) { switch (b[i]) { case 'a': case 'e': case 'i': case 'o': case 'u': return false; case 'y': return (i == 0) ? true : !cons(i - 1); default: return true; } }