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