diff --git a/include/nouncer.h b/include/nouncer.h index 09cdc65..cb4652e 100644 --- a/include/nouncer.h +++ b/include/nouncer.h @@ -47,6 +47,9 @@ class Nouncer { private: + //pronounces words not known to CMU Pronouncing Dictionary + std::string soundItOut(std::string word); + //check whether a phone is a vowel or consonant static bool isVowel(char& phone); 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 018f13f..caba564 100644 --- a/src/nouncer.cpp +++ b/src/nouncer.cpp @@ -52,10 +52,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 < word.length(); i++); + + return pronunciation; +} + /* * TODO: Let's encode outside this and pass in the nounce * @@ -197,7 +207,6 @@ int Nouncer::getSize() { return dict->size(); } - void Nouncer::print(std::string filename) { std::ofstream of(filename); for (auto it = dict->begin(); it!=dict->end(); ++it) {