summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorVictor Chahuneau <vchahune@cs.cmu.edu>2012-07-25 23:57:05 -0400
committerVictor Chahuneau <vchahune@cs.cmu.edu>2012-07-25 23:57:05 -0400
commit0ee6610cf1c0ab342e438879b8a5fe4046e33189 (patch)
tree2cc2c8b8363554a442d9c76dc984f13621ac1dd1 /python
parent070e7fbbacd70dd916a95c1ab08b0113ec221c30 (diff)
Character error rate metric
- [python] cdec.score.CER - Cleanup .gitignore
Diffstat (limited to 'python')
-rw-r--r--python/cdec/score.py2
-rw-r--r--python/src/_cdec.cpp58
-rw-r--r--python/src/mteval.pxi1
3 files changed, 46 insertions, 15 deletions
diff --git a/python/cdec/score.py b/python/cdec/score.py
index d9486ef2..22257774 100644
--- a/python/cdec/score.py
+++ b/python/cdec/score.py
@@ -1 +1 @@
-from _cdec import BLEU, TER, Metric
+from _cdec import BLEU, TER, CER, Metric
diff --git a/python/src/_cdec.cpp b/python/src/_cdec.cpp
index 6d704b1d..44cd6568 100644
--- a/python/src/_cdec.cpp
+++ b/python/src/_cdec.cpp
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.16 on Mon Jul 23 19:56:55 2012 */
+/* Generated by Cython 0.16 on Wed Jul 25 23:56:10 2012 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -1761,13 +1761,14 @@ static char __pyx_k_49[] = "cannot initialize weights with %s";
static char __pyx_k_50[] = "#";
static char __pyx_k_53[] = "Cannot translate input type %s";
static char __pyx_k_56[] = "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi";
-static char __pyx_k_61[] = "/Users/vchahun/Sandbox/cdec/python/src/_cdec.pyx";
+static char __pyx_k_62[] = "/Users/vchahun/Sandbox/cdec/python/src/_cdec.pyx";
static char __pyx_k__a[] = "a";
static char __pyx_k__e[] = "e";
static char __pyx_k__f[] = "f";
static char __pyx_k__i[] = "i";
static char __pyx_k__k[] = "k";
static char __pyx_k__pb[] = "pb";
+static char __pyx_k__CER[] = "CER";
static char __pyx_k__TER[] = "TER";
static char __pyx_k__cat[] = "cat";
static char __pyx_k__dot[] = "dot";
@@ -1874,11 +1875,12 @@ static PyObject *__pyx_kp_s_49;
static PyObject *__pyx_kp_s_50;
static PyObject *__pyx_kp_s_53;
static PyObject *__pyx_kp_s_56;
-static PyObject *__pyx_kp_s_61;
+static PyObject *__pyx_kp_s_62;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__BLEU;
+static PyObject *__pyx_n_s__CER;
static PyObject *__pyx_n_s__Exception;
static PyObject *__pyx_n_s__IBM_BLEU;
static PyObject *__pyx_n_s__IndexError;
@@ -1982,9 +1984,10 @@ static PyObject *__pyx_k_tuple_54;
static PyObject *__pyx_k_tuple_57;
static PyObject *__pyx_k_tuple_58;
static PyObject *__pyx_k_tuple_59;
+static PyObject *__pyx_k_tuple_60;
static PyObject *__pyx_k_codeobj_37;
static PyObject *__pyx_k_codeobj_55;
-static PyObject *__pyx_k_codeobj_60;
+static PyObject *__pyx_k_codeobj_61;
/* "_cdec.pyx":6
* cimport decoder
@@ -26164,11 +26167,12 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0},
{&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0},
{&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0},
- {&__pyx_kp_s_61, __pyx_k_61, sizeof(__pyx_k_61), 0, 0, 1, 0},
+ {&__pyx_kp_s_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 1, 0},
{&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
{&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
{&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
{&__pyx_n_s__BLEU, __pyx_k__BLEU, sizeof(__pyx_k__BLEU), 0, 0, 1, 1},
+ {&__pyx_n_s__CER, __pyx_k__CER, sizeof(__pyx_k__CER), 0, 0, 1, 1},
{&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1},
{&__pyx_n_s__IBM_BLEU, __pyx_k__IBM_BLEU, sizeof(__pyx_k__IBM_BLEU), 0, 0, 1, 1},
{&__pyx_n_s__IndexError, __pyx_k__IndexError, sizeof(__pyx_k__IndexError), 0, 0, 1, 1},
@@ -26565,6 +26569,7 @@ static int __Pyx_InitCachedConstants(void) {
*
* BLEU = Scorer('IBM_BLEU') # <<<<<<<<<<<<<<
* TER = Scorer('TER')
+ * CER = Scorer('CER')
*/
__pyx_k_tuple_57 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_57);
@@ -26577,6 +26582,7 @@ static int __Pyx_InitCachedConstants(void) {
*
* BLEU = Scorer('IBM_BLEU')
* TER = Scorer('TER') # <<<<<<<<<<<<<<
+ * CER = Scorer('CER')
*/
__pyx_k_tuple_58 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_58)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_58);
@@ -26585,6 +26591,18 @@ static int __Pyx_InitCachedConstants(void) {
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__TER));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_58));
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":192
+ * BLEU = Scorer('IBM_BLEU')
+ * TER = Scorer('TER')
+ * CER = Scorer('CER') # <<<<<<<<<<<<<<
+ */
+ __pyx_k_tuple_59 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_59)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_59);
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__CER));
+ PyTuple_SET_ITEM(__pyx_k_tuple_59, 0, ((PyObject *)__pyx_n_s__CER));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CER));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59));
+
/* "_cdec.pyx":28
* class ParseFailed(Exception): pass
*
@@ -26592,25 +26610,25 @@ static int __Pyx_InitCachedConstants(void) {
* for key, value in config.items():
* if isinstance(value, dict):
*/
- __pyx_k_tuple_59 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_59);
+ __pyx_k_tuple_60 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_60);
__Pyx_INCREF(((PyObject *)__pyx_n_s__config));
- PyTuple_SET_ITEM(__pyx_k_tuple_59, 0, ((PyObject *)__pyx_n_s__config));
+ PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_n_s__config));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__config));
__Pyx_INCREF(((PyObject *)__pyx_n_s__key));
- PyTuple_SET_ITEM(__pyx_k_tuple_59, 1, ((PyObject *)__pyx_n_s__key));
+ PyTuple_SET_ITEM(__pyx_k_tuple_60, 1, ((PyObject *)__pyx_n_s__key));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__key));
__Pyx_INCREF(((PyObject *)__pyx_n_s__value));
- PyTuple_SET_ITEM(__pyx_k_tuple_59, 2, ((PyObject *)__pyx_n_s__value));
+ PyTuple_SET_ITEM(__pyx_k_tuple_60, 2, ((PyObject *)__pyx_n_s__value));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__value));
__Pyx_INCREF(((PyObject *)__pyx_n_s__name));
- PyTuple_SET_ITEM(__pyx_k_tuple_59, 3, ((PyObject *)__pyx_n_s__name));
+ PyTuple_SET_ITEM(__pyx_k_tuple_60, 3, ((PyObject *)__pyx_n_s__name));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
__Pyx_INCREF(((PyObject *)__pyx_n_s__info));
- PyTuple_SET_ITEM(__pyx_k_tuple_59, 4, ((PyObject *)__pyx_n_s__info));
+ PyTuple_SET_ITEM(__pyx_k_tuple_60, 4, ((PyObject *)__pyx_n_s__info));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__info));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59));
- __pyx_k_codeobj_60 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_61, __pyx_n_s___make_config, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60));
+ __pyx_k_codeobj_61 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_62, __pyx_n_s___make_config, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
@@ -26831,6 +26849,7 @@ PyMODINIT_FUNC PyInit__cdec(void)
*
* BLEU = Scorer('IBM_BLEU') # <<<<<<<<<<<<<<
* TER = Scorer('TER')
+ * CER = Scorer('CER')
*/
__pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_57), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
@@ -26841,12 +26860,23 @@ PyMODINIT_FUNC PyInit__cdec(void)
*
* BLEU = Scorer('IBM_BLEU')
* TER = Scorer('TER') # <<<<<<<<<<<<<<
+ * CER = Scorer('CER')
*/
__pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_58), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
if (PyObject_SetAttr(__pyx_m, __pyx_n_s__TER, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":192
+ * BLEU = Scorer('IBM_BLEU')
+ * TER = Scorer('TER')
+ * CER = Scorer('CER') # <<<<<<<<<<<<<<
+ */
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_59), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__CER, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
/* "_cdec.pyx":22
* include "mteval.pxi"
*
diff --git a/python/src/mteval.pxi b/python/src/mteval.pxi
index f67f4f04..52d2abc6 100644
--- a/python/src/mteval.pxi
+++ b/python/src/mteval.pxi
@@ -189,3 +189,4 @@ cdef class Metric:
BLEU = Scorer('IBM_BLEU')
TER = Scorer('TER')
+CER = Scorer('CER')