From 75e947fa0021547f460496d1c3aef5b61af4c669 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 31 Mar 2018 23:05:02 -0400 Subject: Migrated generator to hkutil --- generator/pronunciation.cpp | 55 +++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 19 deletions(-) (limited to 'generator/pronunciation.cpp') diff --git a/generator/pronunciation.cpp b/generator/pronunciation.cpp index eb07607..3075d42 100644 --- a/generator/pronunciation.cpp +++ b/generator/pronunciation.cpp @@ -3,9 +3,7 @@ #include #include #include -#include "database.h" -#include "field.h" -#include "../lib/util.h" +#include namespace verbly { namespace generator { @@ -16,28 +14,45 @@ namespace verbly { id_(nextId_++), phonemes_(phonemes) { - auto phonemeList = split>(phonemes, " "); - - auto rhymeStart = std::find_if(std::begin(phonemeList), std::end(phonemeList), [] (std::string phoneme) { - return phoneme.find("1") != std::string::npos; - }); + auto phonemeList = + hatkirby::split>(phonemes, " "); + + std::list::iterator rhymeStart = + std::find_if( + std::begin(phonemeList), + std::end(phonemeList), + [] (std::string phoneme) { + return phoneme.find("1") != std::string::npos; + }); // Rhyme detection if (rhymeStart != std::end(phonemeList)) { std::list rhymePhonemes; - std::transform(rhymeStart, std::end(phonemeList), std::back_inserter(rhymePhonemes), [] (std::string phoneme) { - std::string naked; - - std::remove_copy_if(std::begin(phoneme), std::end(phoneme), std::back_inserter(naked), [] (char ch) { - return std::isdigit(ch); + std::transform( + rhymeStart, + std::end(phonemeList), + std::back_inserter(rhymePhonemes), + [] (std::string phoneme) { + std::string naked; + + std::remove_copy_if( + std::begin(phoneme), + std::end(phoneme), + std::back_inserter(naked), + [] (char ch) { + return std::isdigit(ch); + }); + + return naked; }); - return naked; - }); - - rhyme_ = implode(std::begin(rhymePhonemes), std::end(rhymePhonemes), " "); + rhyme_ = + hatkirby::implode( + std::begin(rhymePhonemes), + std::end(rhymePhonemes), + " "); if (rhymeStart != std::begin(phonemeList)) { @@ -63,9 +78,11 @@ namespace verbly { } } - database& operator<<(database& db, const pronunciation& arg) + hatkirby::database& operator<<( + hatkirby::database& db, + const pronunciation& arg) { - std::list fields; + std::list fields; fields.emplace_back("pronunciation_id", arg.getId()); fields.emplace_back("phonemes", arg.getPhonemes()); -- cgit 1.4.1