diff options
author | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-12-06 17:08:33 +0400 |
---|---|---|
committer | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-12-06 17:08:33 +0400 |
commit | ac045a11c1f0e1d4ae25f0db47061113fc3ae2e1 (patch) | |
tree | 1a6e5fad38dcc3c37852d84cd944f723f2fb4aec /mert/BleuScorer.cpp | |
parent | 55f65c3104989c5dae13f1cda3395cd52d62c524 (diff) |
Speed up N-gram counts when running extractor.
By replacing std::map with boost::unordered_map.
Runtime of extractor on 100-best lists of 2679 sentences:
Before:
real 0m35.314s
user 0m34.030s
sys 0m1.280s
Ater:
real 0m26.729s
user 0m25.420s
sys 0m1.310s
Diffstat (limited to 'mert/BleuScorer.cpp')
-rw-r--r-- | mert/BleuScorer.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/mert/BleuScorer.cpp b/mert/BleuScorer.cpp index ba662680c..a3ba16b13 100644 --- a/mert/BleuScorer.cpp +++ b/mert/BleuScorer.cpp @@ -62,6 +62,7 @@ size_t BleuScorer::CountNgrams(const string& line, NgramCounts& counts, } for (size_t i = 0; i < encoded_tokens.size()-k+1; ++i) { vector<int> ngram; + ngram.reserve(encoded_tokens.size()); for (size_t j = i; j < i+k && j < encoded_tokens.size(); ++j) { ngram.push_back(encoded_tokens[j]); } |