From 04338f2b040fee5142904c062e0e38c836601034 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 17 Apr 2016 13:44:37 -0400 Subject: Fixed perfect rhyming Rhyme detection now ensures that any rhymes it finds are perfect rhymes and not identical rhymes. Rhyme detection is also now a lot faster because additional information is stored in the datafile. Also fixed a bug in the query interface (and the generator) that could cause incorrect queries to be executed. --- lib/word.cpp | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'lib/word.cpp') 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 @@ namespace verbly { + rhyme::rhyme(std::string prerhyme, std::string phonemes) : _prerhyme(prerhyme), _rhyme(phonemes) + { + + } + + std::string rhyme::get_prerhyme() const + { + return _prerhyme; + } + + std::string rhyme::get_rhyme() const + { + return _rhyme; + } + + bool rhyme::operator==(const rhyme& other) const + { + return std::tie(_prerhyme, _rhyme) == std::tie(other._prerhyme, other._rhyme); + } + word::word() { @@ -13,28 +33,11 @@ namespace verbly { } - std::list word::rhyme_phonemes() const + std::list word::get_rhymes() const { assert(_valid == true); - std::list result; - - for (auto pronunciation : pronunciations) - { - auto phemstrt = std::find_if(std::begin(pronunciation), std::end(pronunciation), [] (std::string phoneme) { - return phoneme.find("1") != std::string::npos; - }); - - std::stringstream rhymer; - for (auto it = phemstrt; it != std::end(pronunciation); it++) - { - rhymer << " " << *it; - } - - result.push_back(rhymer.str()); - } - - return result; + return rhymes; } bool word::starts_with_vowel_sound() const -- cgit 1.4.1