summaryrefslogtreecommitdiff
path: root/gi/pf/transliterations.cc
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-03-08 14:29:42 -0500
committerChris Dyer <cdyer@cs.cmu.edu>2012-03-08 14:29:42 -0500
commit78bf1457f606dd3880c2bc912201c4945d3f85b4 (patch)
treea7c09a9e0238c9aea477fa540ddaee6ebf1df638 /gi/pf/transliterations.cc
parent301106af9c13285ff252c618848eaa54b9b0e490 (diff)
moar
Diffstat (limited to 'gi/pf/transliterations.cc')
-rw-r--r--gi/pf/transliterations.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/gi/pf/transliterations.cc b/gi/pf/transliterations.cc
index 61e95b82..8ea4ebd2 100644
--- a/gi/pf/transliterations.cc
+++ b/gi/pf/transliterations.cc
@@ -48,10 +48,11 @@ struct BackwardEstimates {
};
struct TransliterationsImpl {
- TransliterationsImpl(int max_src, int max_trg) :
+ TransliterationsImpl(int max_src, int max_trg, double fr) :
kMAX_SRC_CHUNK(max_src),
kMAX_TRG_CHUNK(max_trg),
- tot_pairs() {
+ kFILTER_RATIO(fr),
+ tot_pairs(), tot_mem() {
}
void Initialize(WordID src, const vector<WordID>& src_lets, WordID trg, const vector<WordID>& trg_lets) {
@@ -63,7 +64,7 @@ struct TransliterationsImpl {
if (trg_len >= graphs[src_len].size()) graphs[src_len].resize(trg_len + 1);
GraphStructure& gs = graphs[src_len][trg_len];
if (!gs.r)
- gs.r = new Reachability(src_len, trg_len, kMAX_SRC_CHUNK, kMAX_TRG_CHUNK);
+ gs.r = new Reachability(src_len, trg_len, kMAX_SRC_CHUNK, kMAX_TRG_CHUNK, kFILTER_RATIO);
const Reachability& r = *gs.r;
// init backward estimates
@@ -77,6 +78,7 @@ struct TransliterationsImpl {
// TODO
tot_pairs++;
+ tot_mem += sizeof(float) * gs.r->nodes;
}
void Forbid(WordID src, const vector<WordID>& src_lets, WordID trg, const vector<WordID>& trg_lets) {
@@ -119,16 +121,20 @@ struct TransliterationsImpl {
cerr << "Average out-degree = " << (to / tn) << endl;
cerr << " Unique structures = " << tt << endl;
cerr << " Unique pairs = " << tot_pairs << endl;
+ cerr << " BEs size = " << (tot_mem / (1024.0*1024.0)) << " MB" << endl;
}
const int kMAX_SRC_CHUNK;
const int kMAX_TRG_CHUNK;
+ const double kFILTER_RATIO;
unsigned tot_pairs;
+ size_t tot_mem;
vector<vector<GraphStructure> > graphs; // graphs[src_len][trg_len]
vector<unordered_map<WordID, BackwardEstimates> > bes; // bes[src][trg]
};
-Transliterations::Transliterations(int max_src, int max_trg) : pimpl_(new TransliterationsImpl(max_src, max_trg)) {}
+Transliterations::Transliterations(int max_src, int max_trg, double fr) :
+ pimpl_(new TransliterationsImpl(max_src, max_trg, fr)) {}
Transliterations::~Transliterations() { delete pimpl_; }
void Transliterations::Initialize(WordID src, const vector<WordID>& src_lets, WordID trg, const vector<WordID>& trg_lets) {