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:
authorTetsuo Kiso <tetsuo-s@is.naist.jp>2012-02-25 20:11:56 +0400
committerTetsuo Kiso <tetsuo-s@is.naist.jp>2012-02-25 20:11:56 +0400
commit17f06a32501289daf11181e24454a2d3f6635ba0 (patch)
treef3300e0b0ec529778a21fd1c5f5f2e653cb2af8c /mert/BleuScorer.h
parent0c9023abc6c231e96cd11cc15502f0e1353fec2a (diff)
Hide the implementation details of Ngram counts from the header.
Diffstat (limited to 'mert/BleuScorer.h')
-rw-r--r--mert/BleuScorer.h34
1 files changed, 9 insertions, 25 deletions
diff --git a/mert/BleuScorer.h b/mert/BleuScorer.h
index 68c485684..4166d30e7 100644
--- a/mert/BleuScorer.h
+++ b/mert/BleuScorer.h
@@ -33,41 +33,25 @@ private:
CLOSEST
};
- //Used to construct the ngram map
- struct CompareNgrams {
- bool operator()(const vector<int>& a, const vector<int>& b) const {
- size_t i;
- const size_t as = a.size();
- const size_t bs = b.size();
- for (i = 0; i < as && i < bs; ++i) {
- if (a[i] < b[i]) {
- return true;
- }
- if (a[i] > b[i]) {
- return false;
- }
- }
- //entries are equal, shortest wins
- return as < bs;
- }
- };
-
- typedef map<vector<int>,int,CompareNgrams> counts_t;
- typedef map<vector<int>,int,CompareNgrams>::iterator counts_iterator;
- typedef map<vector<int>,int,CompareNgrams>::const_iterator counts_const_iterator;
+ /**
+ * A NgramCounts is a key-value store.
+ * Clients don't have to worry about the actual implementation
+ * since this type is used in internal only.
+ */
+ class NgramCounts;
/**
* Count the ngrams of each type, up to the given length in the input line.
*/
- size_t countNgrams(const string& line, counts_t& counts, unsigned int n);
+ size_t countNgrams(const string& line, NgramCounts& counts, unsigned int n);
- void dump_counts(counts_t& counts) const;
+ void dump_counts(const NgramCounts& counts) const;
const int kLENGTH;
ReferenceLengthType m_ref_length_type;
// data extracted from reference files
- ScopedVector<counts_t> m_ref_counts;
+ ScopedVector<NgramCounts> m_ref_counts;
vector<vector<size_t> > m_ref_lengths;
// no copying allowed