Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.   public class Stemmer
  3.   {
  4.     public static void main (String []args)
  5.     {
  6.   Scanner keyboard = new Scanner (System.in);
  7.   {
  8.  while (keyboard.hasNext())
  9.   {
  10.   String word = keyboard.next();
  11.  
  12.  //int ing, sses, ies, s, eed, ed;
  13. int ending;
  14.   System.out.println("Put a word" );
  15. if
  16.   (word.length() > 4 && word.endsWith("ing"))
  17. {
  18.       ending = word.lastIndexOf ("ing");
  19.     System.out.println(word.substring(0, ending ));
  20.                        }   else if
  21.                        (word.endsWith("sses"))
  22.                        {
  23.       ending = word.lastIndexOf("es");
  24.     System.out.println(word.substring(0, ending ));
  25.                        } else  if  (word.endsWith("ies"))
  26.                                       {   String newWord;
  27.        
  28.     newWord = word.replace("ies", "y");
  29.     System.out.println(newWord);
  30.          } else if  (word.endsWith("s") && !word.endsWith("sses") && !word.endsWith("ies") && !word.endsWith("ss"))
  31.               { ending = word.lastIndexOf ("s");
  32.     System.out.println(word.substring(0, ending ));
  33.             } else if (word.length() > 4 && word.endsWith("eed"))
  34.               {ending = word.lastIndexOf ("d");
  35.     System.out.println(word.substring(0, ending ));
  36.                } else if ((word.length() > 4) && word.endsWith("ed") && !word.endsWith("eed"))
  37.               {ending = word.lastIndexOf ("ed");
  38.                  System.out.println(word.substring(0, ending ));
  39.                } else
  40.                { System.out.println (word);
  41.                }
  42.                }
  43.   }
  44.   }
  45.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement