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:
Diffstat (limited to 'scripts/training/cmert-0.5/score.c')
-rwxr-xr-xscripts/training/cmert-0.5/score.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/training/cmert-0.5/score.c b/scripts/training/cmert-0.5/score.c
new file mode 100755
index 000000000..8a02b8b6d
--- /dev/null
+++ b/scripts/training/cmert-0.5/score.c
@@ -0,0 +1,34 @@
+// $Id: score.c 1307 2007-03-14 22:22:36Z hieuhoang1972 $
+#include <math.h>
+#include <stdio.h>
+
+#include "score.h"
+
+int comps_n = 9;
+
+void comps_addto(int *comps1, int *comps2) {
+ int i;
+ for (i=0; i<comps_n; i++)
+ comps1[i] += comps2[i];
+}
+
+float compute_score(int *comps) {
+ float logbleu = 0.0, brevity;
+ int i;
+ int n = (comps_n-1)/2;
+
+ /*for (i=0; i<comps_n; i++)
+ fprintf(stderr, " %d", comps[i]);
+ fprintf(stderr, "\n");*/
+
+ for (i=0; i<n; i++) {
+ if (comps[2*i] == 0)
+ return 0.0;
+ logbleu += log(comps[2*i])-log(comps[2*i+1]);
+ }
+ logbleu /= n;
+ brevity = 1.0-(float)comps[comps_n-1]/comps[1]; // comps[comps_n-1] is the ref length, comps[1] is the test length
+ if (brevity < 0.0)
+ logbleu += brevity;
+ return exp(logbleu);
+}