Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2015-10-03 14:17:02 +0300
committerHieu Hoang <hieuhoang@gmail.com>2015-10-16 22:03:22 +0300
commit73217dd0087c06d226b08f7da59e89221ea473bc (patch)
treef295aa9dbc4d085b718791bfdd50e6dcd8d15bac
parentdd2bf5d9f3c8430eaaf3c2e9b730b93d43022786 (diff)
use util::StringStream
-rw-r--r--moses/ChartHypothesisCollection.cpp14
-rw-r--r--moses/FF/SparseHieroReorderingFeature.cpp3
-rw-r--r--moses/FF/TargetNgramFeature.cpp10
-rw-r--r--moses/FF/WordTranslationFeature.cpp16
-rw-r--r--moses/Manager.cpp3
-rw-r--r--moses/Word.cpp4
6 files changed, 19 insertions, 31 deletions
diff --git a/moses/ChartHypothesisCollection.cpp b/moses/ChartHypothesisCollection.cpp
index 42717c261..745f6f4d2 100644
--- a/moses/ChartHypothesisCollection.cpp
+++ b/moses/ChartHypothesisCollection.cpp
@@ -167,20 +167,6 @@ void ChartHypothesisCollection::Detach(const HCType::iterator &iter)
void ChartHypothesisCollection::Remove(const HCType::iterator &iter)
{
ChartHypothesis *h = *iter;
-
- /*
- stringstream strme("");
- strme << h->GetOutputPhrase();
- string toFind = "the goal of gene scientists is ";
- size_t pos = toFind.find(strme.str());
-
- if (pos == 0)
- {
- cerr << pos << " " << strme.str() << *h << endl;
- cerr << *this << endl;
- }
- */
-
Detach(iter);
ChartHypothesis::Delete(h);
}
diff --git a/moses/FF/SparseHieroReorderingFeature.cpp b/moses/FF/SparseHieroReorderingFeature.cpp
index ee9d4b719..a6d3cea8e 100644
--- a/moses/FF/SparseHieroReorderingFeature.cpp
+++ b/moses/FF/SparseHieroReorderingFeature.cpp
@@ -6,6 +6,7 @@
#include "moses/Sentence.h"
#include "util/exception.hh"
+#include "util/string_stream.hh"
#include "SparseHieroReorderingFeature.h"
@@ -202,7 +203,7 @@ void SparseHieroReorderingFeature::EvaluateWhenApplied(
targetLeftRulePos < targetRightRulePos))) {
isMonotone = false;
}
- stringstream buf;
+ util::StringStream buf;
buf << "h_"; //sparse reordering, Huck
if (m_type == SourceLeft || m_type == SourceCombined) {
buf << GetFactor(sourceLeftBoundaryWord,m_sourceVocab,m_sourceFactor)->GetString();
diff --git a/moses/FF/TargetNgramFeature.cpp b/moses/FF/TargetNgramFeature.cpp
index 956eaeac6..5730293e6 100644
--- a/moses/FF/TargetNgramFeature.cpp
+++ b/moses/FF/TargetNgramFeature.cpp
@@ -281,7 +281,7 @@ FFState* TargetNgramFeature::EvaluateWhenApplied(const ChartHypothesis& cur_hypo
suffixTerminals++;
// everything else
else {
- stringstream ngram;
+ util::StringStream ngram;
ngram << m_baseName;
if (m_factorType == 0)
ngram << factorZero;
@@ -392,7 +392,7 @@ FFState* TargetNgramFeature::EvaluateWhenApplied(const ChartHypothesis& cur_hypo
suffixTerminals = 0;
// remove duplicates
- stringstream curr_ngram;
+ util::StringStream curr_ngram;
curr_ngram << m_baseName;
curr_ngram << (*contextFactor[m_n-2]).GetString(m_factorType);
curr_ngram << ":";
@@ -418,7 +418,7 @@ FFState* TargetNgramFeature::EvaluateWhenApplied(const ChartHypothesis& cur_hypo
// remove duplicates
size_t size = contextFactor.size();
if (makePrefix && makeSuffix && (size <= m_n)) {
- stringstream curr_ngram;
+ util::StringStream curr_ngram;
curr_ngram << m_baseName;
for (size_t i = 0; i < size; ++i) {
curr_ngram << (*contextFactor[i]).GetString(m_factorType);
@@ -436,7 +436,7 @@ FFState* TargetNgramFeature::EvaluateWhenApplied(const ChartHypothesis& cur_hypo
void TargetNgramFeature::MakePrefixNgrams(std::vector<const Word*> &contextFactor, ScoreComponentCollection* accumulator, size_t numberOfStartPos, size_t offset) const
{
- stringstream ngram;
+ util::StringStream ngram;
size_t size = contextFactor.size();
for (size_t k = 0; k < numberOfStartPos; ++k) {
size_t max_end = (size < m_n+k+offset)? size: m_n+k+offset;
@@ -461,7 +461,7 @@ void TargetNgramFeature::MakePrefixNgrams(std::vector<const Word*> &contextFacto
void TargetNgramFeature::MakeSuffixNgrams(std::vector<const Word*> &contextFactor, ScoreComponentCollection* accumulator, size_t numberOfEndPos, size_t offset) const
{
- stringstream ngram;
+ util::StringStream ngram;
for (size_t k = 0; k < numberOfEndPos; ++k) {
size_t end_pos = contextFactor.size()-1-k-offset;
for (int start_pos=end_pos-1; (start_pos >= 0) && (end_pos-start_pos < m_n); --start_pos) {
diff --git a/moses/FF/WordTranslationFeature.cpp b/moses/FF/WordTranslationFeature.cpp
index 1059e34de..6b2302c1c 100644
--- a/moses/FF/WordTranslationFeature.cpp
+++ b/moses/FF/WordTranslationFeature.cpp
@@ -179,7 +179,7 @@ void WordTranslationFeature::EvaluateWithSourceContext(const InputType &input
if (m_simple) {
// construct feature name
- stringstream featureName;
+ util::StringStream featureName;
featureName << m_description << "_";
featureName << sourceWord;
featureName << "~";
@@ -193,7 +193,7 @@ void WordTranslationFeature::EvaluateWithSourceContext(const InputType &input
if(use_topicid) {
// use topicid as trigger
const long topicid = sentence.GetTopicId();
- stringstream feature;
+ util::StringStream feature;
feature << m_description << "_";
if (topicid == -1)
feature << "unk";
@@ -209,7 +209,7 @@ void WordTranslationFeature::EvaluateWithSourceContext(const InputType &input
// use topic probabilities
const vector<string> &topicid_prob = *(input.GetTopicIdAndProb());
if (atol(topicid_prob[0].c_str()) == -1) {
- stringstream feature;
+ util::StringStream feature;
feature << m_description << "_unk_";
feature << sourceWord;
feature << "~";
@@ -217,7 +217,7 @@ void WordTranslationFeature::EvaluateWithSourceContext(const InputType &input
scoreBreakdown.SparsePlusEquals(feature.str(), 1);
} else {
for (size_t i=0; i+1 < topicid_prob.size(); i+=2) {
- stringstream feature;
+ util::StringStream feature;
feature << m_description << "_";
feature << topicid_prob[i];
feature << "_";
@@ -233,7 +233,7 @@ void WordTranslationFeature::EvaluateWithSourceContext(const InputType &input
const long docid = input.GetDocumentId();
for (boost::unordered_set<std::string>::const_iterator p = m_vocabDomain[docid].begin(); p != m_vocabDomain[docid].end(); ++p) {
string sourceTrigger = *p;
- stringstream feature;
+ util::StringStream feature;
feature << m_description << "_";
feature << sourceTrigger;
feature << "_";
@@ -248,7 +248,7 @@ void WordTranslationFeature::EvaluateWithSourceContext(const InputType &input
size_t globalSourceIndex = inputPath.GetWordsRange().GetStartPos() + sourceIndex;
if (!m_domainTrigger && globalSourceIndex == 0) {
// add <s> trigger feature for source
- stringstream feature;
+ util::StringStream feature;
feature << m_description << "_";
feature << "<s>,";
feature << sourceWord;
@@ -278,7 +278,7 @@ void WordTranslationFeature::EvaluateWithSourceContext(const InputType &input
if (m_domainTrigger) {
if (sourceTriggerExists) {
- stringstream feature;
+ util::StringStream feature;
feature << m_description << "_";
feature << sourceTrigger;
feature << "_";
@@ -288,7 +288,7 @@ void WordTranslationFeature::EvaluateWithSourceContext(const InputType &input
scoreBreakdown.SparsePlusEquals(feature.str(), 1);
}
} else if (m_unrestricted || sourceTriggerExists) {
- stringstream feature;
+ util::StringStream feature;
feature << m_description << "_";
if (contextIndex < globalSourceIndex) {
feature << sourceTrigger;
diff --git a/moses/Manager.cpp b/moses/Manager.cpp
index f5168f244..a862ebe3d 100644
--- a/moses/Manager.cpp
+++ b/moses/Manager.cpp
@@ -56,6 +56,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "util/exception.hh"
#include "util/random.hh"
+#include "util/string_stream.hh"
using namespace std;
@@ -1971,7 +1972,7 @@ void Manager::OutputSearchGraphSLF() const
// Output search graph in HTK standard lattice format (SLF)
bool slf = staticData.GetOutputSearchGraphSLF();
if (slf) {
- stringstream fileName;
+ util::StringStream fileName;
string dir;
staticData.GetParameter().SetParameter<string>(dir, "output-search-graph-slf", "");
diff --git a/moses/Word.cpp b/moses/Word.cpp
index c0041b173..679d8c05d 100644
--- a/moses/Word.cpp
+++ b/moses/Word.cpp
@@ -196,7 +196,7 @@ TO_STRING_BODY(Word);
// friend
ostream& operator<<(ostream& out, const Word& word)
{
- stringstream strme;
+ util::StringStream strme;
const std::string& factorDelimiter = StaticData::Instance().GetFactorDelimiter();
bool firstPass = true;
unsigned int stop = max_fax();
@@ -209,7 +209,7 @@ ostream& operator<<(ostream& out, const Word& word)
} else {
strme << factorDelimiter;
}
- strme << *factor;
+ strme << factor->GetString();
}
}
out << strme.str() << " ";