diff options
author | Matous Machacek <machacekmatous@gmail.com> | 2012-02-28 05:27:23 +0400 |
---|---|---|
committer | Matous Machacek <machacekmatous@gmail.com> | 2012-02-28 05:27:23 +0400 |
commit | ba987c94ba9be5e7c8eb9c3e7c83d8f971fbd3aa (patch) | |
tree | 4140bd7b8fcef62012d2fe59956dcc81bb25c2bd /mert/InterpolatedScorer.cpp | |
parent | e38cd12ef3385304a4b363ca9b9ab16ed886a2ff (diff) |
Support for using factors in mert and evaluator
example:
Use --factor "0|2" to use only first and third factor from nbest list and from reference.
If you use interpolated scorer, separate records with comma (e.g. --factor "0|2,1").
Diffstat (limited to 'mert/InterpolatedScorer.cpp')
-rw-r--r-- | mert/InterpolatedScorer.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mert/InterpolatedScorer.cpp b/mert/InterpolatedScorer.cpp index 5ba410539..1951e4234 100644 --- a/mert/InterpolatedScorer.cpp +++ b/mert/InterpolatedScorer.cpp @@ -159,3 +159,24 @@ void InterpolatedScorer::prepareStats(size_t sid, const string& text, ScoreStats string str = buff.str(); entry.set(str); } + +void InterpolatedScorer::setFactors(const string& factors) +{ + if (factors.empty()) return; + + vector<string> fsplit; + split(factors, ',', fsplit); + + if (fsplit.size() != _scorers.size()) throw runtime_error("Number of factor specifications does not equal number of interpolated scorers."); + + for (size_t i = 0; i < _scorers.size(); ++i) + { + _scorers[i]->setFactors(fsplit[i]); + } +} + + + + + + |