[irstlm] 10/78: fixings about virtaul functions; added supporting functions; code cleanup

Giulio Paci giuliopaci-guest at moszumanska.debian.org
Tue May 17 07:47:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

giuliopaci-guest pushed a commit to tag adaptiveLM.v0.10
in repository irstlm.

commit c685ce06d08e2294288b254d86a726048139c20e
Author: Nicola Bertoldi <bertoldi at fbk.eu>
Date:   Fri Nov 6 18:23:48 2015 +0100

    fixings about virtaul functions; added supporting functions; code cleanup
---
 src/lmContainer.h     | 36 +++++++++++++++++++++++++-----------
 src/lmInterpolation.h | 15 ++++++---------
 src/lmclass.h         | 25 +++++++++++--------------
 src/lmmacro.h         |  2 --
 src/lmtable.h         | 27 +++++++++++++++++----------
 5 files changed, 59 insertions(+), 46 deletions(-)

diff --git a/src/lmContainer.h b/src/lmContainer.h
index de908a0..2b4e3f0 100644
--- a/src/lmContainer.h
+++ b/src/lmContainer.h
@@ -115,7 +115,23 @@ public:
     return false;
   };	
 	
-	virtual double clprob(ngram ng, double* bow=NULL, int* bol=NULL, ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL) {
+	double clprob(ngram ng) {
+		return clprob(ng, NULL, NULL, NULL, NULL, NULL, NULL);
+	}
+	double clprob(ngram ng, double* bow, int* bol) {
+		return clprob(ng, bow, bol, NULL, NULL, NULL, NULL);
+	}
+	double clprob(ngram ng, double* bow, int* bol, char** maxsuffptr, unsigned int* statesize) {
+		return clprob(ng, bow, bol, NULL, maxsuffptr, statesize, NULL);
+	}
+	double clprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize) {
+		return clprob(ng, bow, bol, maxsuffidx, maxsuffptr, statesize, NULL);
+	}
+	virtual double clprob(ngram ng, double* bow, int* bol, char** maxsuffptr, unsigned int* statesize,bool* extendible) {
+		VERBOSE(3,"virtual double  lmContainer::clprob(ngram ng, double* bow=NULL, int* bol=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL) ng:|" << ng  << "|\n");
+		return clprob(ng, bow, bol, NULL, maxsuffptr, statesize, extendible);
+  };
+	virtual double clprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize,bool* extendible) {
 		VERBOSE(3,"virtual double  lmContainer::clprob(ngram ng, double* bow=NULL, int* bol=NULL, ngram_state_t* maxsuffidx=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL) ng:|" << ng  << "|\n");
     UNUSED(ng);
     UNUSED(bow);
@@ -127,9 +143,12 @@ public:
     return 0.0;
   };
 
-//  virtual double clprob(int* ng, int ngsize, double* bow=NULL, int* bol=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL) {
-  virtual double clprob(int* ng, int ngsize, double* bow=NULL, int* bol=NULL, ngram_state_t* maxsuffidx=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL) {
-//	VERBOSE(3,"virtual double lmContainer::clprob(int* ng, int ngsize, double* bow=NULL, int* bol=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL)\n");
+  virtual double clprob(int* ng, int ngsize, double* bow, int* bol, char** maxsuffptr, unsigned int* statesize,bool* extendible) {
+		VERBOSE(3,"virtual double lmContainer::clprob(int* ng, int ngsize, double* bow=NULL, int* bol=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL)\n");
+		return clprob(ng, ngsize, bow, bol, NULL, maxsuffptr, statesize, extendible);
+  };
+
+  virtual double clprob(int* ng, int ngsize, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize,bool* extendible) {
 	VERBOSE(3,"virtual double lmContainer::clprob(int* ng, int ngsize, double* bow=NULL, int* bol=NULL, ngram_state_t* maxsuffidx=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL)\n");
     UNUSED(ng);
     UNUSED(ngsize);
@@ -145,17 +164,12 @@ public:
 	
   virtual const char *cmaxsuffptr(ngram ng, unsigned int* statesize=NULL)
   {
-    UNUSED(ng);
-    UNUSED(statesize);
-    return NULL;
+    return cmaxsuffptr(ng, statesize);
   }
 	
   virtual const char *cmaxsuffptr(int* ng, int ngsize, unsigned int* statesize=NULL)
   {
-    UNUSED(ng);
-    UNUSED(ngsize);
-    UNUSED(statesize);
-    return NULL;
+    return cmaxsuffptr(ng, ngsize, statesize);
   }
 	
   virtual ngram_state_t cmaxsuffidx(ngram ng, unsigned int* statesize=NULL)
diff --git a/src/lmInterpolation.h b/src/lmInterpolation.h
index 9b260d8..b1fe743 100644
--- a/src/lmInterpolation.h
+++ b/src/lmInterpolation.h
@@ -71,17 +71,14 @@ public:
 
   void load(const std::string &filename,int mmap=0);
   lmContainer* load_lm(int i, int memmap, float nlf, float dlf);
-	
-//  virtual double clprob(ngram ng,            double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
-//  virtual double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
 
-  virtual double clprob(ngram ng,            double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
-  virtual double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
+  double clprob(ngram ng, double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
+  double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
 	
-	virtual const char *cmaxsuffptr(ngram ong, unsigned int* size=NULL);
-  virtual const char *cmaxsuffptr(int* codes, int sz, unsigned int* size=NULL);
-  virtual ngram_state_t cmaxsuffidx(ngram ong, unsigned int* size=NULL);
-  virtual ngram_state_t cmaxsuffidx(int* codes, int sz, unsigned int* size=NULL);
+	const char *cmaxsuffptr(ngram ong, unsigned int* size=NULL);
+  const char *cmaxsuffptr(int* codes, int sz, unsigned int* size=NULL);
+  ngram_state_t cmaxsuffidx(ngram ong, unsigned int* size=NULL);
+  ngram_state_t cmaxsuffidx(int* codes, int sz, unsigned int* size=NULL);
 	
 
   int maxlevel() const {
diff --git a/src/lmclass.h b/src/lmclass.h
index 55d4fc1..3ab299f 100644
--- a/src/lmclass.h
+++ b/src/lmclass.h
@@ -74,25 +74,22 @@ public:
   ~lmclass();
 
   void load(const std::string &filename,int mmap=0);
-	
-//  double lprob(ngram ng, double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
-/*
-  inline double clprob(ngram ng,double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL) {
-    return lprob(ng,bow,bol,maxsuffptr,statesize,extendible);
+
+  double lprob(ngram ng, double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL) {
+		return lprob(ng,bow,bol,NULL,maxsuffptr,statesize,extendible);
   };
-*/
-/*
- inline double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL) {
-    ngram ong(getDict());
-    ong.pushc(ng,ngsize);
-    return lprob(ong,bow,bol,maxsuffptr,statesize,extendible);
+  double clprob(ngram ng,double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL) {
+    return clprob(ng,bow,bol,NULL,maxsuffptr,statesize,extendible);
+  };
+  double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL) {
+    return clprob(ng,ngsize,bow,bol,NULL,maxsuffptr,statesize,extendible);
   };
-*/
+
   double lprob(ngram ng, double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
-  inline double clprob(ngram ng,double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL) {
+  double clprob(ngram ng,double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL) {
     return lprob(ng,bow,bol,maxsuffidx,maxsuffptr,statesize,extendible);
   };
-  inline double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL) {
+  double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL) {
     ngram ong(getDict());
     ong.pushc(ng,ngsize);
     return lprob(ong,bow,bol,maxsuffidx,maxsuffptr,statesize,extendible);
diff --git a/src/lmmacro.h b/src/lmmacro.h
index d8deed9..c67c6bf 100644
--- a/src/lmmacro.h
+++ b/src/lmmacro.h
@@ -77,8 +77,6 @@ public:
   void load(const std::string &filename,int mmap=0);
 
   double lprob(ngram ng);
-//  double clprob(ngram ng,double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
-//  double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
   double clprob(ngram ng,double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
   double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
 
diff --git a/src/lmtable.h b/src/lmtable.h
index 340eebd..77ed54d 100644
--- a/src/lmtable.h
+++ b/src/lmtable.h
@@ -300,8 +300,8 @@ public:
 	inline void update_offset(int level, table_entry_pos_t value) { tb_offset[level]=value; };
 	
 	
-	void load(const std::string &filename, int mmap=0);
-	void load(std::istream& inp,const char* filename=NULL,const char* outfilename=NULL,int mmap=0);
+	virtual void load(const std::string &filename, int mmap=0);
+	virtual void load(std::istream& inp,const char* filename=NULL,const char* outfilename=NULL,int mmap=0);
 	
 	void load_centers(std::istream& inp,int l);
 	
@@ -315,16 +315,23 @@ public:
 	
 	void filter(const char* /* unused parameter: lmfile */) {};
 	
+	virtual double  lprob(ngram ng){
+		return lprob(ng, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+	}
+	virtual double  lprob(ngram ng, double* bow, int* bol, char** maxsuffptr, unsigned int* statesize, bool* extendible){
+		return lprob(ng, bow, bol, NULL, maxsuffptr, statesize, extendible, NULL);
+	}
+	virtual double  lprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize, bool* extendible){
+	 return lprob(ng, bow, bol, maxsuffidx, maxsuffptr, statesize, extendible, NULL);
+	}
 	
-//	virtual double  lprob(ngram ng, double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL, bool* extendible=NULL, double* lastbow=NULL);
-//	virtual double clprob(ngram ng, double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
-//	virtual double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
-	
-	
+	virtual double  lprob(ngram ng, double* bow, int* bol, char** maxsuffptr, unsigned int* statesize, bool* extendible, double* lastbow){
+		return lprob(ng, bow, bol, NULL, maxsuffptr, statesize, extendible, lastbow);
+	}
+	virtual double  lprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize, bool* extendible, double* lastbow);
 	
-	virtual double  lprob(ngram ng, double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL, bool* extendible=NULL, double* lastbow=NULL);
-  virtual double clprob(ngram ng, double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
-  virtual double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,ngram_state_t* maxsuffidx=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL);
+  virtual double clprob(ngram ng, double* bow=NULL, int* bol=NULL, ngram_state_t* maxsuffidx=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL, bool* extendible=NULL);
+  virtual double clprob(int* ng, int ngsize, double* bow=NULL, int* bol=NULL, ngram_state_t* maxsuffidx=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL, bool* extendible=NULL);
 	
 
 	void *search(int lev,table_entry_pos_t offs,table_entry_pos_t n,int sz,int *w, LMT_ACTION action,char **found=(char **)NULL);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/irstlm.git



More information about the debian-science-commits mailing list