Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Stemmer
- {
- public static void main (String []args)
- {
- Scanner keyboard = new Scanner (System.in);
- {
- while (keyboard.hasNext())
- {
- String word = keyboard.next();
- //int ing, sses, ies, s, eed, ed;
- int ending;
- System.out.println("Put a word" );
- if
- (word.length() > 4 && word.endsWith("ing"))
- {
- ending = word.lastIndexOf ("ing");
- System.out.println(word.substring(0, ending ));
- } else if
- (word.endsWith("sses"))
- {
- ending = word.lastIndexOf("es");
- System.out.println(word.substring(0, ending ));
- } else if (word.endsWith("ies"))
- { String newWord;
- newWord = word.replace("ies", "y");
- System.out.println(newWord);
- } else if (word.endsWith("s") && !word.endsWith("sses") && !word.endsWith("ies") && !word.endsWith("ss"))
- { ending = word.lastIndexOf ("s");
- System.out.println(word.substring(0, ending ));
- } else if (word.length() > 4 && word.endsWith("eed"))
- {ending = word.lastIndexOf ("d");
- System.out.println(word.substring(0, ending ));
- } else if ((word.length() > 4) && word.endsWith("ed") && !word.endsWith("eed"))
- {ending = word.lastIndexOf ("ed");
- System.out.println(word.substring(0, ending ));
- } else
- { System.out.println (word);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement