Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. (define (find-rhymes/acc word1 dictionary1 rhyme-list)
  2. ;(emphasis-part (first(first dictionary1)) dictionary1)
  3. (cond
  4. [(empty? dictionary1) rhyme-list]
  5. [(and (equal? (emphasis-part word1 cmudict) (emphasis-part (first(first dictionary1)) dictionary1))
  6. (not(string=? word1 (first(first dictionary1)))))
  7. (cons (first(first dictionary1)) (find-rhymes/acc word1 (rest dictionary1) rhyme-list))]
  8. [else (find-rhymes/acc word1 (rest dictionary1) rhyme-list)]
  9. )
  10. )
  11.  
  12. (define (find-rhymes word1 dictionary1)
  13. (find-rhymes/acc word1 dictionary1 empty)
  14. )
  15.  
  16.  
  17. ;;helps determine emphasis part of word
  18. (define (emphasis-part word1 dictionary1)
  19.  
  20. (cond
  21. [(string=? word1 (first (first dictionary1)))
  22. (make-emphasis-list(first(rest(first dictionary1))))]
  23. [else (emphasis-part word1 (rest dictionary1))]
  24. )
  25. )
  26.  
  27. ;determines which part of list to cut off from to make one with highest vowel sound
  28. ;; whole pronounciation --> the entire list that was extracted
  29. ;; current-pronounciation --> new list being formed
  30. ;; highest --> highest sound pitch
  31. (define (make-emphasis-list/acc whole-prononciation current-prononciation)
  32. (cond
  33.  
  34. [(empty? whole-prononciation) current-prononciation]
  35. [(list? (first whole-prononciation))
  36. (cond [(= 1 (first(rest(first whole-prononciation))))
  37. (make-emphasis-list/acc (rest whole-prononciation) whole-prononciation)]
  38. [else (make-emphasis-list/acc (rest whole-prononciation) current-prononciation)])
  39. ]
  40. [else (make-emphasis-list/acc (rest whole-prononciation) current-prononciation)]
  41. )
  42. )
  43.  
  44. (define (make-emphasis-list whole-prononciation)
  45. (make-emphasis-list/acc whole-prononciation empty)
  46. )
  47.  
  48. (find-rhymes "ugly" toy-dictionary)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement