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
path: root/irstlm
diff options
context:
space:
mode:
authormfederico <mfederico@1f5c12ca-751b-0410-a591-d2e778427230>2006-08-11 20:36:00 +0400
committermfederico <mfederico@1f5c12ca-751b-0410-a591-d2e778427230>2006-08-11 20:36:00 +0400
commit356bc1d5317277535f693f124c6c2852431f3ce5 (patch)
tree5647d1701b55a8db3865168097995234a2e0bc5f /irstlm
parentb340381eb48db8c0669fa5e41f2edf1998170936 (diff)
LM caches are reset for each sentence only if full.
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@653 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'irstlm')
-rw-r--r--irstlm/src/htable.h2
-rw-r--r--irstlm/src/lmtable.cpp12
-rw-r--r--irstlm/src/lmtable.h25
3 files changed, 27 insertions, 12 deletions
diff --git a/irstlm/src/htable.h b/irstlm/src/htable.h
index cbf997e38..111340632 100644
--- a/irstlm/src/htable.h
+++ b/irstlm/src/htable.h
@@ -85,6 +85,7 @@ class htable {
case INT:case INTPTR: return HashInt(key);
break;
case STR:case STRPTR: return HashStr(key);
+ default: exit(1);
}
};
address HashInt(char *key);
@@ -96,6 +97,7 @@ class htable {
case INT:case INTPTR: return CompInt(Key1,Key2);
break;
case STR:case STRPTR: return CompStr(Key1,Key2);
+ default: exit(1);
};
}
diff --git a/irstlm/src/lmtable.cpp b/irstlm/src/lmtable.cpp
index d071ee402..182d1fa5c 100644
--- a/irstlm/src/lmtable.cpp
+++ b/irstlm/src/lmtable.cpp
@@ -53,7 +53,7 @@ lmtable::lmtable(){
memset(info, 0, sizeof(info));
memset(NumCenters, 0, sizeof(NumCenters));
- bicache=new ngramcache(2,sizeof(char*),1000000);
+ bicache=NULL;
probcache=NULL;
statecache=NULL;
@@ -579,7 +579,7 @@ int lmtable::get(ngram& ng,int n,int lev){
//if (l==2) cout <<"bicache: searching:" << ng <<"\n";
- if (l==2 && bicache->get(ng.wordp(n),(char *)&found))
+ if (bicache && l==2 && bicache->get(ng.wordp(n),(char *)&found))
hit=1;
else
search(table[l] + (offset * nodesize(ndt)),
@@ -591,8 +591,8 @@ int lmtable::get(ngram& ng,int n,int lev){
LMT_FIND,
&found);
- if (l==2 && hit==0){
- if (bicache->isfull()) bicache->reset();
+ if (bicache && l==2 && hit==0){
+ //if (bicache->isfull()) bicache->reset();
//cout << "bicache :" << ng <<"\n";
bicache->add(ng.wordp(n),(char *)&found);
}
@@ -746,7 +746,7 @@ const char *lmtable::cmaxsuffptr(ngram ong){
found=(char *)maxsuffptr(ong);
if (statecache && ong.size==maxlev-1){
- if (statecache->isfull()) statecache->reset();
+ //if (statecache->isfull()) statecache->reset();
statecache->add(ong.wordp(maxlev-1),(char *)&found);
};
@@ -845,7 +845,7 @@ double lmtable::clprob(ngram ong){
logpr=lprob(ong);
if (probcache && ong.size==maxlev){
- if (probcache->isfull()) probcache->reset();
+ //if (probcache->isfull()) probcache->reset();
probcache->add(ong.wordp(maxlev),(char *)&logpr);
};
diff --git a/irstlm/src/lmtable.h b/irstlm/src/lmtable.h
index 753872fbb..4ef928699 100644
--- a/irstlm/src/lmtable.h
+++ b/irstlm/src/lmtable.h
@@ -171,18 +171,31 @@ public:
}
}
- void init_prob_and_state_caches(){
- assert(probcache==NULL && statecache==NULL);
+ void init_probcache(){
+ assert(probcache==NULL);
probcache=new ngramcache(maxlev,sizeof(double),2000000);
+ }
+
+ void init_statecache(){
+ assert(statecache==NULL);
statecache=new ngramcache(maxlev-1,sizeof(char *),2000000);
}
- void reset_prob_and_state_caches(){
- probcache->reset();
- statecache->reset();
+ void init_bicache(){
+ assert(bicache==NULL);
+ bicache=new ngramcache(2,sizeof(char *),2000000);
+ }
+
+
+ void check_cache_levels(){
+ if (probcache && probcache->isfull()) probcache->reset();
+ if (statecache && statecache->isfull()) statecache->reset();
+ if (bicache && bicache->isfull()) bicache->reset();
}
- bool is_prob_cache_active(){return probcache!=NULL;}
+ bool is_probcache_active(){return probcache!=NULL;}
+ bool is_statecache_active(){return statecache!=NULL;}
+ bool is_bicache_active(){return bicache!=NULL;}
void configure(int n,bool quantized){