Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

lyrics4

By: ace on Jun 9th, 2010  |  syntax: None  |  size: 4.13 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.Iterator;
  4. import java.util.Random;
  5. import java.util.StringTokenizer;
  6. /**
  7.  * Write a description of class AlanisMorissetteLyrics here.
  8.  *
  9.  * @author (your name)
  10.  * @version (a version number or a date)
  11.  */
  12. public class AlanisMorissetteLyrics
  13. {
  14.    
  15.  
  16.     /**
  17.      * Constructor for objects of class AlanisMorissetteLyrics
  18.      */
  19.     public AlanisMorissetteLyrics()
  20.     {
  21.  
  22.     }
  23.  
  24.     /**
  25.      * An example of a method - replace this comment with your own
  26.      *
  27.      * @param  y   a sample parameter for a method
  28.      * @return     the sum of x and y
  29.      */
  30.    /* public String subWords(List <String>)
  31.     {
  32.        
  33.        
  34.     }*/
  35.    
  36.    
  37.     public String subNoun(String string, ArrayList<String> nouns)
  38.     {
  39.         String s = string;
  40.         int index = 0;
  41.         while (index <= nouns.size() -1)
  42.             {
  43.                
  44.                return nouns.get(0);
  45.             }
  46.            
  47.            
  48.             return nouns.get(0);
  49. }
  50.    
  51. public String subVerb(String string, ArrayList<String> verbs)
  52.     {
  53.         String s = string;
  54.         int index = 0;
  55.         while (index <= verbs.size() -1)
  56.             {
  57.                
  58.                return verbs.get(0);
  59.             }
  60.            
  61.            
  62.             return verbs.get(0);
  63. }
  64.  
  65. public String subAdj (String string, ArrayList<String> adjs)
  66.     {
  67.         String s = string;
  68.         int index = 0;
  69.         while (index <= adjs.size() -1)
  70.             {
  71.                
  72.                return adjs.get(0);
  73.             }
  74.            
  75.            
  76.             return adjs.get(0);
  77. }
  78.  
  79. /*public String subWords(String string, ArrayList<String> nouns, ArrayList<String> verbs,
  80. ArrayList <String> adjs)
  81. {
  82. System.out.println(string);
  83. String string1 = "";
  84. String string2 ="";
  85. String string3 = "";
  86. System.out.println(string1);
  87. string1 = string.replace("noun", subNoun("noun", nouns));
  88. System.out.println(string1);
  89. string2 = string1.replace("verb", subVerb("verb", verbs));
  90. System.out.println(string1);
  91. string3 = string2.replace("adjective", subAdj("adjective", adjs));
  92. System.out.println(string1);
  93.  return string3;  
  94. }*/
  95.  
  96.  
  97. public String subWords(String string, ArrayList<String> nouns, ArrayList<String> verbs,
  98. ArrayList <String> adjs)
  99. {
  100. String string1 = "";
  101. String string2 = "";
  102. String[] result = string.split("\\s");
  103. for (String word : result)
  104.  
  105.    {
  106. System.out.println(word);
  107.        if (word.equals("noun"))
  108.                 {
  109.                   word = subNoun(string, nouns);
  110.                 System.out.println(word);
  111.                 }
  112.                
  113.         if (word.equals("verb"))
  114.                 {
  115.                   word = subVerb(string, verbs);
  116.                   System.out.println(word);
  117.                 }
  118.                
  119.               if (word.equals("adjective"))
  120.                 {  
  121.                word = subAdj(string, adjs);
  122.                System.out.println(word);
  123.     }
  124.     string1 = string2 + " " + word;
  125.     string2 = string1;
  126. }
  127. return string2;
  128.    
  129.  
  130. }
  131.  
  132. //string.replace ("noun", nouns.get(0));
  133. //string.replace ("verb", verbs.get(0));
  134. //string.replace ("adjective", adjs.get(0));
  135. /*int resultIndex = 0;
  136.  
  137. while (resultIndex <= result.size())
  138.     {
  139.         if (string.equals ("noun"))
  140.             {
  141.                 string.replace("noun", nouns.getIndex(resultIndex));
  142.             }  
  143.             resultIndex++;
  144.            
  145.         }
  146.  
  147.     if (string.equals("noun"))
  148.     {
  149.            System.out.println("string" + subNoun(string, nouns));
  150.             return subNoun(string, nouns);
  151.         }  
  152.  
  153.     if (string.equals("verb"))
  154.     {
  155.         return subVerb(string, verbs);
  156.     }
  157.    
  158.           if(string.equals("adjective"))
  159.           {
  160.                         return subAdj(string, adjs);
  161.                     }
  162.                
  163.                     return string;
  164.                 }*/
  165.                
  166.  /*public String generate(randomNouns, randomVerbs, randomAdjectives)
  167.     {
  168.         randomNouns = new Random();
  169.         randomVerbs = new Random();
  170.         randomAdjectives = new Random();
  171.     }*/
  172.    
  173.    
  174. }