I had no idea how to write this question, because it is a multi-stage question!
Some background: I am trying to combine my background in English literature and grammar, about my love for "face divorced" memo poems and about my growing knowledge of javascript to create a lik the bred poem generator.
In principle, the user enters a one-word name / noun, and a rhyme poem will be created based on this word. The logic for this first bit is as follows:
- Step One: Get User Input
- Step Two: Find out how long user input (this step may not be needed)
- Step Three: Find the first vowel (including only "y" if it is the only vowel - alternatively, include only "y" if this is the last letter)
- Fourth step: select all letters, including after that. vowel
- Step Five: Compare these letters with possible end rhymes.
The problem is that I'm not sure how to handle steps three and four. (I am open to solutions using jQuery or javascript libraries, but since I'm still a beginner, I did not attach much importance to writing anything other than direct javascript from scratch.
NB: If the upper limit for length is useful, nine characters will make sense, since the longest monosyllables in English are 9 letters long.
My first thought was to make a conditional statement, for example:
var noun = document.getElementById('noun').value;
var n = noun.str.length;
var place = 0
var firstVow;
while (place < 10) {
if (noun.charAt(place) == 'a' ||
noun.charAt(place) == 'e' ||
noun.charAt(place) == 'i' ||
noun.charAt(place) == 'o' ||
noun.charAt(place) == 'u'||
noun.charAt(n) == 'y') {
firstVow = noun.indexOf(place);}
else {
place++;
}
}
var numSel = n - firstVow;
var nounSel = noun.substr(firstVow, numSel);
( , ... , , ), , a/e/i/o/u/word-terminal-y, ... .
, , ( ), , ). , , , ? , .
!
:
, " ":
- "ay", "": [ay, eigh, ei]
- "i", "": [y, eye, aye, ye]
- "", "": [a, ah, aw]
- "ot" , "": [ot, ott, shouldugh, aught]
:
- : : ""
- 1: [: "" ]
- 2: [: 5 , aka 0-4]
- 3: [: "o" 2]
- 4: [: "ott" ]
- 5: / (: "ot" )
- 6: 3, 5 7 "ot" [NB: , ]
"ott" . , :
var ay = ["ay", "eigh", "ei"];
var eye = ["y", "eye", "aye", "ye"];
var ah = ["a", "ah", "aw"];
var ot = ["ot", "ott", "ought", "aught"];
, ? , ?