diff --git a/README.md b/README.md index 510e310..dec0ca7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This repository contains an unofficial `CodeBLEU` implementation that supports ` The code is based on the original [CodeXGLUE/CodeBLEU](https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/code-to-code-trans/evaluator/CodeBLEU) and updated version by [XLCoST/CodeBLEU](https://github.com/reddy-lab-code-research/XLCoST/tree/main/code/translation/evaluator/CodeBLEU). It has been refactored, tested, built for macOS, and multiple improvements have been made to enhance usability -Available for: `Python`, `C`, `C#`, `C++`, `Java`, `JavaScript`, `PHP`. +Available for: `Python`, `C`, `C#`, `C++`, `Java`, `JavaScript`, `PHP`, `Go` and `Ruby`. --- diff --git a/codebleu/codebleu.py b/codebleu/codebleu.py index 2e9adbf..f1beb86 100644 --- a/codebleu/codebleu.py +++ b/codebleu/codebleu.py @@ -7,7 +7,7 @@ from . import bleu, dataflow_match, syntax_match, weighted_ngram_match PACKAGE_DIR = Path(__file__).parent -AVAILABLE_LANGS = ["java", "javascript", "c_sharp", "php", "c", "cpp", "python"] # keywords available +AVAILABLE_LANGS = ["java", "javascript", "c_sharp", "php", "c", "cpp", "python", "go", "ruby"] # keywords available def calc_codebleu( diff --git a/codebleu/keywords/go.txt b/codebleu/keywords/go.txt new file mode 100644 index 0000000..893da4a --- /dev/null +++ b/codebleu/keywords/go.txt @@ -0,0 +1,27 @@ +break +default +func +interface +select +case +defer +go +map +struct +chan +else +goto +package +switch +const +fallthrough +if +range +type +continue +for +import +return +var +false +true diff --git a/codebleu/keywords/python.txt b/codebleu/keywords/python.txt index 08c8222..646b998 100644 --- a/codebleu/keywords/python.txt +++ b/codebleu/keywords/python.txt @@ -33,3 +33,6 @@ try while with yield +match +case +type diff --git a/codebleu/keywords/ruby.txt b/codebleu/keywords/ruby.txt new file mode 100644 index 0000000..c26ade8 --- /dev/null +++ b/codebleu/keywords/ruby.txt @@ -0,0 +1,41 @@ +__ENCODING__ +__LINE__ +__FILE__ +BEGIN +END +alias +and +begin +break +case +class +def +defined? +do +else +elsif +end +ensure +false +for +if +in +module +next +nil +not +or +redo +rescue +retry +return +self +super +then +true +undef +unless +until +when +while +yield diff --git a/tests/test_codebleu.py b/tests/test_codebleu.py index 35414be..31c0855 100644 --- a/tests/test_codebleu.py +++ b/tests/test_codebleu.py @@ -39,6 +39,8 @@ def test_exact_match_works_for_all_langs(lang: str) -> None: ("c_sharp", ["public int foo ( int x ) { return x }"], ["public int bar ( int y ) {\n return y\n}"]), ("cpp", ["int foo ( int x ) { return x }"], ["int bar ( int y ) {\n return y\n}"]), ("php", ["function foo ( x ) { return x }"], ["function bar ( y ) {\n return y\n}"]), + ("go", ["func foo ( x ) { return x }"], ["func bar ( y ) {\n return y\n}"]), + ("ruby", ["def foo ( x ) :\n return x"], ["def bar ( y ) :\n return y"]), ], ) def test_simple_cases_work_for_all_langs(lang: str, predictions: List[Any], references: List[Any]) -> None: