summaryrefslogtreecommitdiff
path: root/word-aligner
diff options
context:
space:
mode:
authorChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-04-09 20:19:57 -0400
committerChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-04-09 20:19:57 -0400
commitbde2f6be8d0ea5b931f43fe7f518e9adcbcd2b49 (patch)
tree46d4baad4d906187af70611db01402c00f674473 /word-aligner
parent4627194833a9d50fd218fd3db506685c1d92436d (diff)
fix for loading parameters
Diffstat (limited to 'word-aligner')
-rw-r--r--word-aligner/ttables.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/word-aligner/ttables.cc b/word-aligner/ttables.cc
index a56bbcef..64d54bdf 100644
--- a/word-aligner/ttables.cc
+++ b/word-aligner/ttables.cc
@@ -8,28 +8,32 @@ using namespace std;
void TTable::DeserializeProbsFromText(std::istream* in) {
int c = 0;
+ string e;
+ string f;
+ double p;
while(*in) {
- string e;
- string f;
- double p;
(*in) >> e >> f >> p;
if (e.empty()) break;
++c;
- ttable[TD::Convert(e)][TD::Convert(f)] = p;
+ WordID ie = TD::Convert(e);
+ if (ie >= static_cast<int>(ttable.size())) ttable.resize(ie + 1);
+ ttable[ie][TD::Convert(f)] = p;
}
cerr << "Loaded " << c << " translation parameters.\n";
}
void TTable::DeserializeLogProbsFromText(std::istream* in) {
int c = 0;
+ string e;
+ string f;
+ double p;
while(*in) {
- string e;
- string f;
- double p;
(*in) >> e >> f >> p;
if (e.empty()) break;
++c;
- ttable[TD::Convert(e)][TD::Convert(f)] = exp(p);
+ WordID ie = TD::Convert(e);
+ if (ie >= static_cast<int>(ttable.size())) ttable.resize(ie + 1);
+ ttable[ie][TD::Convert(f)] = exp(p);
}
cerr << "Loaded " << c << " translation parameters.\n";
}