summaryrefslogtreecommitdiff
path: root/training/ttables.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-06-18 20:28:42 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-06-18 20:28:42 -0400
commit67456f9f7af754750faeea6f1e66b14b910d8751 (patch)
treed4c647f455e0a2b9fe102843fd0a060264867c44 /training/ttables.h
parentc3fddf01ebfa8f523ab2d6bb2db5e2be1a929ee2 (diff)
add non-const iterators to sparse vector, speed up model1 code
Diffstat (limited to 'training/ttables.h')
-rw-r--r--training/ttables.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/training/ttables.h b/training/ttables.h
index bf3351d2..9baa13ca 100644
--- a/training/ttables.h
+++ b/training/ttables.h
@@ -4,6 +4,7 @@
#include <iostream>
#include <tr1/unordered_map>
+#include "sparse_vector.h"
#include "m.h"
#include "wordid.h"
#include "tdict.h"
@@ -68,18 +69,18 @@ class TTable {
}
return *this;
}
- void ShowTTable() {
- for (Word2Word2Double::iterator it = ttable.begin(); it != ttable.end(); ++it) {
- Word2Double& cpd = it->second;
- for (Word2Double::iterator j = cpd.begin(); j != cpd.end(); ++j) {
+ void ShowTTable() const {
+ for (Word2Word2Double::const_iterator it = ttable.begin(); it != ttable.end(); ++it) {
+ const Word2Double& cpd = it->second;
+ for (Word2Double::const_iterator j = cpd.begin(); j != cpd.end(); ++j) {
std::cerr << "P(" << TD::Convert(j->first) << '|' << TD::Convert(it->first) << ") = " << j->second << std::endl;
}
}
}
- void ShowCounts() {
- for (Word2Word2Double::iterator it = counts.begin(); it != counts.end(); ++it) {
- Word2Double& cpd = it->second;
- for (Word2Double::iterator j = cpd.begin(); j != cpd.end(); ++j) {
+ void ShowCounts() const {
+ for (Word2Word2Double::const_iterator it = counts.begin(); it != counts.end(); ++it) {
+ const Word2Double& cpd = it->second;
+ for (Word2Double::const_iterator j = cpd.begin(); j != cpd.end(); ++j) {
std::cerr << "c(" << TD::Convert(j->first) << '|' << TD::Convert(it->first) << ") = " << j->second << std::endl;
}
}