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
diff options
context:
space:
mode:
authorbojar <bojar@1f5c12ca-751b-0410-a591-d2e778427230>2006-07-26 23:45:34 +0400
committerbojar <bojar@1f5c12ca-751b-0410-a591-d2e778427230>2006-07-26 23:45:34 +0400
commit71ae9d8dada257e60f26f9da3fc465e13f6a7b9c (patch)
tree26d7e3de95261df44e7f4b813a4294f2556b718c
parent88e62f919b00398f352eb8686871547e30aa2613 (diff)
reports the number of translation options (per span) generated if verbosity > 0
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@309 1f5c12ca-751b-0410-a591-d2e778427230
-rw-r--r--moses/src/TranslationOptionCollection.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/moses/src/TranslationOptionCollection.cpp b/moses/src/TranslationOptionCollection.cpp
index 6238acc61..11d164b82 100644
--- a/moses/src/TranslationOptionCollection.cpp
+++ b/moses/src/TranslationOptionCollection.cpp
@@ -23,11 +23,20 @@ void TranslationOptionCollection::CalcFutureScore(size_t verboseLevel)
{
// create future score matrix in a dynamic programming fashion
+
// setup the matrix (ignore lower triangle, set upper triangle to -inf
size_t size = m_source.GetSize(); // the width of the matrix
+
+ // counting options per span, for statistics
+ bool printCounts = (verboseLevel > 0);
+ int *counts;
+ if (printCounts == true)
+ counts = (int*) malloc(sizeof(int) * size * size);
+
for(size_t row=0; row<size; row++) {
for(size_t col=row; col<size; col++) {
m_futureScore.SetScore(row, col, -numeric_limits<float>::infinity());
+ if (printCounts == true) counts[row*size+col] = 0;
}
}
@@ -40,6 +49,8 @@ void TranslationOptionCollection::CalcFutureScore(size_t verboseLevel)
float score = transOpt.GetFutureScore();
if (score > m_futureScore.GetScore(startpos, endpos))
m_futureScore.SetScore(startpos, endpos, score);
+
+ if (printCounts == true) counts[startpos*size + endpos] ++;
}
// now fill all the cells in the strictly upper triangle
@@ -65,12 +76,25 @@ void TranslationOptionCollection::CalcFutureScore(size_t verboseLevel)
}
}
}
+
+ if (printCounts == true) {
+ int total = 0;
+ for(size_t row=0; row<size; row++)
+ for(size_t col=row; col<size; col++)
+ if (counts[row*size+ col] > 0) {
+ cout<<"translation options spanning from "<< row <<" to "<< col <<" is "<< counts[row*size+ col] <<endl;
+ total += counts[row*size+ col];
+ }
+ cout << "translation options generated in total: "<< total << endl;
+ free(counts);
+ }
+
if(verboseLevel > 0)
{
for(size_t row=0; row<size; row++)
for(size_t col=row; col<size; col++)
cout<<"future cost from "<< row <<" to "<< col <<" is "<< m_futureScore.GetScore(row, col) <<endl;
- }
+ }
}