Poetry Syllable Form Checker
; This project is a program that lets the user choose:
; A file containing a poem.
; A file containing:
; the name of a poetry form
; the number of syllables each line of the poetry form requires
; The program then reports whether the poem has the correct number of syllables in each line.
; For examples of a Haiku and aLimkerick look at the files a-haihu.txt and a-limerick.txt.
; For examples of poetry syllable form description look at haiku-form.txt and limerick-form.txt.
; What to do: under each heading below that starts with exactly one do the numbered steps.
; There will be 1, 2, or 3 steps listed immediately under the .
; The CMU Pronouncing Dictionary
; The pronunciation of words will be determined from the CMU Pronouncing Dictionary:
; http://www.speech.cs.cmu.edu/cgi-bin/cmudict
; The current version of the dictionary well use is:
; http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict-0.7b
; Importing the Dictionary
; 1. Save that file cmuduct-0.7b and this Racket project file in the same directory or folder
; on your computer.
; The following two lines then read in the dictionary as a list of lists of strings:
(require 2htdp/batch-io)
(define CMU (read-words/line cmudict-0.7b))
; The result is a list of lists of strings.
; CMU : list-of-list-of-strings
; For example, the element at index 10000 is the dictionary entry for the word beings:
(check-expect (list-ref CMU 10000) (list BEINGS B IY1 IH0 NG Z))
; The first element of that list is the word beings in upper-case, followed by a list of phonemes
; that represent the sounds to pronounce the word beings.
; Vowel sounds are represented by strings that end with 0, 1, or 2.
; If you are interested in the details of the sound representation take a look at the information
; on the CMU Pronouncing Dictionary Web Site.
; filter-2
; The function filter-2 will be useful for one of the functions youll write.
;
; (filter-2 p value (list a b c z))
;
; It produces the sub-list of (list a b c z) with the elements a b c z for which
; (p value a) (p value b) (p value c) (p value z) are #true.
; For example:
(check-expect (filter-2 < 100 (list 23 104 56 789 104))
; (not (< 100 23))
; (< 100 104)
; (not (< 100 56))
; (< 100 789)
; (< 100 104).
; So the result is:
(list 104 789 104))
(check-expect (filter-2 = 104 (list 23 104 56 789 104))
(list 104 104))
;
; filter-2 : binary-predicate any list -> list
(define (filter-2 binary-predicate a-value a-list)
(local [(define (unary-predicate an-element)
(binary-predicate a-value an-element))]
(filter unary-predicate a-list)))
; choose-file and message
; The GUI.rkt helper file
; 1. Save the file GUI.rkt from the course website into the same directory or folder on your
; computer where you saved the cmu dictionary and this Racket project file.
; The following expression then gives you access to the functions choose-file and message:
(require GUI.rkt)
; The choose-file and message functions are used later in this project.
; The choose-file function takes a title string, and brings up a window with that title, asking
; the user to choose a file.
;
; choose-file : string -> string
;
; The result is the name of the file as a string.
; The message function takes a title string and a contents string, and pops up a window with that
; title and the contents.
;
; message : string string -> string
; string-ci=?
; The Intermediate Student function string-ci=? [meaning string Case Insensitive equal?] will be
; useful for one of the functions youll write.
; string-ci=? : string string -> boolean
Reviews
There are no reviews yet.