辅导案例-CS4411

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
CS4411 Programming Languages

Sabah Mohammed, PhD, MBCS, ISP, IEEE Senior Member, PEng
Full Professor
Department of Computer Science
Lakehead University
Exercise No. 2: Sound Coding in Clojure (5 Marks)
Sound coding is an algorithm for creating indices for words based on their pronunciation.
The goal is for homophones to be encoded to the same representation so that they can be
matched despite minor differences in spelling. From an english word, you generate a letter
and three numbers that roughly describe how an given word sounds. Similar sounding
words will have similar codes. The first letter of the sound code is simply the first letter in
the word. The remaining numbers range from 1 to 6, indicating different categories of
sounds created by consanants following the first letter. If the word is too short to generate
3 numbers, 0 is added as needed. If the generated code is longer than 3 numbers, the extra
are thrown away.
Code Letters Description
1 B, F, P, V Labial
2 C, G, J, K, Q, S, X, Z Gutterals and sibilants
3 D, T Dental
4 L Long liquid
5 M, N Nasal
6 R Short liquid
SKIP A, E, H, I, O, U, W, Y Vowels (and H, W, and Y) are skipped
There are several special cases when calculating a sound code:
 Letters with the same sound number that are immediately next to each other are
discarded. So Pfizer becomes Pizer, Sack becomes Sac, Czar becomes Car, Collins
becomes Colins, and Mroczak becomes Mrocak.
 If two letters with the same sound number separated by "H" or "W", only use the
first letter. So Ashcroft is treated as Ashroft.
Sample Sound Codes
Word Sound Code
Washington W252
Wu W000
DeSmet D253
Gutierrez G362
Pfister P236
Jackson J250
Tymczak T522
Ashcraft A261

In clojure there is a library API (clj-fuzzy) that compute the sound code for you automatically:



But I do not want you to use it. You need to develop your own clojure method to implement the sound
coding according to the above algorithm and similar to the clj-fuzzy API.

Project Requirements:
(1) You may use any clojure utility like clojure.contrib.str-utils in your program.
(2) You must not use any solution that you might find it from other sources (e.g. Web).
(3) Better marks will be given to a simple solution that implements the above algorithm in a
transparent way.
(4) Your solution need to be deploying it to the D2L (Zip file containing the source CLJ file + CLJ
Project + ReadMe.doc explaining with screenshots the puzzle and the way you have solve it).




欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468