1{ lib
2, fetchPypi
3, fetchFromGitHub
4, python
5, buildPythonPackage
6, absl-py
7, nltk
8, numpy
9, six
10, pytestCheckHook
11, pythonOlder
12}:
13let
14 testdata = fetchFromGitHub {
15 owner = "google-research";
16 repo = "google-research";
17 sparseCheckout = [ "rouge/testdata" ];
18 rev = "1d4d2f1aa6f2883a790d2ae46a6ee8ab150d8f31";
19 hash = "sha256-ojqk6U2caS7Xz4iGUC9aQVHrKb2QNvMlPuQAL/jJat0=";
20 };
21in buildPythonPackage rec {
22 pname = "rouge-score";
23 version = "0.1.2";
24 format = "setuptools";
25 disabled = pythonOlder "3.7";
26
27 src = fetchPypi {
28 pname = "rouge_score";
29 inherit version;
30 extension = "tar.gz";
31 hash = "sha256-x9TaJoPmjJq/ATXvkV1jpGZDZm+EjlWKG59+rRf/DwQ=";
32 };
33
34 # the tar file from pypi doesn't come with the test data
35 postPatch = ''
36 substituteInPlace rouge_score/test_util.py \
37 --replace 'os.path.join(os.path.dirname(__file__), "testdata")' '"${testdata}/rouge/testdata/"'
38 '';
39
40 propagatedBuildInputs = [ absl-py nltk numpy six ];
41
42 nativeCheckInputs = [ pytestCheckHook ];
43
44 doCheck = true;
45
46 disabledTests = [
47 # https://github.com/google-research/google-research/issues/1203
48 "testRougeLSumSentenceSplitting"
49 # tries to download external tokenizers via nltk
50 "testRougeLsumLarge"
51 ];
52
53 pythonImportsCheck = [ "rouge_score" ];
54
55 meta = {
56 description = "Python ROUGE Implementation";
57 homepage = "https://github.com/google-research/google-research/tree/master/rouge";
58 license = lib.licenses.asl20;
59 maintainers = with lib.maintainers; [ nviets ];
60 };
61}