Skip to content

Commit

Permalink
Fix indentation and trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhers committed Sep 18, 2016
1 parent 25cf91b commit 5f0d1fa
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions parser/lstm-parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -856,19 +856,19 @@ unsigned compute_correct(const map<int,int>& ref, const map<int,int>& hyp, unsig
}

void output_conll(const vector<unsigned>& sentence, const vector<unsigned>& pos,
const vector<string>& sentenceUnkStrings,
const map<unsigned, string>& intToWords,
const map<unsigned, string>& intToPos,
const vector<string>& sentenceUnkStrings,
const map<unsigned, string>& intToWords,
const map<unsigned, string>& intToPos,
const map<int,int>& hyp, const map<int,string>& 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());
Expand All @@ -880,10 +880,10 @@ void output_conll(const vector<unsigned>& sentence, const vector<unsigned>& 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
Expand Down Expand Up @@ -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<unsigned>(argc); ++i) cerr << ' ' << argv[i];
cerr << endl;
unsigned status_every_i_iterations = 100;
Expand Down Expand Up @@ -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<unsigned>& sentencePos=corpus.sentencesPos[order[si]];
const vector<unsigned>& actions=corpus.correct_act_sent[order[si]];
const vector<unsigned>& sentencePos=corpus.sentencesPos[order[si]];
const vector<unsigned>& 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());
Expand Down Expand Up @@ -1080,17 +1080,17 @@ 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<unsigned>& sentence=corpus.sentencesDev[sii];
const vector<unsigned>& sentencePos=corpus.sentencesPosDev[sii];
const vector<unsigned>& actions=corpus.correct_act_sentDev[sii];
const vector<unsigned>& sentencePos=corpus.sentencesPosDev[sii];
const vector<unsigned>& actions=corpus.correct_act_sentDev[sii];
vector<unsigned> tsentence=sentence;
if (!USE_SPELLING) {
for (auto& w : tsentence)
if (training_vocab.count(w) == 0) w = kUNK;
}

ComputationGraph hg;
vector<unsigned> pred = parser.log_prob_parser(&hg,sentence,tsentence,sentencePos,vector<unsigned>(),corpus.actions,corpus.intToWords,&right);
double lp = 0;
vector<unsigned> pred = parser.log_prob_parser(&hg,sentence,tsentence,sentencePos,vector<unsigned>(),corpus.actions,corpus.intToWords,&right);
double lp = 0;
//vector<unsigned> pred = parser.log_prob_parser_beam(&hg,sentence,sentencePos,corpus.actions,beam_size,&lp);
llh -= lp;
trs += actions.size();
Expand All @@ -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;
Expand All @@ -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<unsigned>& sentence=corpus.sentencesDev[sii];
const vector<unsigned>& sentencePos=corpus.sentencesPosDev[sii];
const vector<string>& sentenceUnkStr=corpus.sentencesStrDev[sii];
const vector<unsigned>& sentencePos=corpus.sentencesPosDev[sii];
const vector<string>& sentenceUnkStr=corpus.sentencesStrDev[sii];
const vector<unsigned>& actions=corpus.correct_act_sentDev[sii];
vector<unsigned> tsentence=sentence;
if (!USE_SPELLING) {
Expand Down

0 comments on commit 5f0d1fa

Please sign in to comment.