diff options
author | bhaddow <bhaddow@1f5c12ca-751b-0410-a591-d2e778427230> | 2010-11-29 20:05:16 +0300 |
---|---|---|
committer | bhaddow <bhaddow@1f5c12ca-751b-0410-a591-d2e778427230> | 2010-11-29 20:05:16 +0300 |
commit | 0e5fbcdb4a4bd60afbd373ef414d9bac03186112 (patch) | |
tree | 41f975cc40efbeeb27847dc41aef22720ec67867 /moses-chart-cmd/src | |
parent | 50f0e6c07ddbd18b9b54fd64baf3804905423f49 (diff) |
Add show-weights for moses_chart
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@3745 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'moses-chart-cmd/src')
-rw-r--r-- | moses-chart-cmd/src/Main.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/moses-chart-cmd/src/Main.cpp b/moses-chart-cmd/src/Main.cpp index f161bd2b0..78473b709 100644 --- a/moses-chart-cmd/src/Main.cpp +++ b/moses-chart-cmd/src/Main.cpp @@ -82,6 +82,39 @@ bool ReadInput(IOWrapper &ioWrapper, InputTypeEnum inputType, InputType*& source return (source ? true : false); } +static void PrintFeatureWeight(const FeatureFunction* ff) { + + size_t weightStart = StaticData::Instance().GetScoreIndexManager().GetBeginIndex(ff->GetScoreBookkeepingID()); + size_t weightEnd = StaticData::Instance().GetScoreIndexManager().GetEndIndex(ff->GetScoreBookkeepingID()); + for (size_t i = weightStart; i < weightEnd; ++i) { + cout << ff->GetScoreProducerDescription() << " " << ff->GetScoreProducerWeightShortName() << " " + << StaticData::Instance().GetAllWeights()[i] << endl; + } +} + + +static void ShowWeights() { + cout.precision(6); + const StaticData& staticData = StaticData::Instance(); + const TranslationSystem& system = staticData.GetTranslationSystem(TranslationSystem::DEFAULT); + const vector<const StatelessFeatureFunction*>& slf =system.GetStatelessFeatureFunctions(); + const vector<const StatefulFeatureFunction*>& sff = system.GetStatefulFeatureFunctions(); + const vector<PhraseDictionaryFeature*>& pds = system.GetPhraseDictionaries(); + const vector<GenerationDictionary*>& gds = system.GetGenerationDictionaries(); + for (size_t i = 0; i < sff.size(); ++i) { + PrintFeatureWeight(sff[i]); + } + for (size_t i = 0; i < pds.size(); ++i) { + PrintFeatureWeight(pds[i]); + } + for (size_t i = 0; i < gds.size(); ++i) { + PrintFeatureWeight(gds[i]); + } + for (size_t i = 0; i < slf.size(); ++i) { + PrintFeatureWeight(slf[i]); + } +} + int main(int argc, char* argv[]) { @@ -107,6 +140,11 @@ int main(int argc, char* argv[]) const StaticData &staticData = StaticData::Instance(); if (!StaticData::LoadDataStatic(¶meter)) return EXIT_FAILURE; + + if (parameter.isParamSpecified("show-weights")) { + ShowWeights(); + exit(0); + } assert(staticData.GetSearchAlgorithm() == ChartDecoding); |