[irstlm] 17/126: inserted context-dependent LM among the available LMs in lmContainer ; changes to context-dependent LM

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


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

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

commit 63c3c9d4bb4f36265e1a63d27576fb2596fca426
Author: Nicola Bertoldi <bertoldi at fbk.eu>
Date:   Tue Jul 21 17:03:22 2015 +0200

    inserted context-dependent LM among the available LMs in lmContainer ; changes to context-dependent LM
---
 src/lmContainer.cpp      |  9 ++++++++-
 src/lmContainer.h        | 14 ++++++++++++++
 src/lmContextDependent.h | 16 +++++++++++++---
 3 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/src/lmContainer.cpp b/src/lmContainer.cpp
index 4d7a756..1a1f4f2 100644
--- a/src/lmContainer.cpp
+++ b/src/lmContainer.cpp
@@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 #include "lmmacro.h"
 #include "lmclass.h"
 #include "lmInterpolation.h"
+#include "lmContextDependent.h"
 
 using namespace std;
 	
@@ -92,8 +93,10 @@ int lmContainer::getLanguageModelType(std::string filename)
 
   int type=_IRSTLM_LMUNKNOWN;
   VERBOSE(1,"type: " << type << std::endl);
-  if (header == "lmminterpolation" || header == "LMINTERPOLATION") {
+  if (header == "lminterpolation" || header == "LMINTERPOLATION") {
     type = _IRSTLM_LMINTERPOLATION;
+  } else if (header == "lmcontextdependent" || header == "LMCONTEXTDEPENDENT") {
+    type = _IRSTLM_LMCONTEXTDEPENDENT;
   } else if (header == "lmmacro" || header == "LMMACRO") {
     type = _IRSTLM_LMMACRO;
   } else if (header == "lmclass" || header == "LMCLASS") {
@@ -138,6 +141,10 @@ lmContainer* lmContainer::CreateLanguageModel(int type, float nlf, float dlf)
 		case _IRSTLM_LMINTERPOLATION:
 			lm = new lmInterpolation(nlf, dlf);
 			break;
+
+                case _IRSTLM_LMCONTEXTDEPENDENT:
+                        lm = new lmContextDependent(nlf, dlf);
+                        break;
 			
 		default:
 			exit_error(IRSTLM_ERROR_DATA, "This language model type is unknown!");
diff --git a/src/lmContainer.h b/src/lmContainer.h
index 03c8b37..3e998f6 100644
--- a/src/lmContainer.h
+++ b/src/lmContainer.h
@@ -28,11 +28,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 #define _IRSTLM_LMMACRO 2
 #define _IRSTLM_LMCLASS 3
 #define _IRSTLM_LMINTERPOLATION 4
+#define _IRSTLM_LMCONTEXTDEPENDENT 5
 
 
 #include <stdio.h>
 #include <cstdlib>
 #include <stdlib.h>
+#include <map>
 #include "util.h"
 #include "n_gram.h"
 #include "dictionary.h"
@@ -40,6 +42,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 typedef enum {BINARY,TEXT,YRANIB,NONE} OUTFILE_TYPE;
 
 namespace irstlm {
+
+typedef std::map< std::string, float > topic_map;
+
 class lmContainer
 {
   static const bool debug=true;
@@ -128,6 +133,15 @@ public:
     return 0.0;
   };
 
+  virtual double clprob(ngram ng, topic_map& topic_weights, double* bow=NULL, int* bol=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL) {
+    UNUSED(topic_weights);
+    return clprob(ng, bow, bol, maxsuffptr, statesize, extendible);
+  };
+
+  virtual double clprob(int* ng, int ngsize, topic_map& topic_weights, double* bow=NULL, int* bol=NULL, char** maxsuffptr=NULL, unsigned int* statesize=NULL,bool* extendible=NULL) {
+    UNUSED(topic_weights);
+    return clprob(ng, ngsize, bow, bol, maxsuffptr, statesize, extendible);
+  }
 
   virtual const char *cmaxsuffptr(ngram ng, unsigned int* statesize=NULL)
   {
diff --git a/src/lmContextDependent.h b/src/lmContextDependent.h
index 7795aa6..e4d33fd 100644
--- a/src/lmContextDependent.h
+++ b/src/lmContextDependent.h
@@ -28,14 +28,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 #include <stdlib.h>
 #include <string>
 #include <math.h>
-#include <map>
 #include "util.h"
 #include "dictionary.h"
 #include "n_gram.h"
 #include "lmContainer.h"
 
-typedef std::map< std::string, float > topic_map;
-	
 namespace irstlm {
 /*
 Context-dependent LM
@@ -79,11 +76,24 @@ public:
 
   virtual double clprob(ngram ng,            double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL){
         VERBOSE(0, "This LM type (lmContextDependent) does not support this function");
+        UNUSED(ng);
+        UNUSED(bow);
+        UNUSED(bol);
+        UNUSED(maxsuffptr);
+        UNUSED(statesize);
+        UNUSED(extendible);
         assert(false);
   };
 
   virtual double clprob(int* ng, int ngsize, double* bow=NULL,int* bol=NULL,char** maxsuffptr=NULL,unsigned int* statesize=NULL,bool* extendible=NULL){
 	VERBOSE(0, "This LM type (lmContextDependent) does not support this function");
+        UNUSED(ng);
+        UNUSED(ngsize);
+        UNUSED(bow);
+        UNUSED(bol);
+        UNUSED(maxsuffptr);
+        UNUSED(statesize);
+        UNUSED(extendible);
 	assert(false);
   };
 

-- 
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