1{
2 lib,
3 pkgs,
4 fetchPypi,
5 buildPythonPackage,
6 pythonOlder,
7 click,
8 joblib,
9 regex,
10 tqdm,
11
12 # preInstallCheck
13 nltk,
14
15 # nativeCheckInputs
16 matplotlib,
17 numpy,
18 pyparsing,
19 pytestCheckHook,
20 pytest-mock,
21}:
22
23buildPythonPackage rec {
24 pname = "nltk";
25 version = "3.9.1";
26 format = "setuptools";
27
28 disabled = pythonOlder "3.7";
29
30 src = fetchPypi {
31 inherit pname version;
32 hash = "sha256-h9EnvT3kvYmk+BJl5fpZyxsZmydEAXU3D3QX0rx66Gg=";
33 };
34
35 dependencies = [
36 click
37 joblib
38 regex
39 tqdm
40 ];
41
42 # Use new passthru function to pass dependencies required for testing
43 preInstallCheck = ''
44 export NLTK_DATA=${
45 nltk.dataDir (
46 d: with d; [
47 averaged-perceptron-tagger-eng
48 averaged-perceptron-tagger-rus
49 brown
50 cess-cat
51 cess-esp
52 conll2007
53 floresta
54 gutenberg
55 inaugural
56 indian
57 large-grammars
58 nombank-1-0
59 omw-1-4
60 pl196x
61 porter-test
62 ptb
63 punkt-tab
64 rte
65 sinica-treebank
66 stopwords
67 tagsets-json
68 treebank
69 twitter-samples
70 udhr
71 universal-tagset
72 wmt15-eval
73 wordnet
74 wordnet-ic
75 words
76 ]
77 )
78 }
79 '';
80
81 nativeCheckInputs = [
82 pytestCheckHook
83 matplotlib
84 numpy
85 pyparsing
86 pytest-mock
87
88 pkgs.which
89 ];
90
91 disabledTestPaths = [
92 "nltk/test/unit/test_downloader.py" # Touches network
93 ];
94
95 pythonImportsCheck = [ "nltk" ];
96
97 passthru = {
98 data = pkgs.nltk-data;
99 dataDir = pkgs.callPackage ./data-dir.nix { };
100 };
101
102 meta = with lib; {
103 description = "Natural Language Processing ToolKit";
104 mainProgram = "nltk";
105 homepage = "http://nltk.org/";
106 license = licenses.asl20;
107 maintainers = [ lib.maintainers.bengsparks ];
108 };
109}