diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2012-12-06 00:21:33 +0400 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2012-12-06 00:21:33 +0400 |
commit | da9cd0e3aadc5154d262f8c37697b1c429280594 (patch) | |
tree | ea2d91a5074aeb472d0a315ca2246e40e544b8c6 /moses/ConfusionNet.cpp | |
parent | b8d4c64d6d8c3b1045d3d91772422d8ee4e5826e (diff) |
clean up weights code for confusion networks & lattices. Works, except for multiple phrase-tables or factors
Diffstat (limited to 'moses/ConfusionNet.cpp')
-rw-r--r-- | moses/ConfusionNet.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/moses/ConfusionNet.cpp b/moses/ConfusionNet.cpp index c8d3dd3bf..fd31e2766 100644 --- a/moses/ConfusionNet.cpp +++ b/moses/ConfusionNet.cpp @@ -118,11 +118,12 @@ bool ConfusionNet::ReadFormat0(std::istream& in, const std::vector<FactorType>& factorOrder) { Clear(); - std::string line; - size_t numLinkParams = StaticData::Instance().GetNumLinkParams(); - size_t numLinkWeights = StaticData::Instance().GetNumInputScores(); - bool addRealWordCount = ((numLinkParams + 1) == numLinkWeights); + size_t numInputScores = StaticData::Instance().GetNumInputScores(); + size_t numRealWordCount = StaticData::Instance().GetNumRealWordsInInput(); + size_t totalCount = numInputScores + numRealWordCount; + bool addRealWordCount = (numRealWordCount > 0); + std::string line; while(getline(in,line)) { std::istringstream is(line); std::string word; @@ -131,8 +132,8 @@ bool ConfusionNet::ReadFormat0(std::istream& in, while(is>>word) { Word w; String2Word(word,w,factorOrder); - std::vector<float> probs(numLinkWeights,0.0); - for(size_t i=0; i<numLinkParams; i++) { + std::vector<float> probs(totalCount, 0.0); + for(size_t i=0; i < numInputScores; i++) { double prob; if (!(is>>prob)) { TRACE_ERR("ERROR: unable to parse CN input - bad link probability, or wrong number of scores\n"); @@ -150,7 +151,7 @@ bool ConfusionNet::ReadFormat0(std::istream& in, } //store 'real' word count in last feature if we have one more weight than we do arc scores and not epsilon if (addRealWordCount && word!=EPSILON && word!="") - probs[numLinkParams] = -1.0; + probs.back() = -1.0; col.push_back(std::make_pair(w,probs)); } if(col.size()) { |