diff options
-rw-r--r-- | lib/word.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/word.cpp b/lib/word.cpp index 156e7e0..15af150 100644 --- a/lib/word.cpp +++ b/lib/word.cpp | |||
@@ -32,9 +32,17 @@ namespace verbly { | |||
32 | 32 | ||
33 | bool word::starts_with_vowel_sound() const | 33 | bool word::starts_with_vowel_sound() const |
34 | { | 34 | { |
35 | return std::any_of(std::begin(pronunciations), std::end(pronunciations), [] (std::list<std::string> phonemes) { | 35 | if (pronunciations.size() > 0) |
36 | return (phonemes.front().find_first_of("012") != std::string::npos); | 36 | { |
37 | }); | 37 | return std::any_of(std::begin(pronunciations), std::end(pronunciations), [] (std::list<std::string> phonemes) { |
38 | return (phonemes.front().find_first_of("012") != std::string::npos); | ||
39 | }); | ||
40 | } else { | ||
41 | // If the word is not in CMUDICT, fall back to checking whether the first letter is a vowel | ||
42 | // Not perfect but will work in most cases | ||
43 | char ch = tolower(base_form().front()); | ||
44 | return (ch == 'a') || (ch == 'e') || (ch == 'i') || (ch == 'o') || (ch == 'u'); | ||
45 | } | ||
38 | } | 46 | } |
39 | 47 | ||
40 | }; | 48 | }; |