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
path: root/moses
diff options
context:
space:
mode:
authorUlrich Germann <Ulrich.Germann@gmail.com>2015-11-24 22:22:37 +0300
committerUlrich Germann <Ulrich.Germann@gmail.com>2015-11-24 22:22:37 +0300
commitc8b859de678b3b1b258bbe5842e47cb96d5aaca2 (patch)
treede4cb09b0b8e040ebef8cc44aab5d9394547907b /moses
parentbcb0212b5b7a9535eb859f228bcfdf833aa57462 (diff)
parent5fea1ad548988d721a8850551b25f76f5dcf5694 (diff)
Merge remote-tracking branch 'legacy/master'
Conflicts: moses/server/TranslationRequest.cpp
Diffstat (limited to 'moses')
-rw-r--r--moses/FF/BleuScoreFeature.h16
-rw-r--r--moses/FF/ConstrainedDecoding.h18
-rw-r--r--moses/FF/ControlRecombination.h17
-rw-r--r--moses/FF/CoveredReferenceFeature.cpp5
-rw-r--r--moses/FF/CoveredReferenceFeature.h8
-rw-r--r--moses/FF/DistortionScoreProducer.h17
-rw-r--r--moses/FF/LexicalReordering/LexicalReordering.h22
-rw-r--r--moses/FF/OSM-Feature/OpSequenceModel.h12
-rw-r--r--moses/FF/PhraseBoundaryFeature.h17
-rw-r--r--moses/FF/PhraseOrientationFeature.h12
-rw-r--r--moses/FF/SkeletonStatefulFF.cpp14
-rw-r--r--moses/FF/SkeletonStatefulFF.h42
-rw-r--r--moses/FF/StatefulFeatureFunction.h17
-rw-r--r--moses/FF/TargetBigramFeature.h16
-rw-r--r--moses/FF/TargetNgramFeature.h18
-rw-r--r--moses/FF/TreeStructureFeature.h16
-rw-r--r--moses/Hypothesis.h4
-rw-r--r--moses/LM/Base.cpp9
-rw-r--r--moses/LM/Base.h12
-rw-r--r--moses/LM/BilingualLM.cpp16
-rw-r--r--moses/LM/BilingualLM.h17
-rw-r--r--moses/LM/RDLM.h13
-rw-r--r--moses/ThreadPool.cpp3
-rw-r--r--moses/ThreadPool.h3
-rw-r--r--moses/TranslationModel/UG/bitext-find.cc26
-rw-r--r--moses/TranslationModel/UG/check-coverage.cc13
-rw-r--r--moses/TranslationModel/UG/check-coverage3.cc64
-rw-r--r--moses/TranslationModel/UG/mm/ug_bitext.h42
-rw-r--r--moses/TranslationModel/UG/mm/ug_bitext_sampler.h4
-rw-r--r--moses/TranslationModel/UG/mm/ug_prep_phrases.h4
-rw-r--r--moses/TranslationModel/UG/mmsapt.h4
-rw-r--r--moses/parameters/AllOptions.cpp1
-rw-r--r--moses/parameters/NBestOptions.cpp2
-rw-r--r--moses/parameters/OptionsBaseClass.cpp8
-rw-r--r--moses/parameters/OptionsBaseClass.h2
-rw-r--r--moses/parameters/ReportingOptions.cpp2
-rw-r--r--moses/server/Hypothesis_4server.cpp9
-rw-r--r--moses/server/TranslationRequest.cpp51
-rw-r--r--moses/server/TranslationRequest.h9
39 files changed, 240 insertions, 345 deletions
diff --git a/moses/FF/BleuScoreFeature.h b/moses/FF/BleuScoreFeature.h
index 266d06b68..753d92cf9 100644
--- a/moses/FF/BleuScoreFeature.h
+++ b/moses/FF/BleuScoreFeature.h
@@ -123,22 +123,6 @@ public:
FFState* EvaluateWhenApplied(const ChartHypothesis& cur_hypo,
int featureID,
ScoreComponentCollection* accumulator) const;
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const {
- }
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {
- }
- void EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const {
- }
bool Enabled() const {
return m_enabled;
diff --git a/moses/FF/ConstrainedDecoding.h b/moses/FF/ConstrainedDecoding.h
index 3f28c43e1..769edd80f 100644
--- a/moses/FF/ConstrainedDecoding.h
+++ b/moses/FF/ConstrainedDecoding.h
@@ -42,24 +42,6 @@ public:
return true;
}
- void EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const {
- }
-
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const {
- }
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {
- }
-
FFState* EvaluateWhenApplied(
const Hypothesis& cur_hypo,
const FFState* prev_state,
diff --git a/moses/FF/ControlRecombination.h b/moses/FF/ControlRecombination.h
index 04f7d441b..034b1a790 100644
--- a/moses/FF/ControlRecombination.h
+++ b/moses/FF/ControlRecombination.h
@@ -58,23 +58,6 @@ public:
return true;
}
- void EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const {
- }
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const {
- }
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {
- }
-
FFState* EvaluateWhenApplied(
const Hypothesis& cur_hypo,
const FFState* prev_state,
diff --git a/moses/FF/CoveredReferenceFeature.cpp b/moses/FF/CoveredReferenceFeature.cpp
index d4606a8ec..5e4ada5b0 100644
--- a/moses/FF/CoveredReferenceFeature.cpp
+++ b/moses/FF/CoveredReferenceFeature.cpp
@@ -30,11 +30,6 @@ bool CoveredReferenceState::operator==(const FFState& other) const
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void CoveredReferenceFeature::EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const
-{}
void CoveredReferenceFeature::EvaluateWithSourceContext(const InputType &input
, const InputPath &inputPath
diff --git a/moses/FF/CoveredReferenceFeature.h b/moses/FF/CoveredReferenceFeature.h
index e6fc79ff7..aedfb3793 100644
--- a/moses/FF/CoveredReferenceFeature.h
+++ b/moses/FF/CoveredReferenceFeature.h
@@ -53,10 +53,6 @@ public:
return new CoveredReferenceState();
}
- void EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const;
void EvaluateWithSourceContext(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
@@ -64,10 +60,6 @@ public:
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedScores = NULL) const;
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {
- }
-
FFState* EvaluateWhenApplied(
const Hypothesis& cur_hypo,
const FFState* prev_state,
diff --git a/moses/FF/DistortionScoreProducer.h b/moses/FF/DistortionScoreProducer.h
index 6e6bfbaeb..cfe0dc005 100644
--- a/moses/FF/DistortionScoreProducer.h
+++ b/moses/FF/DistortionScoreProducer.h
@@ -47,23 +47,6 @@ public:
throw std::logic_error("DistortionScoreProducer not supported in chart decoder, yet");
}
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const {
- }
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {
- }
-
- void EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const {
- }
};
}
diff --git a/moses/FF/LexicalReordering/LexicalReordering.h b/moses/FF/LexicalReordering/LexicalReordering.h
index c47e7f037..fa2747c82 100644
--- a/moses/FF/LexicalReordering/LexicalReordering.h
+++ b/moses/FF/LexicalReordering/LexicalReordering.h
@@ -64,28 +64,6 @@ public:
UTIL_THROW2("LexicalReordering is not valid for chart decoder");
}
- void
- EvaluateWithSourceContext
- (const InputType &input,
- const InputPath &inputPath,
- const TargetPhrase &targetPhrase,
- const StackVec *stackVec,
- ScoreComponentCollection& scoreBreakdown,
- ScoreComponentCollection* estimatedScores = NULL) const
- { }
-
- void
- EvaluateTranslationOptionListWithSourceContext
- (const InputType &input, const TranslationOptionList &transOptList) const
- { }
-
- void
- EvaluateInIsolation(const Phrase &source,
- const TargetPhrase &targetPhrase,
- ScoreComponentCollection &scoreBreakdown,
- ScoreComponentCollection &estimatedScores) const
- { }
-
bool
GetHaveDefaultScores() {
return m_haveDefaultScores;
diff --git a/moses/FF/OSM-Feature/OpSequenceModel.h b/moses/FF/OSM-Feature/OpSequenceModel.h
index b97450d6b..36a901974 100644
--- a/moses/FF/OSM-Feature/OpSequenceModel.h
+++ b/moses/FF/OSM-Feature/OpSequenceModel.h
@@ -37,18 +37,6 @@ public:
int /* featureID - used to index the state in the previous hypotheses */,
ScoreComponentCollection* accumulator) const;
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const {
- }
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {
- }
-
void EvaluateInIsolation(const Phrase &source
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown
diff --git a/moses/FF/PhraseBoundaryFeature.h b/moses/FF/PhraseBoundaryFeature.h
index 916225b7d..9e84aaeef 100644
--- a/moses/FF/PhraseBoundaryFeature.h
+++ b/moses/FF/PhraseBoundaryFeature.h
@@ -54,23 +54,6 @@ public:
throw std::logic_error("PhraseBoundaryState not supported in chart decoder, yet");
}
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const {
- }
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {
- }
- void EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const {
- }
-
void SetParameter(const std::string& key, const std::string& value);
private:
diff --git a/moses/FF/PhraseOrientationFeature.h b/moses/FF/PhraseOrientationFeature.h
index 82d3928d9..4d9dc20dc 100644
--- a/moses/FF/PhraseOrientationFeature.h
+++ b/moses/FF/PhraseOrientationFeature.h
@@ -296,18 +296,6 @@ public:
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection &estimatedScores) const;
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const
- {};
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const
- {}
-
FFState* EvaluateWhenApplied(
const Hypothesis& cur_hypo,
const FFState* prev_state,
diff --git a/moses/FF/SkeletonStatefulFF.cpp b/moses/FF/SkeletonStatefulFF.cpp
index 4b077335e..2acaf2d2e 100644
--- a/moses/FF/SkeletonStatefulFF.cpp
+++ b/moses/FF/SkeletonStatefulFF.cpp
@@ -15,12 +15,19 @@ SkeletonStatefulFF::SkeletonStatefulFF(const std::string &line)
ReadParameters();
}
+
+// An empty implementation of this function is provided by StatefulFeatureFunction.
+// Unless you are actually implementing this, please remove it from your
+// implementation (and the declaration in the header file to reduce code clutter.
void SkeletonStatefulFF::EvaluateInIsolation(const Phrase &source
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection &estimatedScores) const
{}
+// An empty implementation of this function is provided by StatefulFeatureFunction.
+// Unless you are actually implementing this, please remove it from your
+// implementation (and the declaration in the header file to reduce code clutter.
void SkeletonStatefulFF::EvaluateWithSourceContext(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
@@ -29,8 +36,11 @@ void SkeletonStatefulFF::EvaluateWithSourceContext(const InputType &input
, ScoreComponentCollection *estimatedScores) const
{}
-void SkeletonStatefulFF::EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const
+// An empty implementation of this function is provided by StatefulFeatureFunction.
+// Unless you are actually implementing this, please remove it from your
+// implementation (and the declaration in the header file to reduce code clutter.
+void SkeletonStatefulFF::EvaluateTranslationOptionListWithSourceContext
+(const InputType &input, const TranslationOptionList &translationOptionList) const
{}
FFState* SkeletonStatefulFF::EvaluateWhenApplied(
diff --git a/moses/FF/SkeletonStatefulFF.h b/moses/FF/SkeletonStatefulFF.h
index bed54753c..7544ddd30 100644
--- a/moses/FF/SkeletonStatefulFF.h
+++ b/moses/FF/SkeletonStatefulFF.h
@@ -37,19 +37,35 @@ public:
return new SkeletonState(0);
}
- void EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const;
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const;
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const;
+ // An empty implementation of this function is provided by StatefulFeatureFunction.
+ // Unless you are actually implementing this, please remove this declaration here
+ // and the empty skeleton implementation from the corresponding .cpp
+ // file to reduce code clutter.
+ void
+ EvaluateInIsolation(const Phrase &source
+ , const TargetPhrase &targetPhrase
+ , ScoreComponentCollection &scoreBreakdown
+ , ScoreComponentCollection &estimatedScores) const;
+
+ // An empty implementation of this function is provided by StatefulFeatureFunction.
+ // Unless you are actually implementing this, please remove this declaration here
+ // and the empty skeleton implementation from the corresponding .cpp
+ // file to reduce code clutter.
+ void
+ EvaluateWithSourceContext(const InputType &input
+ , const InputPath &inputPath
+ , const TargetPhrase &targetPhrase
+ , const StackVec *stackVec
+ , ScoreComponentCollection &scoreBreakdown
+ , ScoreComponentCollection *estimatedScores = NULL) const;
+
+ // An empty implementation of this function is provided by StatefulFeatureFunction.
+ // Unless you are actually implementing this, please remove this declaration here
+ // and the empty skeleton implementation from the corresponding .cpp
+ // file to reduce code clutter.
+ void
+ EvaluateTranslationOptionListWithSourceContext
+ ( const InputType &input , const TranslationOptionList &translationOptionList) const;
FFState* EvaluateWhenApplied(
const Hypothesis& cur_hypo,
diff --git a/moses/FF/StatefulFeatureFunction.h b/moses/FF/StatefulFeatureFunction.h
index ac6888aa7..5c8c2bbd6 100644
--- a/moses/FF/StatefulFeatureFunction.h
+++ b/moses/FF/StatefulFeatureFunction.h
@@ -70,6 +70,23 @@ public:
return false;
}
+
+ virtual void
+ EvaluateInIsolation
+ (Phrase const& source, TargetPhrase const& targetPhrase,
+ ScoreComponentCollection &scoreBreakdown,
+ ScoreComponentCollection &estimatedScores) const {}
+
+ virtual void
+ EvaluateWithSourceContext
+ (InputType const&input, InputPath const& inputPath, TargetPhrase const& targetPhrase,
+ StackVec const* stackVec, ScoreComponentCollection &scoreBreakdown,
+ ScoreComponentCollection *estimatedFutureScore = NULL) const {}
+
+ virtual void
+ EvaluateTranslationOptionListWithSourceContext
+ (const InputType &input, const TranslationOptionList &translationOptionList) const {}
+
};
diff --git a/moses/FF/TargetBigramFeature.h b/moses/FF/TargetBigramFeature.h
index 200eca060..eacd27656 100644
--- a/moses/FF/TargetBigramFeature.h
+++ b/moses/FF/TargetBigramFeature.h
@@ -48,22 +48,6 @@ public:
ScoreComponentCollection* ) const {
throw std::logic_error("TargetBigramFeature not valid in chart decoder");
}
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const {
- }
- void EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const {
- }
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {
- }
void SetParameter(const std::string& key, const std::string& value);
diff --git a/moses/FF/TargetNgramFeature.h b/moses/FF/TargetNgramFeature.h
index 5bc2fc953..0a4b4aa25 100644
--- a/moses/FF/TargetNgramFeature.h
+++ b/moses/FF/TargetNgramFeature.h
@@ -215,24 +215,6 @@ public:
virtual FFState* EvaluateWhenApplied(const ChartHypothesis& cur_hypo, int featureId,
ScoreComponentCollection* accumulator) const;
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const {
- }
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {
- }
-
- void EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const {
- }
-
void SetParameter(const std::string& key, const std::string& value);
private:
diff --git a/moses/FF/TreeStructureFeature.h b/moses/FF/TreeStructureFeature.h
index 361e8cc6a..353328466 100644
--- a/moses/FF/TreeStructureFeature.h
+++ b/moses/FF/TreeStructureFeature.h
@@ -63,22 +63,6 @@ public:
void SetParameter(const std::string& key, const std::string& value);
- void EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const {};
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const {};
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {
- }
-
-
FFState* EvaluateWhenApplied(
const Hypothesis& cur_hypo,
const FFState* prev_state,
diff --git a/moses/Hypothesis.h b/moses/Hypothesis.h
index 01ba5a55e..cd26f5a2d 100644
--- a/moses/Hypothesis.h
+++ b/moses/Hypothesis.h
@@ -268,8 +268,8 @@ public:
#ifdef HAVE_XMLRPC_C
// these are implemented in moses/server/Hypothesis_4server.cpp !
- void OutputWordAlignment(std::vector<xmlrpc_c::value>& out, const ReportingOptions &options) const;
- void OutputLocalWordAlignment(std::vector<xmlrpc_c::value>& dest, const ReportingOptions &options) const;
+ void OutputWordAlignment(std::vector<xmlrpc_c::value>& out) const;
+ void OutputLocalWordAlignment(std::vector<xmlrpc_c::value>& dest) const;
#endif
bool beats(Hypothesis const& b) const;
diff --git a/moses/LM/Base.cpp b/moses/LM/Base.cpp
index 06911c325..a89bd27c1 100644
--- a/moses/LM/Base.cpp
+++ b/moses/LM/Base.cpp
@@ -57,10 +57,11 @@ void LanguageModel::ReportHistoryOrder(std::ostream &out,const Phrase &phrase) c
// out << "ReportHistoryOrder not implemented";
}
-void LanguageModel::EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const
+void
+LanguageModel::
+EvaluateInIsolation(Phrase const& source, TargetPhrase const& targetPhrase,
+ ScoreComponentCollection &scoreBreakdown,
+ ScoreComponentCollection &estimatedScores) const
{
// contains factors used by this LM
float fullScore, nGramScore;
diff --git a/moses/LM/Base.h b/moses/LM/Base.h
index 6212611ee..a052cc82e 100644
--- a/moses/LM/Base.h
+++ b/moses/LM/Base.h
@@ -90,18 +90,6 @@ public:
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection &estimatedScores) const;
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores = NULL) const {
- }
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {
- }
-
};
}
diff --git a/moses/LM/BilingualLM.cpp b/moses/LM/BilingualLM.cpp
index a52ccc1f2..b8974bb5e 100644
--- a/moses/LM/BilingualLM.cpp
+++ b/moses/LM/BilingualLM.cpp
@@ -188,22 +188,6 @@ size_t BilingualLM::getState(const Hypothesis& cur_hypo) const
return hashCode;
}
-void BilingualLM::EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedScores) const {}
-
-void BilingualLM::EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedScores) const
-{
-
-}
-
-
FFState* BilingualLM::EvaluateWhenApplied(
const Hypothesis& cur_hypo,
const FFState* prev_state,
diff --git a/moses/LM/BilingualLM.h b/moses/LM/BilingualLM.h
index 5070c7cec..cb5075fd1 100644
--- a/moses/LM/BilingualLM.h
+++ b/moses/LM/BilingualLM.h
@@ -119,23 +119,6 @@ public:
void Load();
- void EvaluateInIsolation(
- const Phrase &source,
- const TargetPhrase &targetPhrase,
- ScoreComponentCollection &scoreBreakdown,
- ScoreComponentCollection &estimatedScores) const;
-
- void EvaluateWithSourceContext(
- const InputType &input,
- const InputPath &inputPath,
- const TargetPhrase &targetPhrase,
- const StackVec *stackVec,
- ScoreComponentCollection &scoreBreakdown,
- ScoreComponentCollection *estimatedScores = NULL) const;
-
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {};
-
FFState* EvaluateWhenApplied(
const Hypothesis& cur_hypo,
const FFState* prev_state,
diff --git a/moses/LM/RDLM.h b/moses/LM/RDLM.h
index 8e169310f..963c1e8d5 100644
--- a/moses/LM/RDLM.h
+++ b/moses/LM/RDLM.h
@@ -196,18 +196,7 @@ public:
}
void SetParameter(const std::string& key, const std::string& value);
- void EvaluateInIsolation(const Phrase &source
- , const TargetPhrase &targetPhrase
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedFutureScore) const {};
- void EvaluateWithSourceContext(const InputType &input
- , const InputPath &inputPath
- , const TargetPhrase &targetPhrase
- , const StackVec *stackVec
- , ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection *estimatedFutureScore = NULL) const {};
- void EvaluateTranslationOptionListWithSourceContext(const InputType &input
- , const TranslationOptionList &translationOptionList) const {};
+
FFState* EvaluateWhenApplied(
const Hypothesis& cur_hypo,
const FFState* prev_state,
diff --git a/moses/ThreadPool.cpp b/moses/ThreadPool.cpp
index cba459697..deb6acb67 100644
--- a/moses/ThreadPool.cpp
+++ b/moses/ThreadPool.cpp
@@ -55,9 +55,6 @@ void ThreadPool::Execute()
}
//Execute job
if (task) {
- // must read from task before run. otherwise task may be deleted by main thread
- // race condition
- task->DeleteAfterExecution();
task->Run();
}
m_threadAvailable.notify_all();
diff --git a/moses/ThreadPool.h b/moses/ThreadPool.h
index b7d459bb2..f5be5e52b 100644
--- a/moses/ThreadPool.h
+++ b/moses/ThreadPool.h
@@ -53,9 +53,6 @@ class Task
{
public:
virtual void Run() = 0;
- virtual bool DeleteAfterExecution() {
- return true;
- }
virtual ~Task() {}
};
diff --git a/moses/TranslationModel/UG/bitext-find.cc b/moses/TranslationModel/UG/bitext-find.cc
index d02ce0710..4c6e13208 100644
--- a/moses/TranslationModel/UG/bitext-find.cc
+++ b/moses/TranslationModel/UG/bitext-find.cc
@@ -53,16 +53,16 @@ int main(int argc, char* argv[])
interpret_args(argc, argv);
if (Q1.empty() && Q2.empty()) exit(0);
- mmbitext B; string w;
- B.open(bname, L1, L2);
+ boost::shared_ptr<mmbitext> B(new mmbitext); string w;
+ B->open(bname, L1, L2);
- Bitext<Token>::iter m1(B.I1.get(), *B.V1, Q1);
+ Bitext<Token>::iter m1(B->I1.get(), *B->V1, Q1);
if (Q1.size() && m1.size() == 0) exit(0);
- Bitext<Token>::iter m2(B.I2.get(), *B.V2, Q2);
+ Bitext<Token>::iter m2(B->I2.get(), *B->V2, Q2);
if (Q2.size() && m2.size() == 0) exit(0);
- bitvector check(B.T1->size());
+ bitvector check(B->T1->size());
if (Q1.size() == 0 || Q2.size() == 0) check.set();
else (m2.markSentences(check));
@@ -87,23 +87,23 @@ int main(int argc, char* argv[])
size_t s1,s2,e1,e2; int po_fwd=-1,po_bwd=-1;
std::vector<unsigned char> caln;
- // cout << sid << " " << B.docname(sid) << std::endl;
- if (!B.find_trg_phr_bounds(sid, off, off+m.size(),
+ // cout << sid << " " << B->docname(sid) << std::endl;
+ if (!B->find_trg_phr_bounds(sid, off, off+m.size(),
s1,s2,e1,e2,po_fwd,po_bwd,
&caln, NULL, &m == &m2))
{
// cout << "alignment failure" << std::endl;
}
- std::cout << sid << " " << B.docname(sid)
+ std::cout << sid << " " << B->sid2docname(sid)
<< " dfwd=" << po_fwd << " dbwd=" << po_bwd
<< "\n";
- write_sentence(*B.T1, sid, *B.V1, std::cout); std::cout << "\n";
- write_sentence(*B.T2, sid, *B.V2, std::cout); std::cout << "\n";
- B.write_yawat_alignment(sid,
- m1.size() ? &m1 : NULL,
- m2.size() ? &m2 : NULL, std::cout);
+ write_sentence(*B->T1, sid, *B->V1, std::cout); std::cout << "\n";
+ write_sentence(*B->T2, sid, *B->V2, std::cout); std::cout << "\n";
+ B->write_yawat_alignment(sid,
+ m1.size() ? &m1 : NULL,
+ m2.size() ? &m2 : NULL, std::cout);
std::cout << std::endl;
}
diff --git a/moses/TranslationModel/UG/check-coverage.cc b/moses/TranslationModel/UG/check-coverage.cc
index 28d3e8968..3cf954912 100644
--- a/moses/TranslationModel/UG/check-coverage.cc
+++ b/moses/TranslationModel/UG/check-coverage.cc
@@ -41,8 +41,8 @@ basename(string const path, string const suffix)
int main(int argc, char* argv[])
{
- bitext_t B;
- B.open(argv[1],argv[2],argv[3]);
+ boost::shared_ptr<bitext_t> B(new bitext_t);
+ B->open(argv[1],argv[2],argv[3]);
string line;
string ifile = argv[4];
string docname = basename(ifile, string(".") + argv[2] + ".gz");
@@ -52,10 +52,10 @@ int main(int argc, char* argv[])
{
cout << line << " [" << docname << "]" << endl;
vector<id_type> snt;
- B.V1->fillIdSeq(line,snt);
+ B->V1->fillIdSeq(line,snt);
for (size_t i = 0; i < snt.size(); ++i)
{
- bitext_t::iter m(B.I1.get());
+ bitext_t::iter m(B->I1.get());
for (size_t k = i; k < snt.size() && m.extend(snt[k]); ++k)
{
if (m.ca() > 500) continue;
@@ -65,9 +65,10 @@ int main(int argc, char* argv[])
while (I.next != stop)
{
m.root->readEntry(I.next,I);
- ++cnt[B.docname(I.sid)];
+ ++cnt[B->sid2docname(I.sid)];
}
- cout << setw(8) << int(m.ca()) << " " << B.V1->toString(&snt[i],&snt[k+1]) << endl;
+ cout << setw(8) << int(m.ca()) << " "
+ << B->V1->toString(&snt[i],&snt[k+1]) << endl;
typedef pair<string,uint32_t> entry;
vector<entry> ranked; ranked.reserve(cnt.size());
BOOST_FOREACH(entry const& e, cnt) ranked.push_back(e);
diff --git a/moses/TranslationModel/UG/check-coverage3.cc b/moses/TranslationModel/UG/check-coverage3.cc
index d41e10ef3..c4a83877f 100644
--- a/moses/TranslationModel/UG/check-coverage3.cc
+++ b/moses/TranslationModel/UG/check-coverage3.cc
@@ -37,7 +37,7 @@ basename(string const path, string const suffix)
size_t k = path.size() - suffix.size();
cout << path << " " << suffix << endl;
cout << path.substr(0,p) << " " << path.substr(k) << endl;
- return path.substr(p, suffix == &path[k] ? k-p : path.size() - p);
+ return path.substr(p+1, suffix == &path[k] ? k-p-1 : path.size() - p);
}
int main(int argc, char* argv[])
@@ -47,6 +47,7 @@ int main(int argc, char* argv[])
string line;
string ifile = argv[4];
string docname = basename(ifile, string(".") + argv[2] + ".gz");
+ id_type docid = B->docname2docid(docname);
boost::iostreams::filtering_istream in;
ugdiss::open_input_stream(ifile,in);
while(getline(in,line))
@@ -57,13 +58,70 @@ int main(int argc, char* argv[])
for (size_t i = 0; i < snt.size(); ++i)
{
bitext_t::iter m(B->I1.get());
- for (size_t k = i; k < snt.size() && m.extend(snt[k]); ++k)
+ for (size_t k = i; k < snt.size() && m.extend(snt[k]); ++k);
+ for (size_t num_occurrences = m.ca(); m.size(); m.up())
{
+ if (size_t(m.ca()) == num_occurrences) continue;
+ num_occurrences = m.ca();
SPTR<SamplingBias const> zilch;
BitextSampler<Token> s(B.get(), m, zilch, 1000, 1000,
sapt::random_sampling);
s();
- cout << m.size() << " " << s.stats()->trg.size() << endl;
+ if (s.stats()->trg.size() == 0) continue;
+ // if (s.stats()->indoc[docname] > 10) continue;
+ sapt::pstats::indoc_map_t::const_iterator d
+ = s.stats()->indoc.find(docid);
+ size_t indoccnt = d != s.stats()->indoc.end() ? d->second : 0;
+ cout << m.size() << " : " << m.str(B->V1.get()) << " ("
+ << s.stats()->trg.size() << " entries; "
+ << indoccnt << "/" << s.stats()->good
+ << " samples in domain)" << endl;
+ vector<PhrasePair<Token> > ppairs;
+ PhrasePair<Token>::SortDescendingByJointCount sorter;
+ expand(m,*B,*s.stats(),ppairs,NULL);
+ sort(ppairs.begin(),ppairs.end(),sorter);
+ boost::format fmt("%4d/%d/%d |%s| (%4.2f : %4.2f)");
+ BOOST_FOREACH(PhrasePair<Token>& ppair, ppairs)
+ {
+ if (ppair.joint * 100 < ppair.good1) break;
+ ppair.good2 = ppair.raw2 * float(ppair.good1)/ppair.raw1;
+ ppair.good2 = max(ppair.good2, ppair.joint);
+
+#if 0
+ cout << "\t"
+ << (fmt % ppair.joint % ppair.good1 % ppair.good2
+ % B->T2->pid2str(B->V2.get(),ppair.p2)
+ % (float(ppair.joint)/ppair.good1)
+ % (float(ppair.joint)/ppair.good2)
+ ) << "\n";
+ typedef std::map<uint32_t, uint32_t>::const_iterator iter;
+ for (iter d = ppair.indoc.begin(); d != ppair.indoc.end(); ++d)
+ {
+ // if (d != ppair.indoc.begin()) cout << "; ";
+ cout << (boost::format("\t\t%4d %s") % d->second
+ % B->docid2name(d->first))
+ << endl;
+ }
+ cout << endl;
+#else
+ cout << "\t"
+ << (fmt % ppair.joint % ppair.good1 % ppair.good2
+ % B->T2->pid2str(B->V2.get(),ppair.p2)
+ % (float(ppair.joint)/ppair.good1)
+ % (float(ppair.joint)/ppair.good2)
+ ) << " [";
+ typedef std::map<uint32_t, uint32_t>::const_iterator iter;
+ for (iter d = ppair.indoc.begin(); d != ppair.indoc.end(); ++d)
+ {
+ if (d != ppair.indoc.begin()) cout << "; ";
+ cout << (boost::format("%s: %d") % B->docid2name(d->first)
+ % d->second) ;
+ }
+ cout << "]" << endl;
+
+#endif
+
+ }
}
}
}
diff --git a/moses/TranslationModel/UG/mm/ug_bitext.h b/moses/TranslationModel/UG/mm/ug_bitext.h
index aeb8703dc..4094dc9cc 100644
--- a/moses/TranslationModel/UG/mm/ug_bitext.h
+++ b/moses/TranslationModel/UG/mm/ug_bitext.h
@@ -217,17 +217,42 @@ namespace sapt
write_yawat_alignment
( id_type const sid, iter const* m1, iter const* m2, std::ostream& out ) const;
- std::string docname(id_type const sid) const;
-
+ std::string sid2docname(id_type const sid) const;
+ std::string docid2name(id_type const sid) const;
+ int docname2docid(std::string const& name) const;
+
std::vector<id_type> const* sid2did() const;
+ int sid2did(uint32_t sid) const;
};
#include "ug_bitext_agenda.h"
template<typename Token>
+ int
+ Bitext<Token>::
+ docname2docid(std::string const& name) const
+ {
+ std::map<std::string,id_type>::const_iterator m;
+ m = m_docname2docid.find(name);
+ if (m != m_docname2docid.end()) return m->second;
+ return -1;
+ }
+
+ template<typename Token>
std::string
Bitext<Token>::
- docname(id_type const sid) const
+ docid2name(id_type const did) const
+ {
+ if (did < m_docname.size())
+ return m_docname[did];
+ else
+ return (boost::format("%d") % did).str();
+ }
+
+ template<typename Token>
+ std::string
+ Bitext<Token>::
+ sid2docname(id_type const sid) const
{
if (sid < m_sid2docid->size() && (*m_sid2docid)[sid] < m_docname.size())
return m_docname[(*m_sid2docid)[sid]];
@@ -244,6 +269,17 @@ namespace sapt
}
template<typename Token>
+ int
+ Bitext<Token>::
+ sid2did(uint32_t sid) const
+ {
+ if (m_sid2docid)
+ return m_sid2docid->at(sid);
+ return -1;
+ }
+
+
+ template<typename Token>
SPTR<SentenceBias>
Bitext<Token>::
loadSentenceBias(std::string const& fname) const
diff --git a/moses/TranslationModel/UG/mm/ug_bitext_sampler.h b/moses/TranslationModel/UG/mm/ug_bitext_sampler.h
index a36e0772f..a10c83c6e 100644
--- a/moses/TranslationModel/UG/mm/ug_bitext_sampler.h
+++ b/moses/TranslationModel/UG/mm/ug_bitext_sampler.h
@@ -52,7 +52,7 @@ BitextSampler : public Moses::reference_counter
// const members
// SPTR<bitext const> const m_bitext; // keep bitext alive while I am
// should be an
- iptr<bitext const> const m_bitext; // keep bitext alive as long as I am
+ SPTR<bitext const> const m_bitext; // keep bitext alive as long as I am
size_t const m_plen; // length of lookup phrase
bool const m_fwd; // forward or backward direction?
SPTR<tsa const> const m_root; // root of suffix array
@@ -275,7 +275,7 @@ consider_sample(TokenPosition const& p)
bitvector full_aln(100*100);
PhraseExtractionRecord
rec(p.sid, p.offset, p.offset + m_plen, !m_fwd, &aln, &full_aln);
- int docid = m_bias ? m_bias->GetClass(p.sid) : -1;
+ int docid = m_bias ? m_bias->GetClass(p.sid) : m_bitext->sid2did(p.sid);
if (!m_bitext->find_trg_phr_bounds(rec))
{ // no good, probably because phrase is not coherent
m_stats->count_sample(docid, 0, rec.po_fwd, rec.po_bwd);
diff --git a/moses/TranslationModel/UG/mm/ug_prep_phrases.h b/moses/TranslationModel/UG/mm/ug_prep_phrases.h
index 1c62db2e3..1d04d6680 100644
--- a/moses/TranslationModel/UG/mm/ug_prep_phrases.h
+++ b/moses/TranslationModel/UG/mm/ug_prep_phrases.h
@@ -16,7 +16,7 @@ struct StatsCollector
typedef lru_cache::LRU_Cache< uint64_t, pstats > hcache_t;
typedef ThreadSafeContainer<uint64_t, SPTR<pstats> > pcache_t;
typedef map<uint64_t, SPTR<pstats> > lcache_t;
- iptr<Bitext<Token> const> bitext; // underlying bitext
+ SPTR<Bitext<Token> const> bitext; // underlying bitext
sampling_method method; // sampling method
size_t sample_size; // sample size
SPTR<SamplingBias const> bias; // sampling bias
@@ -26,7 +26,7 @@ struct StatsCollector
SPTR<lcache_t> lcache; // local cache
ug::ThreadPool* tpool; // thread pool to run jobs on
- StatsCollector(iptr<Bitext<Token> > xbitext,
+ StatsCollector(SPTR<Bitext<Token> > xbitext,
SPTR<SamplingBias> const xbias)
: method(ranked_sampling)
, sample_size(100)
diff --git a/moses/TranslationModel/UG/mmsapt.h b/moses/TranslationModel/UG/mmsapt.h
index d30177518..9dbd869df 100644
--- a/moses/TranslationModel/UG/mmsapt.h
+++ b/moses/TranslationModel/UG/mmsapt.h
@@ -71,7 +71,7 @@ namespace Moses
typedef sapt::PhraseScorer<Token> pscorer;
private:
// vector<SPTR<bitext> > shards;
- iptr<mmbitext> btfix;
+ SPTR<mmbitext> btfix;
SPTR<imbitext> btdyn;
std::string m_bname, m_extra_data, m_bias_file,m_bias_server;
std::string L1;
@@ -160,7 +160,7 @@ namespace Moses
#if PROVIDES_RANKED_SAMPLING
void
- set_bias_for_ranking(ttasksptr const& ttask, iptr<sapt::Bitext<Token> const> bt);
+ set_bias_for_ranking(ttasksptr const& ttask, SPTR<sapt::Bitext<Token> const> bt);
#endif
private:
diff --git a/moses/parameters/AllOptions.cpp b/moses/parameters/AllOptions.cpp
index cfb925dfb..a7acdadfa 100644
--- a/moses/parameters/AllOptions.cpp
+++ b/moses/parameters/AllOptions.cpp
@@ -65,6 +65,7 @@ namespace Moses
// set m_nbest_options.enabled = true if necessary:
nbest.enabled = (nbest.enabled || mira || search.consensus
|| nbest.nbest_size > 0
+ || mbr.enabled || lmbr.enabled
|| !output.SearchGraph.empty()
|| !output.SearchGraphExtended.empty()
|| !output.SearchGraphSLF.empty()
diff --git a/moses/parameters/NBestOptions.cpp b/moses/parameters/NBestOptions.cpp
index e916c3437..c65f9e852 100644
--- a/moses/parameters/NBestOptions.cpp
+++ b/moses/parameters/NBestOptions.cpp
@@ -43,7 +43,7 @@ update(std::map<std::string,xmlrpc_c::value>const& param)
params_t::const_iterator si = param.find("nbest");
if (si != param.end())
nbest_size = xmlrpc_c::value_int(si->second);
- only_distinct = check(param, "nbest-distinct");
+ only_distinct = check(param, "nbest-distinct", only_distinct);
enabled = (nbest_size > 0);
return true;
}
diff --git a/moses/parameters/OptionsBaseClass.cpp b/moses/parameters/OptionsBaseClass.cpp
index 148aa5d24..a19aaf7a6 100644
--- a/moses/parameters/OptionsBaseClass.cpp
+++ b/moses/parameters/OptionsBaseClass.cpp
@@ -1,5 +1,7 @@
// -*- mode: c++; indent-tabs-mode: nil; tab-width:2 -*-
#include "OptionsBaseClass.h"
+#include "moses/Util.h"
+
namespace Moses {
#ifdef HAVE_XMLRPC_C
@@ -15,10 +17,12 @@ namespace Moses {
bool
OptionsBaseClass::
check(std::map<std::string, xmlrpc_c::value> const& param,
- std::string const key)
+ std::string const key, bool dfltval)
{
std::map<std::string, xmlrpc_c::value>::const_iterator m;
- return (param.find(key) != param.end());
+ m = param.find(key);
+ if (m == param.end()) return dfltval;
+ return Scan<bool>(xmlrpc_c::value_string(m->second));
}
#endif
}
diff --git a/moses/parameters/OptionsBaseClass.h b/moses/parameters/OptionsBaseClass.h
index 71f9fa77a..ddec48192 100644
--- a/moses/parameters/OptionsBaseClass.h
+++ b/moses/parameters/OptionsBaseClass.h
@@ -13,6 +13,6 @@ namespace Moses
#endif
bool
check(std::map<std::string, xmlrpc_c::value> const& param,
- std::string const key);
+ std::string const key, bool dfltval);
};
}
diff --git a/moses/parameters/ReportingOptions.cpp b/moses/parameters/ReportingOptions.cpp
index 640b6a177..10a0cfcb4 100644
--- a/moses/parameters/ReportingOptions.cpp
+++ b/moses/parameters/ReportingOptions.cpp
@@ -75,7 +75,7 @@ namespace Moses {
ReportingOptions::
update(std::map<std::string, xmlrpc_c::value>const& param)
{
- ReportAllFactors = check(param, "report-all-factors");
+ ReportAllFactors = check(param, "report-all-factors", ReportAllFactors);
return true;
}
#endif
diff --git a/moses/server/Hypothesis_4server.cpp b/moses/server/Hypothesis_4server.cpp
index a7049f3d3..372755750 100644
--- a/moses/server/Hypothesis_4server.cpp
+++ b/moses/server/Hypothesis_4server.cpp
@@ -5,14 +5,15 @@
namespace Moses {
void
Hypothesis::
- OutputLocalWordAlignment(std::vector<xmlrpc_c::value>& dest, const ReportingOptions &options) const
+ OutputLocalWordAlignment(std::vector<xmlrpc_c::value>& dest) const
{
using namespace std;
Range const& src = this->GetCurrSourceWordsRange();
Range const& trg = this->GetCurrTargetWordsRange();
+ WordAlignmentSort waso = m_manager.options().output.WA_SortOrder;
vector<pair<size_t,size_t> const* > a
- = this->GetCurrTargetPhrase().GetAlignTerm().GetSortedAlignments(options.WA_SortOrder);
+ = this->GetCurrTargetPhrase().GetAlignTerm().GetSortedAlignments(waso);
typedef pair<size_t,size_t> item;
map<string, xmlrpc_c::value> M;
BOOST_FOREACH(item const* p, a) {
@@ -24,13 +25,13 @@ namespace Moses {
void
Hypothesis::
- OutputWordAlignment(std::vector<xmlrpc_c::value>& out, const ReportingOptions &options) const
+ OutputWordAlignment(std::vector<xmlrpc_c::value>& out) const
{
std::vector<Hypothesis const*> tmp;
for (Hypothesis const* h = this; h; h = h->GetPrevHypo())
tmp.push_back(h);
for (size_t i = tmp.size(); i-- > 0;)
- tmp[i]->OutputLocalWordAlignment(out, options);
+ tmp[i]->OutputLocalWordAlignment(out);
}
}
diff --git a/moses/server/TranslationRequest.cpp b/moses/server/TranslationRequest.cpp
index 1748f80ae..2157b2466 100644
--- a/moses/server/TranslationRequest.cpp
+++ b/moses/server/TranslationRequest.cpp
@@ -3,6 +3,8 @@
#include "moses/ContextScope.h"
#include <boost/foreach.hpp>
#include "moses/Util.h"
+#include "moses/Hypothesis.h"
+
namespace MosesServer
{
using namespace std;
@@ -164,15 +166,15 @@ insertGraphInfo(Manager& manager, map<string, xmlrpc_c::value>& retData)
retData["sg"] = xmlrpc_c::value_array(searchGraphXml);
}
-void
-TranslationRequest::
-output_phrase(ostream& out, Phrase const& phrase) const
-{
- if (!m_options.output.ReportAllFactors) {
- for (size_t i = 0 ; i < phrase.GetSize(); ++i)
- out << *phrase.GetFactor(i, 0) << " ";
- } else out << phrase;
-}
+// void
+// TranslationRequest::
+// output_phrase(ostream& out, Phrase const& phrase) const
+// {
+// if (!m_options.output.ReportAllFactors) {
+// for (size_t i = 0 ; i < phrase.GetSize(); ++i)
+// out << *phrase.GetFactor(i, 0) << " ";
+// } else out << phrase;
+// }
void
TranslationRequest::
@@ -193,7 +195,7 @@ outputNBest(const Manager& manager, map<string, xmlrpc_c::value>& retData)
vector<const Hypothesis *> const& E = path->GetEdges();
if (!E.size()) continue;
std::map<std::string, xmlrpc_c::value> nBestXmlItem;
- pack_hypothesis(E, "hyp", nBestXmlItem);
+ pack_hypothesis(manager, E, "hyp", nBestXmlItem);
if (m_withScoreBreakdown) {
// should the score breakdown be reported in a more structured manner?
ostringstream buf;
@@ -262,8 +264,11 @@ bool
check(std::map<std::string, xmlrpc_c::value> const& param,
std::string const key)
{
- std::map<std::string, xmlrpc_c::value>::const_iterator m;
- return (param.find(key) != param.end());
+ std::map<std::string, xmlrpc_c::value>::const_iterator m = param.find(key);
+ if(m == param.end()) return false;
+ std::string val = string(xmlrpc_c::value_string(m->second));
+ if(val == "true" || val == "True" || val == "TRUE" || val == "1") return true;
+ return false;
}
void
@@ -367,15 +372,17 @@ run_chart_decoder()
void
TranslationRequest::
-pack_hypothesis(vector<Hypothesis const* > const& edges, string const& key,
+pack_hypothesis(const Moses::Manager& manager, vector<Hypothesis const* > const& edges, string const& key,
map<string, xmlrpc_c::value> & dest) const
{
// target string
ostringstream target;
- BOOST_REVERSE_FOREACH(Hypothesis const* e, edges)
- output_phrase(target, e->GetCurrTargetPhrase());
- XVERBOSE(1,"SERVER TRANSLATION: " << target.str() << std::endl);
-
+ BOOST_REVERSE_FOREACH(Hypothesis const* e, edges) {
+ manager.OutputSurface(target, *e, m_options.output.factor_order,
+ m_options.output.ReportSegmentation, m_options.output.ReportAllFactors);
+ }
+ XVERBOSE(1, "BEST TRANSLATION: " << *(manager.GetBestHypothesis()) << std::endl);
+// XVERBOSE(1,"SERVER TRANSLATION: " << target.str() << std::endl);
dest[key] = xmlrpc_c::value_string(target.str());
if (m_withAlignInfo) {
@@ -383,7 +390,7 @@ pack_hypothesis(vector<Hypothesis const* > const& edges, string const& key,
vector<xmlrpc_c::value> p_aln;
BOOST_REVERSE_FOREACH(Hypothesis const* e, edges)
- add_phrase_aln_info(*e, p_aln);
+ add_phrase_aln_info(*e, p_aln);
dest["align"] = xmlrpc_c::value_array(p_aln);
}
@@ -391,21 +398,21 @@ pack_hypothesis(vector<Hypothesis const* > const& edges, string const& key,
// word alignment, if requested
vector<xmlrpc_c::value> w_aln;
BOOST_FOREACH(Hypothesis const* e, edges)
- e->OutputLocalWordAlignment(w_aln, m_options.output);
+ e->OutputLocalWordAlignment(w_aln);
dest["word-align"] = xmlrpc_c::value_array(w_aln);
}
}
void
TranslationRequest::
-pack_hypothesis(Hypothesis const* h, string const& key,
+pack_hypothesis(const Moses::Manager& manager, Hypothesis const* h, string const& key,
map<string, xmlrpc_c::value>& dest) const
{
using namespace std;
vector<Hypothesis const*> edges;
for (; h; h = h->GetPrevHypo())
edges.push_back(h);
- pack_hypothesis(edges, key, dest);
+ pack_hypothesis(manager, edges, key, dest);
}
@@ -422,7 +429,7 @@ run_phrase_decoder()
manager.Decode();
- pack_hypothesis(manager.GetBestHypothesis(), "text", m_retData);
+ pack_hypothesis(manager, manager.GetBestHypothesis(), "text", m_retData);
if (m_session_id)
m_retData["session-id"] = xmlrpc_c::value_int(m_session_id);
diff --git a/moses/server/TranslationRequest.h b/moses/server/TranslationRequest.h
index b93043b9b..7fb122714 100644
--- a/moses/server/TranslationRequest.h
+++ b/moses/server/TranslationRequest.h
@@ -58,17 +58,16 @@ TranslationRequest : public virtual Moses::TranslationTask
run_phrase_decoder();
void
- pack_hypothesis(std::vector<Moses::Hypothesis const* > const& edges,
+ pack_hypothesis(const Moses::Manager& manager, std::vector<Moses::Hypothesis const* > const& edges,
std::string const& key,
std::map<std::string, xmlrpc_c::value> & dest) const;
void
- pack_hypothesis(Moses::Hypothesis const* h, std::string const& key,
+ pack_hypothesis(const Moses::Manager& manager, Moses::Hypothesis const* h, std::string const& key,
std::map<std::string, xmlrpc_c::value> & dest) const;
-
- void
- output_phrase(std::ostream& out, Moses::Phrase const& phrase) const;
+ // void
+ // output_phrase(std::ostream& out, Moses::Phrase const& phrase) const;
void
add_phrase_aln_info(Moses::Hypothesis const& h,