Question: Java, Challenging Question, Hi ive been attempteing to complete this question for almost 2 weeks and have had no success. If anyone could give me
Java, Challenging Question,
Hi ive been attempteing to complete this question for almost 2 weeks and have had no success. If anyone could give me the correct answer to this I would truly appreciate it.
Question: Given a String with multiple lines, return its rhyme scheme with the first line labeled A and each new ending syllable is B, then C, etc. You don't have to identify if the scheme repeats so if the input has 10 lines that follow an AB rhyming scheme the output will be "ABABABABAB" // In case this doesn't make sense, see Wikipedia's description of rhyme schemes which is more clear and // and in depth than the above description: https://en.wikipedia.org/wiki/Rhyme_scheme // // You may assume that the input has at most 9 different rhymes (ie. will use the letters A-I)
static String Q3(String lyrics){
return ""; }
here is the class words that must be used to complete this question
public class Words{
private static final String DIRECTORY = "/data/"; private static final String DICTIONARY_FILENAME = DIRECTORY + "cmudict-0.7b"; private static final String ADJECTIVES_FILENAME = DIRECTORY + "index.adj"; private static final String ADVERBS_FILENAME = DIRECTORY + "index.adv"; private static final String NOUNS_FILENAME = DIRECTORY + "index.noun"; private static final String SENSES_FILENAME = DIRECTORY + "index.sense"; private static final String VERB_FILENAME = DIRECTORY + "index.verb";
private static Map
/** * Return the number of syllables in the input word. */ public static int numberOfSyllables(String word){ int syllables = 0; List
}
/** * Returns an ArrayList containing all the possible parts of speech of the input word. An empty ArrayList * is returned if the part of speech is unknown. */ public static ArrayList
/** * returns the number of rhyming syllables between the two input words. Returns 0 if either word in not found in * the dictionary. */ public static int rhymeLength(String word1, String word2){ List
/** * returns the number of alliterating sounds between the two input words. Returns 0 if either word in not found in * the dictionary. */ public static int alliterationLength(String word1, String word2){ List
// private methods
private static List
Map
if(dictionary.containsKey(word.toLowerCase())){ return dictionary.get(word.toLowerCase()); }else{ return null; }
}
private static boolean isVowel(String sound){ return sound.length() > 2; }
private static Map
if(Words.dictionary == null){
Words.dictionary = new HashMap<>();
Set
}
return Words.dictionary; }
private static Map
if(Words.partOfSpeech == null){ Words.partOfSpeech = new HashMap<>(); parsePartsOfSpeechFile("adjective", Words.ADJECTIVES_FILENAME); parsePartsOfSpeechFile("adverb", Words.ADVERBS_FILENAME); parsePartsOfSpeechFile("noun", Words.NOUNS_FILENAME); parsePartsOfSpeechFile("sense", Words.SENSES_FILENAME); parsePartsOfSpeechFile("verb", Words.VERB_FILENAME); }
return Words.partOfSpeech; }
private static void parsePartsOfSpeechFile(String partOfSpeech, String filename){ Set
public static void main(String[] args){ String word = "orange"; System.out.println(getPartsOfSpeech(word)); System.out.println(numberOfSyllables(word)); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
