summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2016-03-20 18:19:05 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2016-03-20 18:19:05 -0400
commitd5ee4e39e5b5b3b8daa85cd972802195ad35e965 (patch)
treec1c6d3776fd1628f8e5bc4c5baf15071978f1fa7 /lib
parentb7a453a8246a76293b296dadf305217a70b0ac1a (diff)
downloadverbly-d5ee4e39e5b5b3b8daa85cd972802195ad35e965.tar.gz
verbly-d5ee4e39e5b5b3b8daa85cd972802195ad35e965.tar.bz2
verbly-d5ee4e39e5b5b3b8daa85cd972802195ad35e965.zip
Added fallback to vowel sound detection when no entry exists in CMUDICT
Diffstat (limited to 'lib')
-rw-r--r--lib/word.cpp14
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};