From 5f0d1fa35b4fa97586e0392f6645d3474c2789fe Mon Sep 17 00:00:00 2001 From: Daniel Hershcovich Date: Tue, 28 Jul 2015 14:08:28 +0300 Subject: [PATCH] Fix indentation and trailing whitespace --- parser/lstm-parse.cc | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/parser/lstm-parse.cc b/parser/lstm-parse.cc index 1431599..a7f44e7 100644 --- a/parser/lstm-parse.cc +++ b/parser/lstm-parse.cc @@ -856,19 +856,19 @@ unsigned compute_correct(const map& ref, const map& hyp, unsig } void output_conll(const vector& sentence, const vector& pos, - const vector& sentenceUnkStrings, - const map& intToWords, - const map& intToPos, + const vector& sentenceUnkStrings, + const map& intToWords, + const map& intToPos, const map& hyp, const map& rel_hyp) { for (unsigned i = 0; i < (sentence.size()-1); ++i) { auto index = i + 1; - assert(i < sentenceUnkStrings.size() && + assert(i < sentenceUnkStrings.size() && ((sentence[i] == corpus.get_or_add_word(cpyp::Corpus::UNK) && sentenceUnkStrings[i].size() > 0) || (sentence[i] != corpus.get_or_add_word(cpyp::Corpus::UNK) && sentenceUnkStrings[i].size() == 0 && intToWords.find(sentence[i]) != intToWords.end()))); - string wit = (sentenceUnkStrings[i].size() > 0)? + string wit = (sentenceUnkStrings[i].size() > 0)? sentenceUnkStrings[i] : intToWords.find(sentence[i])->second; auto pit = intToPos.find(pos[i]); assert(hyp.find(i) != hyp.end()); @@ -880,10 +880,10 @@ void output_conll(const vector& sentence, const vector& pos, size_t first_char_in_rel = hyp_rel.find('(') + 1; size_t last_char_in_rel = hyp_rel.rfind(')') - 1; hyp_rel = hyp_rel.substr(first_char_in_rel, last_char_in_rel - first_char_in_rel + 1); - cout << index << '\t' // 1. ID + cout << index << '\t' // 1. ID << wit << '\t' // 2. FORM - << "_" << '\t' // 3. LEMMA - << "_" << '\t' // 4. CPOSTAG + << "_" << '\t' // 3. LEMMA + << "_" << '\t' // 4. CPOSTAG << pit->second << '\t' // 5. POSTAG << "_" << '\t' // 6. FEATS << hyp_head << '\t' // 7. HEAD @@ -913,7 +913,7 @@ void init_pretrained(istream &in) { int main(int argc, char** argv) { cnn::Initialize(argc, argv); - cerr << "COMMAND:"; + cerr << "COMMAND:"; for (unsigned i = 0; i < static_cast(argc); ++i) cerr << ' ' << argv[i]; cerr << endl; unsigned status_every_i_iterations = 100; @@ -1048,8 +1048,8 @@ int main(int argc, char** argv) { for (auto& w : tsentence) if (singletons.count(w) && cnn::rand01() < unk_prob) w = kUNK; } - const vector& sentencePos=corpus.sentencesPos[order[si]]; - const vector& actions=corpus.correct_act_sent[order[si]]; + const vector& sentencePos=corpus.sentencesPos[order[si]]; + const vector& actions=corpus.correct_act_sent[order[si]]; ComputationGraph hg; parser.log_prob_parser(&hg,sentence,tsentence,sentencePos,actions,corpus.actions,corpus.intToWords,&right); double lp = as_scalar(hg.incremental_forward()); @@ -1080,8 +1080,8 @@ int main(int argc, char** argv) { auto t_start = std::chrono::high_resolution_clock::now(); for (unsigned sii = 0; sii < dev_size; ++sii) { const vector& sentence=corpus.sentencesDev[sii]; - const vector& sentencePos=corpus.sentencesPosDev[sii]; - const vector& actions=corpus.correct_act_sentDev[sii]; + const vector& sentencePos=corpus.sentencesPosDev[sii]; + const vector& actions=corpus.correct_act_sentDev[sii]; vector tsentence=sentence; if (!USE_SPELLING) { for (auto& w : tsentence) @@ -1089,8 +1089,8 @@ int main(int argc, char** argv) { } ComputationGraph hg; - vector pred = parser.log_prob_parser(&hg,sentence,tsentence,sentencePos,vector(),corpus.actions,corpus.intToWords,&right); - double lp = 0; + vector pred = parser.log_prob_parser(&hg,sentence,tsentence,sentencePos,vector(),corpus.actions,corpus.intToWords,&right); + double lp = 0; //vector pred = parser.log_prob_parser_beam(&hg,sentence,sentencePos,corpus.actions,beam_size,&lp); llh -= lp; trs += actions.size(); @@ -1111,9 +1111,9 @@ int main(int argc, char** argv) { // easier to refer to it in a shell script. if (!softlinkCreated) { string softlink = " latest_model"; - if (system((string("rm -f ") + softlink).c_str()) == 0 && + if (system((string("rm -f ") + softlink).c_str()) == 0 && system((string("ln -s ") + fname + softlink).c_str()) == 0) { - cerr << "Created " << softlink << " as a soft link to " << fname + cerr << "Created " << softlink << " as a soft link to " << fname << " for convenience." << endl; } softlinkCreated = true; @@ -1132,8 +1132,8 @@ int main(int argc, char** argv) { unsigned corpus_size = corpus.nsentencesDev; for (unsigned sii = 0; sii < corpus_size; ++sii) { const vector& sentence=corpus.sentencesDev[sii]; - const vector& sentencePos=corpus.sentencesPosDev[sii]; - const vector& sentenceUnkStr=corpus.sentencesStrDev[sii]; + const vector& sentencePos=corpus.sentencesPosDev[sii]; + const vector& sentenceUnkStr=corpus.sentencesStrDev[sii]; const vector& actions=corpus.correct_act_sentDev[sii]; vector tsentence=sentence; if (!USE_SPELLING) {