From 4a49aa368ae0c273954e0d98ca28fcc2500ac11a Mon Sep 17 00:00:00 2001 From: Cameron Matson Date: Thu, 8 Dec 2016 22:15:31 -0600 Subject: [PATCH 1/2] change lookup --- include/nouncer.h | 3 +++ src/main.cpp | 5 ++++- src/nouncer.cpp | 12 +++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/nouncer.h b/include/nouncer.h index 2994fc6..df88778 100644 --- a/include/nouncer.h +++ b/include/nouncer.h @@ -42,6 +42,9 @@ class Nouncer { void print(std::string filename); private: + //pronounces words not known to CMU Pronouncing Dictionary + std::string soundItOut(std::string word); + std::map* dict; }; diff --git a/src/main.cpp b/src/main.cpp index 7e556d9..9c7ce85 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ void parseFile(std::string filename, Model* model, Nouncer* nouncer, Denouncer* void parseLine(std::string in, Model* model, Nouncer* nouncer, Denouncer* denouncer); int main(int argc, char *argv[]) { - std::string file = TRAP_FILE; + std::string file = TEST_FILE; // check for test flag if (argc > 1) { @@ -46,10 +46,13 @@ int main(int argc, char *argv[]) { parseFile(file, model, nouncer, denouncer); + denouncer->print("data/denounce.txt"); + std::string bar; std::cout << "Gimme a bar" << std::endl; std::getline(std::cin, bar); + rap(bar, model, nouncer, denouncer); delete model; diff --git a/src/nouncer.cpp b/src/nouncer.cpp index 6f81191..9687439 100644 --- a/src/nouncer.cpp +++ b/src/nouncer.cpp @@ -46,10 +46,20 @@ std::string* Nouncer::lookUp(std::string word) { return &(dict->at(Utils::allCaps(word))); } catch (const std::out_of_range& oor) { - return &(dict->at("GRAVY")); + std::string pronunciation = soundItOut(word); + addWord(pronunciation); + return &(dict->at(Utils::allCaps(word))); } } +std::string Nouncer::soundItOut(std::string word) { + std::string pronunciation = Utils::allCaps(word); + + for (int i = 0; i < string.length(); i++); + + return pronunciation; +} + /* * TODO: Let's encode outside this and pass in the nounce * From fb77ace6c2d09af9326c41fc53030339deca151a Mon Sep 17 00:00:00 2001 From: Cameron Matson Date: Thu, 8 Dec 2016 22:53:53 -0600 Subject: [PATCH 2/2] fix variable error --- src/nouncer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nouncer.cpp b/src/nouncer.cpp index 4d88eaf..caba564 100644 --- a/src/nouncer.cpp +++ b/src/nouncer.cpp @@ -61,7 +61,7 @@ std::string* Nouncer::lookUp(std::string word) { std::string Nouncer::soundItOut(std::string word) { std::string pronunciation = Utils::allCaps(word); - for (int i = 0; i < string.length(); i++); + for (int i = 0; i < word.length(); i++); return pronunciation; }