-1
\$\begingroup\$

Challenge

Joe the rapper is struggling with rhyming words in his lyrics. He needs your help.

For this situation, we will use rhymes where the last syllable in a word is the same as the other word (spelled the same).

When Joe inputs a word, the program will read a list of words from a file and output those that rhyme with Joe's word.

To show that the program works, we will only need to use a small list.

txt File:

hello
joe
crew
flow
time
apple
heart
glow
rhyme
art
jello
grew
doe
flue
blow
smart
dime
cat
slime
show
bedtime
clue
grime
toe
dart
cart
brew
snow
prime
hat
chart
lime
blue
knew
lunchtime
restart

Examples

Input: snow

Output: blow flow glow show Note- Should not output the input

Input: fart

Output: restart art dart cart chart smart heart Note- Should work for inputs not in list

Input: crime

Output: time slime prime grime dime lime bedtime lunchtime Note- Should work for all syllables

Rules

  1. Should output all words that rhyme with input

    does not need to output rhymes with different letters Ex: Crime should not output rhyme

  2. Should not output the input

  3. Should work with inputs not in the list
  4. Should work will all syllables

Shortest Bytes Wins!

\$\endgroup\$

closed as unclear what you're asking by Peter Taylor, Level River St, Leaky Nun, xnor, Rɪᴋᴇʀ May 20 '16 at 13:34

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ Define "rhyme". Does "bedtime" rhyme with "clue"? \$\endgroup\$ – Leaky Nun May 20 '16 at 9:11
  • \$\begingroup\$ See comments on meta.codegolf.stackexchange.com/a/7014/194 for a suggestion as to how to make "rhyme" well-specified. \$\endgroup\$ – Peter Taylor May 20 '16 at 10:30
  • \$\begingroup\$ @Peter I think JoshK is looking for something simpler than phonetic rhyming. does not need to output rhymes with differet letters and snow --> blow flow glow show (but not toe) Anyway, Josh, a proper definition is required. Given examples follow the rule of last vowel and all consonants after it (this works for chart & heart but would fail for chat & heat.) As shown by Kenny Lau's example, matching the whole of the last vowel cluster (and any following consonants) may be better but would make heart invalid. Voting to close until resolved. (personally I'd get rid of heart) \$\endgroup\$ – Level River St May 20 '16 at 10:52
  • \$\begingroup\$ As you haven't been here that long, I'll point out that the reason for close voting is nothing personal, it's to temporarily stop the posting of answers before the rules have been fully clarified (as is happening right now.) You could try posting your next challeng in the sandbox for feedback first before posting on the main site meta.codegolf.stackexchange.com/q/2140/15599 \$\endgroup\$ – Level River St May 20 '16 at 10:57
  • \$\begingroup\$ Do though, through, and rough rhyme? \$\endgroup\$ – mbomb007 May 20 '16 at 19:12
1
\$\begingroup\$

JavaScript (ES6), 67 bytes

(a,w)=>a.filter(s=>s!=w&s.endsWith(w.replace(/.*([aeiou].)/,"$1")))

Function that accepts an array of words and an input word as parameters. Uses the definition of rhyme as the substring of the word starting at the last vowel before the last letter.

a=
(a,w)=>a.filter(s=>s!=w&s.endsWith(w.replace(/.*([aeiou].)/,"$1")))
;
u=w=>r.value=a(f.value.split`\n`,w).join`\n`
File:
<textarea rows=5 id=f>
hello
joe
crew
flow
time
apple
heart
glow
rhyme
art
jello
grew
doe
flue
blow
smart
dime
cat
slime
show
bedtime
clue
grime
toe
dart
cart
brew
snow
prime
hat
chart
lime
blue
knew
lunchtime
restart
</textarea>
<br>
Word:
<input oninput="u(this.value)">
<br>
Rhymes:
<textarea rows=5 id=r>
</textarea>

\$\endgroup\$
  • \$\begingroup\$ What is your definition of rhyme? You should state it in English (not just code) in the answer. Better still, wait for the OP to clarify the rules before posting. \$\endgroup\$ – Level River St May 20 '16 at 10:58
0
\$\begingroup\$

Ruby, 68 bytes

FGITW. Full program, takes file and word from command line: ruby script.rb words.txt "hello".

Assumes the last syllable (or rather, the section of the syllable to match against for the purposes of rhyming) is at least 2 characters long, or more if there are extra vowels before that.

f,w=$*
w=~/[aeiou]*..$/
puts open(f).map(&:chomp).grep(/#{$&}$/)-[w]
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.