commit 8c750990fe1e41b2e8c51236a90321648ff5e3ea Author: Tanmai Khanna Date: Tue May 19 19:20:51 2020 +0530 Clean code | regression tests done diff --git a/apertium/transfer.cc b/apertium/transfer.cc index 3aa6b76..eca0389 100644 --- a/apertium/transfer.cc +++ b/apertium/transfer.cc @@ -316,7 +316,6 @@ Transfer::evalString(xmlNode *element) if(in_lu) { secondary_tags.append(word[ti.getPos()]->source(attr_items["sectags"], ti.getCondition())); -// wcout << "\n###EVALSLSTAGS::" << secondary_tags << "::\n"; } else if(in_let_var) { @@ -330,7 +329,6 @@ Transfer::evalString(xmlNode *element) } else if(ti.getContent().compare("lemq") == 0) { - // cout << "\nLEMQ!\n"; if(in_lu) { string sectags_lemq = secondary_tags; @@ -354,16 +352,9 @@ Transfer::evalString(xmlNode *element) { if(gettingLemmaFromWord(ti.getContent())) { - // cout << "\nLEM or LEMH\n"; - // if(in_lu) - // cout <<"\nINLU!\n"; - // else - // cout <<"\nNOTINLU!\n"; - if(in_lu) { secondary_tags.append(word[ti.getPos()]->target(attr_items["sectags"], ti.getCondition())); - //wcout << "\n###:: "<< word[ti.getPos()]->target(attr_items[ti.getContent()], ti.getCondition()) << "EVALTLSTAGS::" << secondary_tags << "::\n"; } else if(in_let_var) { @@ -378,7 +369,6 @@ Transfer::evalString(xmlNode *element) } else if(ti.getContent().compare("lemq") == 0) { - //cout << "\nLEMQ!\n"; if(in_lu) { string sectags_lemq = secondary_tags; @@ -447,7 +437,7 @@ Transfer::evalString(xmlNode *element) break; case ti_var: - secondary_tags.append(var_secondary_tags[ti.getContent()]); //append secondary tags of this variable into secondary_tags + secondary_tags.append(var_secondary_tags[ti.getContent()]); if(var_has_lemq[ti.getContent()] && !secondary_tags.empty()) { @@ -470,8 +460,6 @@ Transfer::evalString(xmlNode *element) var_content_with_sectags = var_content.substr(0,lemq_position).append(secondary_tags).append(var_content.substr(lemq_position, string::npos)); - //cout << "\n###VARSTAGS::" << var_content_with_sectags << "::####\n"; - secondary_tags.clear(); return var_content_with_sectags; @@ -691,9 +679,8 @@ Transfer::evalString(xmlNode *element) } in_lu = false; - myword.append(secondary_tags); //from the LU that the lem or lemh has come from - secondary_tags is added in evalString + myword.append(secondary_tags); - //wcout << "\n###EVALSTRINGMYWORD::" << myword << "::###\n"; if(myword != "") { return "^"+myword+"$"; @@ -727,8 +714,7 @@ Transfer::evalString(xmlNode *element) } in_lu = false; - myword.append(secondary_tags); //from the LU that the lem or lemh has come from - //wcout << "\n###EVALMLUMYWORD::" << myword << "::###\n"; + myword.append(secondary_tags); if(!first_time) { @@ -796,8 +782,7 @@ Transfer::processOut(xmlNode *localroot) in_lu = false; - myword.append(secondary_tags); //from the LU that the lem or lemh has come from - secondary_tags is added in evalString - //wcout << "\n###OUTMYWORD::" << myword << "::###\n"; + myword.append(secondary_tags); if(myword != "") { fputwc_unlocked(L'^', output); @@ -826,7 +811,7 @@ Transfer::processOut(xmlNode *localroot) } in_lu = false; - myword.append(secondary_tags); //from the LU that the lem or lemh has come from + myword.append(secondary_tags); if(!first_time) { @@ -842,7 +827,7 @@ Transfer::processOut(xmlNode *localroot) first_time = false; } } -// wcout << "\n###OUTMLUMYWORD::" << myword << "::###\n"; + fputws_unlocked(UtfConverter::fromUtf8(myword).c_str(), output); } } @@ -946,12 +931,11 @@ Transfer::processChunk(xmlNode *localroot) if(j->type == XML_ELEMENT_NODE) { myword.append(evalString(j)); - // wcout << "\n###CHUNKMYWORD::" << myword << "::###" << secondary_tags << "::\n"; } } in_lu = false; - myword.append(secondary_tags); //from the LU that the lem or lemh has come from - secondary_tags is added in evalString + myword.append(secondary_tags); if(myword != "") { @@ -977,12 +961,11 @@ Transfer::processChunk(xmlNode *localroot) if(k->type == XML_ELEMENT_NODE) { mylocalword.append(evalString(k)); - // wcout << "\n###CHUNKMLUMLOCALYWORD::" << mylocalword << "::###\n"; } } in_lu = false; - mylocalword.append(secondary_tags); //from the LU that the lem or lemh has come from + mylocalword.append(secondary_tags); if(!first_time) { @@ -1124,7 +1107,7 @@ Transfer::processLet(xmlNode *localroot) { case ti_var: in_let_var = true; - var_val = ti.getContent(); //current variable name - need it in evalString + var_val = ti.getContent(); var_secondary_tags[var_val].clear(); var_has_lemq[var_val] = false; @@ -1175,7 +1158,7 @@ Transfer::processLet(xmlNode *localroot) string const val = (const char *) leftSide->properties->children->content; - var_val = val; //current variable name - need it in evalString + var_val = val; var_secondary_tags[var_val].clear(); var_has_lemq[var_val] = false; diff --git a/apertium/transfer.h b/apertium/transfer.h index 1d64d68..79ae6fd 100644 --- a/apertium/transfer.h +++ b/apertium/transfer.h @@ -68,7 +68,7 @@ private: bool in_let_var; //flag to denote that a var in let is being processed (or in append) string var_val; //stores the name of the variable being processed (in let or append) map var_secondary_tags; //map variable name to secondary tags of the word it takes lem/lemh from - map var_has_lemq; + map var_has_lemq; //map variable name to bool->true if variable clips lemq bool gettingLemmaFromWord(string attr);