Sunday, September 30, 2012

Kata Diphthong and Hiatus

Advice for all Katas: 

  • Try not to read ahead.
  • Do one task at a time (the trick is to learn to work incrementally).
  • Always use TDD if the Kata is suitable for.

Diphthong and Hiatus

For this Kata try different approaches:  regular expressions, word position traversing, brute force (dictionaries and alike), etc.

Base data and Definitions

Please note that all rules and definitions conform to the Spanish language's rules for Diphthongs and Hiatuses.

This is the classification of vowels in Spanish:
  • Strong (open): a, e, o
  • Weak (close): i, u
The following files contain a listing of words containing different types of Diphthongs and Hiatuses:
The above files will be referred from DF-1 to DF-4 (Data File One to Data File Four).


A Diphthong: Refers to two adjacent vowel sounds occurring within the same syllable. 
E1: Create a DiphthongFinder class with a method boolean analyseWord(string word); use the DF-1 to test your code. If you pass the word "caotico" and "aurora" it must output true.

Diphthong classes: 
  • Two different vowels of the same type (refer to this type as homogeneous)
  • One weak (close) vowel and one open (strong) vowel (refer to this type as heterogeneous)
    • Falling: Strong first Weak second
    • Raising: Weak first Strong second
E2: Modify your code to distinguish between Homogeneous and Heterogeneous diphthongs; extract words from DF-1, DF-2, and DF-3 to conform your test cases. If you pass the words "triunfo" and "coagular" it must output Homogeneous. If you pass the word "hielo"  it must output Heterogeneous.
E3: Modify your code to distinguish between Heterogeneous diphthongs (Falling and Raising); extract words from DF-1DF-2, and DF-3 to conform your test cases. If you pass the word "harapiento" it must output Raising. If you pass the word "país" it must output Falling.

Extended Definition and the Acute Accent ( ´ )

A Diphthong: Refers to two adjacent vowel sounds occurring within the same syllable, one vowel must be weak (close), no matter their order; if and only if, the weak (close) does not have the acute accent ( ´ ). 

An Homogeneous Diphthong must be composed only of weak (close) vowels.
E4: Now the DiphthongFinder.analyseWord(string word) must indicate that the word "caotico" is not a Diphthong (because 'a' and 'o' are both Strong or Open).  The word "aurora" is a truly Diphthong but not and Homogeneous one. The word "triunfo" is an Homogeneous Diphthong because it has two weak vowels. 
E5: Now if you pass the word "país" instead of returning Falling, it must indicates that this word is not a Diphthong because the weak vowel (i) has the acute (í), becoming a strong one; so we have two strong vowels.
Hiatus: Any word containing two consecutive vowels, but that can't be considered a Diphthong is an Hiatus. In other words: any word with two consecutive strong vowels, or an strong vowel with a weak one with an acute accent is an Hiatus. According to the RAE (Real Academia Española), two adjacent strong vowels do not conform a Diphthong as they are part of two different syllable.
E6: Extend your code to also identify Hiatuses. Pick words from DF-4 to add more tests.


Do you want some more?
Consider the following observations, later change your code to support the new specifications:
  • As the "h" in-between vowels does not produce sound, it does not block Diphthongs formation. The word "ahilar" is an example.
  • In Spanish, the "y" at the end of a word has the same sound as the "i", so it can conform Diphthongs. The words "hoy" and "muy" are two examples. However  the "y" at the beginning or middle of a word remains as a consonant and can't conform a Diphthong.
  • An Hiatus Simple is one formed of two different strong vowels.
  • An Accentual Hiatus is one formed of one strong vowel and one weak, but accented, one.

No comments:

Post a Comment

enter your comments here...

Subscribe to our mailing list

* indicates required
Email Format