1{ 2 lib, 3 fetchPypi, 4 fetchFromGitHub, 5 buildPythonPackage, 6 setuptools, 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 pyproject = true; 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-fail \ 40 'os.path.join(os.path.dirname(__file__), "testdata")' \ 41 '"${testdata}/rouge/testdata/"' 42 ''; 43 44 build-system = [ setuptools ]; 45 46 dependencies = [ 47 absl-py 48 nltk 49 numpy 50 six 51 ]; 52 53 nativeCheckInputs = [ pytestCheckHook ]; 54 55 disabledTests = [ 56 # https://github.com/google-research/google-research/issues/1203 57 "testRougeLSumSentenceSplitting" 58 # tries to download external tokenizers via nltk 59 "testRougeLsumLarge" 60 ]; 61 62 pythonImportsCheck = [ "rouge_score" ]; 63 64 meta = { 65 description = "Python ROUGE Implementation"; 66 homepage = "https://github.com/google-research/google-research/tree/master/rouge"; 67 license = lib.licenses.asl20; 68 maintainers = with lib.maintainers; [ nviets ]; 69 }; 70}