diff options
author | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2014-04-08 15:44:21 +0400 |
---|---|---|
committer | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2014-04-08 15:44:21 +0400 |
commit | ad678ac0ec2a3c3a315b7256ab896d246e1dc03e (patch) | |
tree | da0154fa177d3ebc05fdca5d15076d89f24bf881 /moses/WordLattice.cpp | |
parent | 43a51bb5d7d576bb6d8038032135605144025294 (diff) |
Replaced calls to String2Word by calls to Word::CreateFromString(). String2Word is deprecated (code duplication) and should be removed. Some reformatting for readability.
Diffstat (limited to 'moses/WordLattice.cpp')
-rw-r--r-- | moses/WordLattice.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/moses/WordLattice.cpp b/moses/WordLattice.cpp index 8dfc5879d..7153f2d93 100644 --- a/moses/WordLattice.cpp +++ b/moses/WordLattice.cpp @@ -49,7 +49,12 @@ void WordLattice::Print(std::ostream& out) const out<<"\n\n"; } -int WordLattice::InitializeFromPCNDataType(const PCN::CN& cn, const std::vector<FactorType>& factorOrder, const std::string& debug_line) +int +WordLattice:: +InitializeFromPCNDataType +(const PCN::CN& cn, + const std::vector<FactorType>& factorOrder, + const std::string& debug_line) { const StaticData &staticData = StaticData::Instance(); const InputFeature &inputFeature = InputFeature::Instance(); @@ -73,14 +78,20 @@ int WordLattice::InitializeFromPCNDataType(const PCN::CN& cn, const std::vector< //check for correct number of link parameters if (alt.m_denseFeatures.size() != numInputScores) { - TRACE_ERR("ERROR: need " << numInputScores << " link parameters, found " << alt.m_denseFeatures.size() << " while reading column " << i << " from " << debug_line << "\n"); + TRACE_ERR("ERROR: need " << numInputScores + << " link parameters, found " + << alt.m_denseFeatures.size() + << " while reading column " << i + << " from " << debug_line << "\n"); return false; } //check each element for bounds std::vector<float>::const_iterator probsIterator; data[i][j].second = std::vector<float>(0); - for(probsIterator = alt.m_denseFeatures.begin(); probsIterator < alt.m_denseFeatures.end(); probsIterator++) { + for(probsIterator = alt.m_denseFeatures.begin(); + probsIterator < alt.m_denseFeatures.end(); + probsIterator++) { IFVERBOSE(1) { if (*probsIterator < 0.0f) { TRACE_ERR("WARN: neg probability: " << *probsIterator << "\n"); @@ -102,7 +113,9 @@ int WordLattice::InitializeFromPCNDataType(const PCN::CN& cn, const std::vector< float value = (alt.m_word=="" || alt.m_word==EPSILON) ? 0.0f : -1.0f; data[i][j].second.denseScores.push_back(value); } - String2Word(alt.m_word, data[i][j]. first, factorOrder); + Word& w = data[i][j].first; + w.CreateFromString(Input,factorOrder,StringPiece(alt.m_word),false); + // String2Word(alt.m_word, data[i][j]. first, factorOrder); next_nodes[i][j] = alt.m_next; if(next_nodes[i][j] > maxSizePhrase) { |