Skip to content

Commit

Permalink
feat: add rust lang (#33)
Browse files Browse the repository at this point in the history
* feat: add rust lang

* fix: delete use file
  • Loading branch information
k4black authored Mar 1, 2024
1 parent a30cb9f commit a2e9524
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

This repository contains an unofficial `CodeBLEU` implementation that supports `Linux`, `MacOS` (incl. M-series) and `Windows`. It is available through `PyPI` and the `evaluate` library.

Available for: `Python`, `C`, `C#`, `C++`, `Java`, `JavaScript`, `PHP`, `Go`, `Ruby`.
Available for: `Python`, `C`, `C#`, `C++`, `Java`, `JavaScript`, `PHP`, `Go`, `Ruby`, `Rust`.

---

Expand Down
2 changes: 1 addition & 1 deletion evaluate_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pinned: false

This repository contains an unofficial `CodeBLEU` implementation that supports `Linux`, `MacOS` and `Windows`. It is available through `PyPI` and the `evaluate` library.

Available for: `Python`, `C`, `C#`, `C++`, `Java`, `JavaScript`, `PHP`, `Go`, `Ruby`.
Available for: `Python`, `C`, `C#`, `C++`, `Java`, `JavaScript`, `PHP`, `Go`, `Ruby`, `Rust`.

---

Expand Down
2 changes: 1 addition & 1 deletion evaluate_app/codebleu.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
should be a string with tokens separated by spaces.
references: list of reference for each prediction. Each
reference 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.
language: programming language in ['java','js','c_sharp','php','c','python','cpp','go','ruby','rust']. 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,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_codebleu.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ def test_exact_match_works_for_all_langs(lang: str) -> None:
("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"]),
("rust", ["fn foo ( x ) -> i32 { x }"], ["fn bar ( y ) -> i32 { y }"]),
],
)
def test_simple_cases_work_for_all_langs(lang: str, predictions: List[Any], references: List[Any]) -> None:
result = calc_codebleu(references, predictions, lang)
logging.debug(result)
assert result["codebleu"] == pytest.approx(0.6, 0.05)
assert result["codebleu"] == pytest.approx(0.6, 0.1)


def test_error_when_lang_not_supported() -> None:
Expand Down
25 changes: 0 additions & 25 deletions use.py

This file was deleted.

0 comments on commit a2e9524

Please sign in to comment.