diff options
Diffstat (limited to 'lib/word.cpp')
-rw-r--r-- | lib/word.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/lib/word.cpp b/lib/word.cpp index 13c611f..49e34a1 100644 --- a/lib/word.cpp +++ b/lib/word.cpp | |||
@@ -3,6 +3,26 @@ | |||
3 | 3 | ||
4 | namespace verbly { | 4 | namespace verbly { |
5 | 5 | ||
6 | rhyme::rhyme(std::string prerhyme, std::string phonemes) : _prerhyme(prerhyme), _rhyme(phonemes) | ||
7 | { | ||
8 | |||
9 | } | ||
10 | |||
11 | std::string rhyme::get_prerhyme() const | ||
12 | { | ||
13 | return _prerhyme; | ||
14 | } | ||
15 | |||
16 | std::string rhyme::get_rhyme() const | ||
17 | { | ||
18 | return _rhyme; | ||
19 | } | ||
20 | |||
21 | bool rhyme::operator==(const rhyme& other) const | ||
22 | { | ||
23 | return std::tie(_prerhyme, _rhyme) == std::tie(other._prerhyme, other._rhyme); | ||
24 | } | ||
25 | |||
6 | word::word() | 26 | word::word() |
7 | { | 27 | { |
8 | 28 | ||
@@ -13,28 +33,11 @@ namespace verbly { | |||
13 | 33 | ||
14 | } | 34 | } |
15 | 35 | ||
16 | std::list<std::string> word::rhyme_phonemes() const | 36 | std::list<rhyme> word::get_rhymes() const |
17 | { | 37 | { |
18 | assert(_valid == true); | 38 | assert(_valid == true); |
19 | 39 | ||
20 | std::list<std::string> result; | 40 | return rhymes; |
21 | |||
22 | for (auto pronunciation : pronunciations) | ||
23 | { | ||
24 | auto phemstrt = std::find_if(std::begin(pronunciation), std::end(pronunciation), [] (std::string phoneme) { | ||
25 | return phoneme.find("1") != std::string::npos; | ||
26 | }); | ||
27 | |||
28 | std::stringstream rhymer; | ||
29 | for (auto it = phemstrt; it != std::end(pronunciation); it++) | ||
30 | { | ||
31 | rhymer << " " << *it; | ||
32 | } | ||
33 | |||
34 | result.push_back(rhymer.str()); | ||
35 | } | ||
36 | |||
37 | return result; | ||
38 | } | 41 | } |
39 | 42 | ||
40 | bool word::starts_with_vowel_sound() const | 43 | bool word::starts_with_vowel_sound() const |