summaryrefslogtreecommitdiff
path: root/word-aligner/ttables.cc
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-06-12 13:56:42 +0200
committerPatrick Simianer <p@simianer.de>2014-06-12 13:56:42 +0200
commit244971287003d079e46193b8a209c28955f90134 (patch)
tree8beaae6b12b913acb213fc7f2415fd63886192f9 /word-aligner/ttables.cc
parent5250fd67a4b8f242068cff87f0a6a4211f8b0fcf (diff)
parentb66e838ed52decc0be1eb5817b2a77c3840db2c5 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'word-aligner/ttables.cc')
-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";
}