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>2014-09-30 17:22:38 +0400
committerHieu Hoang <hieuhoang@gmail.com>2014-09-30 17:22:38 +0400
commit33ed15ef199a11c0690ff6db2bc2c8f446af3395 (patch)
tree10034981d269b6e01eb523bbce880af16bf1c382 /moses/Util.cpp
parentc20af584e73873ce4d06b14a7ff793752fb07505 (diff)
move misc common functions into moses/
Diffstat (limited to 'moses/Util.cpp')
-rw-r--r--moses/Util.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/moses/Util.cpp b/moses/Util.cpp
index f92c32dbb..9664c811e 100644
--- a/moses/Util.cpp
+++ b/moses/Util.cpp
@@ -37,6 +37,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "Timer.h"
#include "util/exception.hh"
#include "util/file.hh"
+#include "moses/FF/StatelessFeatureFunction.h"
+#include "moses/FF/StatefulFeatureFunction.h"
+#include "moses/StaticData.h"
using namespace std;
@@ -203,6 +206,44 @@ std::string PassthroughSGML(std::string &line, const std::string tagName, const
return meta;
}
+void PrintFeatureWeight(const FeatureFunction* ff)
+{
+ cout << ff->GetScoreProducerDescription() << "=";
+ size_t numScoreComps = ff->GetNumScoreComponents();
+ vector<float> values = StaticData::Instance().GetAllWeights().GetScoresForProducer(ff);
+ for (size_t i = 0; i < numScoreComps; ++i) {
+ cout << " " << values[i];
+ }
+ cout << endl;
+
}
+void ShowWeights()
+{
+ fix(cout,6);
+ const vector<const StatelessFeatureFunction*>& slf = StatelessFeatureFunction::GetStatelessFeatureFunctions();
+ const vector<const StatefulFeatureFunction*>& sff = StatefulFeatureFunction::GetStatefulFeatureFunctions();
+
+ for (size_t i = 0; i < sff.size(); ++i) {
+ const StatefulFeatureFunction *ff = sff[i];
+ if (ff->IsTuneable()) {
+ PrintFeatureWeight(ff);
+ }
+ else {
+ cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
+ }
+ }
+ for (size_t i = 0; i < slf.size(); ++i) {
+ const StatelessFeatureFunction *ff = slf[i];
+ if (ff->IsTuneable()) {
+ PrintFeatureWeight(ff);
+ }
+ else {
+ cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
+ }
+ }
+}
+
+} // namespace
+