Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/nouncer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions src/nouncer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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) {
Expand Down