Spaces:
Runtime error
Runtime error
Upload codebleu.py
#2
by fasterinnerlooper - opened
40 unmodified lines414243444546475 unmodified lines5354555657585953 unmodified lines11311411511611711811940 unmodified linesshould be a string with tokens separated by spaces.references: list of reference for each prediction. Eachreference should be a string with tokens separated by spaces.language: programming language in ['java','js','c_sharp','php','c','python','cpp'].weights: tuple of 4 floats to use as weights for scores. Defaults to (0.25, 0.25, 0.25, 0.25).Returns:codebleu: resulting `CodeBLEU` score,5 unmodified lines>>> metric = evaluate.load("k4black/codebleu")>>> ref = "def sum ( first , second ) :\n return second + first">>> pred = "def add ( a , b ) :\n return a + b">>> results = metric.compute(references=[ref], predictions=[pred], language="python")>>> print(results)"""53 unmodified linesreturn self.codebleu_package.calc_codebleu(references=references,predictions=predictions,lang=lang,weights=weights,tokenizer=tokenizer,)40 unmodified lines414243444546475 unmodified lines5354555657585953 unmodified lines11311411511611711811940 unmodified linesshould be a string with tokens separated by spaces.references: list of reference for each prediction. Eachreference should be a string with tokens separated by spaces.language: programming language in ['java','js','c_sharp','php','c','python','cpp']. Please note that, due to the way Datasets works, the number of entities in the language array must match the number of entries in the predictions and references arrays, but only the first value from the languages array will be used. This means that you will not be able to compute a metric for different langauges at the same time, but mst do them as sequential calls to CodeBleu.weights: tuple of 4 floats to use as weights for scores. Defaults to (0.25, 0.25, 0.25, 0.25).Returns:codebleu: resulting `CodeBLEU` score,5 unmodified lines>>> metric = evaluate.load("k4black/codebleu")>>> ref = "def sum ( first , second ) :\n return second + first">>> pred = "def add ( a , b ) :\n return a + b">>> results = metric.compute(references=[ref], predictions=[pred], language=["python"])>>> print(results)"""53 unmodified linesreturn self.codebleu_package.calc_codebleu(references=references,predictions=predictions,lang=lang[0],weights=weights,tokenizer=tokenizer,)
codebleu.py+3-3