[irstlm] 42/126: minor changes and code cleanup related to usage of log_10 and ln for probabilities

Giulio Paci giuliopaci-guest at moszumanska.debian.org
Tue May 17 07:46:43 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 34d2de6c100183e1efeb6da77831d19ac16a8638
Author: Nicola Bertoldi <bertoldi at fbk.eu>
Date:   Tue Aug 4 13:54:16 2015 +0200

    minor changes and code cleanup related to usage of log_10 and ln for probabilities
---
 src/context-dependent-evaluation.cpp | 11 +++++------
 src/lmContextDependent.cpp           |  7 +++----
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/context-dependent-evaluation.cpp b/src/context-dependent-evaluation.cpp
index 18de5da..44760a0 100644
--- a/src/context-dependent-evaluation.cpp
+++ b/src/context-dependent-evaluation.cpp
@@ -346,8 +346,8 @@ int main(int argc, char **argv)
 			}
 			
 			if (sent_PP_flag) {
-				sent_PP=exp((-sent_logPr * log(10.0)) /sent_Nw);
-				sent_PPwp= sent_PP * (1 - 1/exp((sent_Noov *  lmt->getlogOOVpenalty()) * log(10.0) / sent_Nw));
+				sent_PP=exp((-sent_logPr * M_LN10) /sent_Nw);
+				sent_PPwp= sent_PP * (1 - 1/exp((sent_Noov *  lmt->getlogOOVpenalty()) * M_LN10 / sent_Nw));
 				
 				std::cout << "%% sent_Nw=" << sent_Nw
 				<< " sent_PP=" << sent_PP
@@ -364,16 +364,15 @@ int main(int argc, char **argv)
 		}
 		
 		
-		PP=exp((-logPr * log(10.0)) /Nw);
-		
-		PPwp= PP * (1 - 1/exp((Noov *  lmt->getlogOOVpenalty()) * log(10.0) / Nw));
+		PP=exp((-logPr * M_LN10) / Nw);
+		PPwp= PP * (1 - 1/exp((Noov *  lmt->getlogOOVpenalty()) * M_LN10 / Nw));
 		
 		std::cout << "%% Nw=" << Nw
 		<< " PP=" << PP
 		<< " PPwp=" << PPwp
 		<< " Noov=" << Noov
 		<< " OOV=" << (float)Noov/Nw * 100.0 << "%";
-		if (debug) std::cout << " logPr=" <<  logPr;
+		if (debug > 0) std::cout << " log10_Pr=" <<  logPr;
 		std::cout << std::endl;
 		std::cout.flush();
 		
diff --git a/src/lmContextDependent.cpp b/src/lmContextDependent.cpp
index 34e4640..ebd6ed7 100644
--- a/src/lmContextDependent.cpp
+++ b/src/lmContextDependent.cpp
@@ -148,7 +148,7 @@ namespace irstlm {
 		if (similarity_score != SIMILARITY_LOWER_BOUND){
 			ret_logprob += m_similaritymodel_weight * similarity_score;
 		}
-		VERBOSE(0, "lm_logprob:" << lm_logprob << " similarity_score:" << similarity_score << " m_similaritymodel_weight:" << m_similaritymodel_weight << " ret_logprob:" << ret_logprob << std::endl);
+		VERBOSE(0, "lm_log10_pr:" << lm_logprob << " similarity_score:" << similarity_score << " m_similaritymodel_weight:" << m_similaritymodel_weight << " ret_log10_pr:" << ret_logprob << std::endl);
 		
 		return ret_logprob;
 	}
@@ -168,7 +168,7 @@ namespace irstlm {
 		if (similarity_score != SIMILARITY_LOWER_BOUND){
 			ret_logprob += m_similaritymodel_weight * similarity_score;
 		}
-		VERBOSE(0, "lm_logprob:" << lm_logprob << " similarity_score:" << similarity_score << " m_similaritymodel_weight:" << m_similaritymodel_weight << " ret_logprob:" << ret_logprob << std::endl);
+		VERBOSE(0, "lm_log10_pr:" << lm_logprob << " similarity_score:" << similarity_score << " m_similaritymodel_weight:" << m_similaritymodel_weight << " ret_log10_pr:" << ret_logprob << std::endl);
 		
 		return ret_logprob;
 	}
@@ -188,8 +188,7 @@ namespace irstlm {
 	{
 		MY_ASSERT(dub > dict->size());
 		m_lm->setlogOOVpenalty(dub);  //set OOV Penalty by means of DUB
-		double OOVpenalty = m_lm->getlogOOVpenalty();  //get OOV Penalty
-		logOOVpenalty=log(OOVpenalty);
+		logOOVpenalty=log(m_lm->getlogOOVpenalty());
 		return logOOVpenalty;
 	}
 }//namespace irstlm

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