for (int i = 0; i < len; i++) { char ch = term[i]; if (!isAlpha(ch)) return false; // don't stem plural(); if (matched()) break; pastTense(); if (matched()) break; aspect(); if (matched()) break; ityEndings(); if (matched()) break; nessEndings(); if (matched()) break; ionEndings(); if (matched()) break; erAndOrEndings(); if (matched()) break; lyEndings(); if (matched()) break; alEndings(); if (matched()) break; entry = wordInDict(); iveEndings(); if (matched()) break; izeEndings(); if (matched()) break; mentEndings(); if (matched()) break;
/** Returns the next, stemmed, input Token. * @return The stemmed form of a token. * @throws IOException If there is a low-level I/O error. */ @Override public boolean incrementToken() throws IOException { if (!input.incrementToken()) return false; char[] term = termAttribute.buffer(); int len = termAttribute.length(); if ((!keywordAtt.isKeyword()) && stemmer.stem(term, len)) { termAttribute.setEmpty().append(stemmer.asCharSequence()); } return true; } }
private void izeEndings() { int old_k = k; if (endsIn('i', 'z', 'e')) { word.setLength(j + 1); /* try removing -ize entirely */ k = j; if (lookup()) return; word.unsafeWrite('i'); if (doubleC(j)) { /* allow for a doubled consonant */ word.setLength(j); k = j - 1; if (lookup()) return; word.unsafeWrite(word.charAt(j - 1)); } word.setLength(j + 1); word.unsafeWrite('e'); /* try removing -ize and adding -e */ k = j + 1; if (lookup()) return; word.setLength(j + 1); word.append("ize"); k = old_k; // nolookup() } return; }
if (endsIn('i', 'n', 'g') && vowelInStem()) { k = j + 1; DictEntry entry = wordInDict(); if (entry != null) { if (!entry.exception) /* if it's in the dictionary and not an exception */ if (lookup()) return; if (doubleC(k)) { k--; word.setLength(k + 1); if (lookup()) return; lookup(); return; if ((j > 0) && isCons(j) && isCons(j - 1)) { k = j; word.setLength(k + 1);
if (endsIn('i', 'e', 'd')) { word.setLength(j + 3); k--; if (lookup()) /* we almost always want to convert -ied to -y, but */ return; /* this isn't true for short words (died->die) */ setSuffix("y"); lookup(); return; if (endsIn('e', 'd') && vowelInStem()) { DictEntry entry = wordInDict(); if (entry != null) if (!entry.exception) /* if (lookup()) return; if (doubleC(k)) { word.setLength(k); k--; if (lookup()) return; word.unsafeWrite(word.charAt(k)); k++; lookup(); return;
private void plural() { if (word.charAt(k) == 's') { if (endsIn('i', 'e', 's')) { word.setLength(j + 3); k--; if (lookup()) /* ensure calories -> calorie */ return; k++; word.unsafeWrite('s'); setSuffix("y"); lookup(); } else if (endsIn('e', 's')) { if (tryE && lookup()) return; if (lookup()) return; k++; if (!tryE) lookup(); // if we didn't try the "e" ending before return; } else { if (word.length() > 3 && penultChar() != 's' && !endsIn('o', 'u', 's')) { lookup();
/** * Returns the result of the stem (assuming the word was changed) as a String. */ String asString() { String s = getString(); if (s != null) return s; return word.toString(); }
if (endsIn('a', 'l')) { word.setLength(j + 1); k = j; if (lookup()) /* try just removing the -al */ return; if (doubleC(j)) { /* allow for a doubled consonant */ word.setLength(j); k = j - 1; if (lookup()) return; word.unsafeWrite(word.charAt(j - 1)); word.unsafeWrite('e'); /* try removing the -al and adding -e */ k = j + 1; if (lookup()) return; if (lookup()) return; word.setLength(j - 1); /* try removing -ical */ k = j - 2; if (lookup()) return; if (lookup()) return; lookup(); return; if (lookup()) return; word.append("ial");
if (endsIn('i', 'n', 'g') && vowelInStem()) { k = j + 1; DictEntry entry = wordInDict(); if (entry != null) { if (!entry.exception) /* if it's in the dictionary and not an exception */ if (lookup()) return; if (doubleC(k)) { k--; word.setLength(k + 1); if (lookup()) return; lookup(); return; if ((j > 0) && isCons(j) && isCons(j - 1)) { k = j; word.setLength(k + 1);
if (endsIn('i', 'e', 'd')) { word.setLength(j + 3); k--; if (lookup()) /* we almost always want to convert -ied to -y, but */ return; /* this isn't true for short words (died->die) */ setSuffix("y"); lookup(); return; if (endsIn('e', 'd') && vowelInStem()) { DictEntry entry = wordInDict(); if (entry != null) if (!entry.exception) /* if (lookup()) return; if (doubleC(k)) { word.setLength(k); k--; if (lookup()) return; word.unsafeWrite(word.charAt(k)); k++; lookup(); return;
private void plural() { if (word.charAt(k) == 's') { if (endsIn('i', 'e', 's')) { word.setLength(j + 3); k--; if (lookup()) /* ensure calories -> calorie */ return; k++; word.unsafeWrite('s'); setSuffix("y"); lookup(); } else if (endsIn('e', 's')) { if (tryE && lookup()) return; if (lookup()) return; k++; if (!tryE) lookup(); // if we didn't try the "e" ending before return; } else { if (word.length() > 3 && penultChar() != 's' && !endsIn('o', 'u', 's')) { lookup();
/** * Returns the result of the stem (assuming the word was changed) as a String. */ String asString() { String s = getString(); if (s != null) return s; return word.toString(); }
for (int i = 0; i < len; i++) { char ch = term[i]; if (!isAlpha(ch)) return false; // don't stem plural(); if (matched()) break; pastTense(); if (matched()) break; aspect(); if (matched()) break; ityEndings(); if (matched()) break; nessEndings(); if (matched()) break; ionEndings(); if (matched()) break; erAndOrEndings(); if (matched()) break; lyEndings(); if (matched()) break; alEndings(); if (matched()) break; entry = wordInDict(); iveEndings(); if (matched()) break; izeEndings(); if (matched()) break; mentEndings(); if (matched()) break;
if (endsIn('i', 'z', 'e', 'r')) { /* lookup(); return; if (endsIn('e', 'r') || endsIn('o', 'r')) { word_char = word.charAt(j + 1); if (doubleC(j)) { word.setLength(j); k = j - 1; if (lookup()) return; word.unsafeWrite(word.charAt(j - 1)); /* restore the doubled consonant */ word.setLength(j + 1); k = j; if (lookup()) /* yes, so check against the dictionary */ return; word.setCharAt(j, 'i'); /* restore the endings */ word.setLength(j); k = j - 1; if (lookup()) return; word.unsafeWrite('e'); if (lookup()) return; word.setLength(j + 1); /* try removing -er/-or */ k = j; if (lookup()) return; word.unsafeWrite('e'); /* try removing -or and adding -e */
if (endsIn('i', 'n', 'g') && vowelInStem()) { k = j + 1; DictEntry entry = wordInDict(); if (entry != null) { if (!entry.exception) /* if it's in the dictionary and not an exception */ if (lookup()) return; if (doubleC(k)) { k--; word.setLength(k + 1); if (lookup()) return; lookup(); return; if ((j > 0) && isCons(j) && isCons(j - 1)) { k = j; word.setLength(k + 1);
if (endsIn('i', 'e', 'd')) { word.setLength(j + 3); k--; if (lookup()) /* we almost always want to convert -ied to -y, but */ return; /* this isn't true for short words (died->die) */ setSuffix("y"); lookup(); return; if (endsIn('e', 'd') && vowelInStem()) { DictEntry entry = wordInDict(); if (entry != null) if (!entry.exception) /* if (lookup()) return; if (doubleC(k)) { word.setLength(k); k--; if (lookup()) return; word.unsafeWrite(word.charAt(k)); k++; lookup(); return;