[irstlm] 70/78: code cleanup and optimization

Giulio Paci giuliopaci-guest at moszumanska.debian.org
Tue May 17 07:47:07 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 05e0d48e6d950d69d1ad84cf6cc1485e0d5bff8f
Author: Nicola Bertoldi <bertoldi at fbk.eu>
Date:   Thu Dec 10 00:16:35 2015 +0100

    code cleanup and optimization
---
 src/lmContainer.h     | 70 +++++++++++++++++++++++++++++++--------------------
 src/lmInterpolation.h |  2 +-
 src/lmclass.h         | 10 ++------
 src/lmmacro.h         |  4 +--
 src/lmtable.h         | 19 ++------------
 5 files changed, 50 insertions(+), 55 deletions(-)

diff --git a/src/lmContainer.h b/src/lmContainer.h
index 40aaa3a..7d52273 100644
--- a/src/lmContainer.h
+++ b/src/lmContainer.h
@@ -128,19 +128,6 @@ namespace irstlm {
 		virtual 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, NULL); }
 		virtual double clprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize, bool* extendible) { return clprob(ng, bow, bol, maxsuffidx, maxsuffptr, statesize, extendible, NULL); };
 
-		virtual double clprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize, bool* extendible, double* lastbow)
-{
-			UNUSED(ng);
-			UNUSED(bow);
-			UNUSED(bol);
-			UNUSED(maxsuffidx);
-			UNUSED(maxsuffptr);
-                        UNUSED(statesize);
-			UNUSED(extendible);
-			UNUSED(lastbow);
-
-                        return 0.0;
-}
 		
 		virtual double clprob(int* ng, int ngsize){ return clprob(ng, ngsize, NULL, NULL, NULL, NULL, NULL, NULL, NULL); }
 		virtual double clprob(int* ng, int ngsize, double* bow){ return clprob(ng, ngsize, bow, NULL, NULL, NULL, NULL, NULL, NULL); }
@@ -149,25 +136,54 @@ namespace irstlm {
 		virtual double clprob(int* ng, int ngsize, double* bow, int* bol, ngram_state_t* maxsuffidx){ return clprob(ng, ngsize, bow, bol, maxsuffidx, NULL, NULL, NULL, NULL); }
 		virtual double clprob(int* ng, int ngsize, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize=NULL, bool* extendible=NULL, double* lastbow=NULL)
 		{
-			//create the actual ngram
-			ngram ong(getDict());
-			ong.pushc(ng,ngsize);
-			MY_ASSERT (ong.size == ngsize);
-			
-			return clprob(ong, bow, bol, maxsuffidx, maxsuffptr, statesize, extendible, lastbow);
-		}
-		
-		virtual double clprob(ngram ng, topic_map_t& topic_weights, double* bow=NULL, int* bol=NULL, ngram_state_t* maxsuffidx=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL, double* lastbow=NULL)
-		{
-			UNUSED(topic_weights);		
-			return clprob(ng, bow, bol, maxsuffidx, maxsuffptr, statesize, extendible, lastbow);
+                        //create the actual ngram
+                        ngram ong(getDict());
+                        ong.pushc(ng,ngsize);
+                        MY_ASSERT (ong.size == ngsize);
+
+			return clprob(ng, ngsize, bow, bol, maxsuffidx, maxsuffptr, statesize, extendible, lastbow);
 		}
+
 		virtual double clprob(int* ng, int ngsize, topic_map_t& topic_weights, double* bow=NULL, int* bol=NULL, ngram_state_t* maxsuffidx=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL, double* lastbow=NULL)
 		{
-			UNUSED(topic_weights);		
-			return clprob(ng, ngsize, bow, bol, maxsuffidx, maxsuffptr, statesize, extendible, lastbow);
+                        //create the actual ngram
+                        ngram ong(getDict());
+                        ong.pushc(ng,ngsize);
+                        MY_ASSERT (ong.size == ngsize);
+
+			return clprob(ng, ngsize, topic_weights, bow, bol, maxsuffidx, maxsuffptr, statesize, extendible, lastbow);
 		}
 
+		virtual double clprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize, bool* extendible, double* lastbow)
+                {
+                        UNUSED(ng);
+                        UNUSED(bow);
+                        UNUSED(bol);
+                        UNUSED(maxsuffidx);
+                        UNUSED(maxsuffptr);
+                        UNUSED(statesize);
+                        UNUSED(extendible);
+                        UNUSED(lastbow);
+
+                        return 0.0;
+                }
+
+	//this is a function which could be overwritten	
+                virtual double clprob(ngram ng, topic_map_t& topic_weights, double* bow=NULL, int* bol=NULL, ngram_state_t* maxsuffidx=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL, double* lastbow=NULL)
+                {
+                        UNUSED(topic_weights);
+                        UNUSED(ng);
+                        UNUSED(bow);
+                        UNUSED(bol);
+                        UNUSED(maxsuffidx);
+                        UNUSED(maxsuffptr);
+                        UNUSED(statesize);
+                        UNUSED(extendible);
+                        UNUSED(lastbow);
+                        
+                        return 0.0;
+		}                
+
 		virtual const char *cmaxsuffptr(ngram ng, unsigned int* statesize=NULL)
 		{
 			UNUSED(ng);
diff --git a/src/lmInterpolation.h b/src/lmInterpolation.h
index 13e9c7d..6869d4e 100644
--- a/src/lmInterpolation.h
+++ b/src/lmInterpolation.h
@@ -72,7 +72,7 @@ namespace irstlm {
 		virtual 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, 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, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize, bool* extendible, double* lastbow);
 		
 		virtual const char *cmaxsuffptr(ngram ong, unsigned int* size=NULL);
 		virtual ngram_state_t cmaxsuffidx(ngram ong, unsigned int* size=NULL);
diff --git a/src/lmclass.h b/src/lmclass.h
index 3fcfba0..4014232 100644
--- a/src/lmclass.h
+++ b/src/lmclass.h
@@ -75,14 +75,8 @@ namespace irstlm {
 		
 		virtual void load(const std::string &filename,int mmap=0);
 		
-		/*		
-		  virtual double lprob(ngram ng, double* bow=NULL, int* bol=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL, bool* extendible=NULL, double* lastbow=NULL) { return lprob(ng,bow,bol,NULL,maxsuffptr,statesize,extendible,lastbow); };
-		  virtual 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); };
-		  virtual 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); };
-		*/
-		
-		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, double* lastbow=NULL) { return lprob(ng, bow, bol, maxsuffidx, 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 clprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize, bool* extendible, double* lastbow) { return lprob(ng, bow, bol, maxsuffidx, maxsuffptr, statesize, extendible, lastbow); };
 		
 		inline bool is_OOV(int code) {
 			//a word is consisdered OOV if its mapped value is OOV
diff --git a/src/lmmacro.h b/src/lmmacro.h
index 5ff8421..8f31c90 100644
--- a/src/lmmacro.h
+++ b/src/lmmacro.h
@@ -76,8 +76,8 @@ namespace irstlm {
 		
 		virtual void load(const std::string &filename,int mmap=0);
 		
-		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, double* lastbow=NULL);
+		virtual double lprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize, bool* extendible, double* lastbow);
+		virtual double clprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize, bool* extendible, double* lastbow);
 		
 		virtual const char *maxsuffptr(ngram ong, unsigned int* size=NULL);
 		virtual ngram_state_t maxsuffidx(ngram ong, unsigned int* size=NULL);
diff --git a/src/lmtable.h b/src/lmtable.h
index 3e9338b..c6f301d 100644
--- a/src/lmtable.h
+++ b/src/lmtable.h
@@ -316,23 +316,8 @@ namespace irstlm {
 		int reload(std::set<string> words);
 		
 		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){ return lprob(ng, bow, NULL, NULL, NULL, NULL, NULL, NULL); }
-		virtual double  lprob(ngram ng, double* bow, int* bol){ return lprob(ng, bow, bol, NULL, NULL, NULL, NULL, NULL); }
-		virtual double  lprob(ngram ng, double* bow, int* bol, char** maxsuffptr){ return lprob(ng, bow, bol, NULL, maxsuffptr, NULL, NULL, NULL); }
-		virtual double  lprob(ngram ng, double* bow, int* bol, char** maxsuffptr, unsigned int* statesize){ return lprob(ng, bow, bol, NULL, maxsuffptr, statesize, 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){ return lprob(ng, bow, bol, maxsuffidx, NULL, NULL, NULL, NULL); }
-		virtual double  lprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr){ return lprob(ng, bow, bol, maxsuffidx, maxsuffptr, NULL, NULL, NULL); }
-		virtual double  lprob(ngram ng, double* bow, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize){ return lprob(ng, bow, bol, maxsuffidx, maxsuffptr, statesize, NULL, 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, 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, double* lastbow=NULL);
+		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, int* bol, ngram_state_t* maxsuffidx, char** maxsuffptr, unsigned int* statesize, bool* extendible, double* lastbow);
 
 		virtual const char *maxsuffptr(ngram ong, unsigned int* size=NULL);
 		virtual const char *cmaxsuffptr(ngram ong, unsigned int* size=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