From e21e27f1a62413814e0e9a8d0f97a99f25fe9068 Mon Sep 17 00:00:00 2001 From: nviets Date: Wed, 10 May 2023 08:31:40 -0500 Subject: [PATCH] python3Packages.rouge-score: init at 0.1.2 (#229208) Co-authored-by: Sandro Co-authored-by: nviets --- .../python-modules/rouge-score/default.nix | 61 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 63 insertions(+) create mode 100644 pkgs/development/python-modules/rouge-score/default.nix diff --git a/pkgs/development/python-modules/rouge-score/default.nix b/pkgs/development/python-modules/rouge-score/default.nix new file mode 100644 index 000000000000..09d2bcc1dc81 --- /dev/null +++ b/pkgs/development/python-modules/rouge-score/default.nix @@ -0,0 +1,61 @@ +{ lib +, fetchPypi +, fetchFromGitHub +, python +, buildPythonPackage +, absl-py +, nltk +, numpy +, six +, pytestCheckHook +, pythonOlder +}: +let + testdata = fetchFromGitHub { + owner = "google-research"; + repo = "google-research"; + sparseCheckout = [ "rouge/testdata" ]; + rev = "1d4d2f1aa6f2883a790d2ae46a6ee8ab150d8f31"; + hash = "sha256-ojqk6U2caS7Xz4iGUC9aQVHrKb2QNvMlPuQAL/jJat0="; + }; +in buildPythonPackage rec { + pname = "rouge-score"; + version = "0.1.2"; + format = "setuptools"; + disabled = pythonOlder "3.7"; + + src = fetchPypi { + pname = "rouge_score"; + inherit version; + extension = "tar.gz"; + hash = "sha256-x9TaJoPmjJq/ATXvkV1jpGZDZm+EjlWKG59+rRf/DwQ="; + }; + + # the tar file from pypi doesn't come with the test data + postPatch = '' + substituteInPlace rouge_score/test_util.py \ + --replace 'os.path.join(os.path.dirname(__file__), "testdata")' '"${testdata}/rouge/testdata/"' + ''; + + propagatedBuildInputs = [ absl-py nltk numpy six ]; + + nativeCheckInputs = [ pytestCheckHook ]; + + doCheck = true; + + disabledTests = [ + # https://github.com/google-research/google-research/issues/1203 + "testRougeLSumSentenceSplitting" + # tries to download external tokenizers via nltk + "testRougeLsumLarge" + ]; + + pythonImportsCheck = [ "rouge_score" ]; + + meta = { + description = "Python ROUGE Implementation"; + homepage = "https://github.com/google-research/google-research/tree/master/rouge"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ nviets ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 7e3021fe6a9b..566be5f269c5 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10550,6 +10550,8 @@ self: super: with self; { ropper = callPackage ../development/python-modules/ropper { }; + rouge-score = callPackage ../development/python-modules/rouge-score { }; + routes = callPackage ../development/python-modules/routes { }; rova = callPackage ../development/python-modules/rova { };