git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #37784 from ixxie/wordfreq-and-deps

pythonPackages.wordfreq and dependencies

commitaddb9852750551428a549e696b28ce644e1aebc2 authorRobert Schütz <rschuetz17@gmail.com> dateThu 5 Apr 2018, 10:38 (9 years ago) parent554b8331f82712
6 files changed+183
pkgs/development/python-modules/jieba/default.nix+33 pkgs/development/python-modules/langcodes/default.nix+34 pkgs/development/python-modules/marisa-trie/default.nix+34 pkgs/development/python-modules/mecab-python3/default.nix+24 pkgs/development/python-modules/wordfreq/default.nix+48 pkgs/top-level/python-packages.nix+10
pkgs/development/python-modules/jieba/default.nixnew file+33
@@ -0,0 +1,33 @@
1+{ lib, buildPythonPackage, fetchFromGitHub, glibcLocales, python, isPy3k }:
2+
3+buildPythonPackage rec {
4+ pname = "jieba";
5+ version = "0.39";
6+
7+ # no tests in PyPI tarball
8+ src = fetchFromGitHub {
9+ owner = "fxsjy";
10+ repo = pname;
11+ rev = "v${version}";
12+ sha256 = "0hbq0l1jbgcvm58qg4p37im4jl5a9igvq3wlhlk22pmbkbvqqgzs";
13+ };
14+
15+ checkInputs = [ glibcLocales ];
16+
17+ # UnicodeEncodeError
18+ doCheck = isPy3k;
19+
20+ # Citing https://github.com/fxsjy/jieba/issues/384: "testcases is in a mess"
21+ # So just picking random ones that currently work
22+ checkPhase = ''
23+ export LC_ALL=en_US.UTF-8
24+ ${python.interpreter} test/test.py
25+ ${python.interpreter} test/test_tokenize.py
26+ '';
27+
28+ meta = with lib; {
29+ description = "Chinese Words Segementation Utilities";
30+ homepage = https://github.com/fxsjy/jieba;
31+ license = licenses.mit;
32+ };
33+}
pkgs/development/python-modules/langcodes/default.nixnew file+34
@@ -0,0 +1,34 @@
1+{ lib
2+, buildPythonPackage
3+, marisa-trie
4+, pythonOlder
5+, fetchPypi
6+, nose
7+}:
8+
9+buildPythonPackage rec {
10+ pname = "langcodes";
11+ version = "1.4.1";
12+
13+ src = fetchPypi {
14+ inherit pname version;
15+ sha256 = "1axdiva2qglsjmnx2ak7i6hm0yhp6kbc4lcsgn8ckwy0nq1z3kr2";
16+ };
17+
18+ propagatedBuildInputs = [ marisa-trie ];
19+
20+ disabled = pythonOlder "3.3";
21+
22+ checkInputs = [ nose ];
23+
24+ checkPhase = ''
25+ nosetests
26+ '';
27+
28+ meta = with lib; {
29+ description = "A toolkit for working with and comparing the standardized codes for languages, such as ‘en’ for English or ‘es’ for Spanish";
30+ homepage = http://github.com/LuminosoInsight/langcodes;
31+ license = licenses.mit;
32+ maintainers = with maintainers; [ ixxie ];
33+ };
34+}
pkgs/development/python-modules/marisa-trie/default.nixnew file+34
@@ -0,0 +1,34 @@
1+{ lib
2+, buildPythonPackage
3+, fetchPypi
4+, pytestrunner
5+, pytest
6+, hypothesis
7+}:
8+
9+buildPythonPackage rec {
10+ pname = "marisa-trie";
11+ version = "0.7.4";
12+
13+ src = fetchPypi {
14+ inherit pname version;
15+ sha256 = "1n4pxnaranbh3x2fcqxwh8j1z2918vy7i4q1z4jn75m9rkm5h8ia";
16+ };
17+
18+ postPatch = ''
19+ substituteInPlace setup.py \
20+ --replace "hypothesis==" "hypothesis>="
21+ '';
22+
23+ nativeBuildInputs = [ pytestrunner ];
24+
25+ checkInputs = [ pytest hypothesis ];
26+
27+ meta = with lib; {
28+ description = "Static memory-efficient Trie-like structures for Python (2.x and 3.x) based on marisa-trie C++ library";
29+ longDescription = "There are official SWIG-based Python bindings included in C++ library distribution; this package provides alternative Cython-based pip-installable Python bindings.";
30+ homepage = https://github.com/kmike/marisa-trie;
31+ license = licenses.mit;
32+ maintainers = with maintainers; [ ixxie ];
33+ };
34+}
pkgs/development/python-modules/mecab-python3/default.nixnew file+24
@@ -0,0 +1,24 @@
1+{ lib
2+, buildPythonPackage
3+, mecab
4+, fetchPypi
5+}:
6+
7+buildPythonPackage rec {
8+ pname = "mecab-python3";
9+ version = "0.7";
10+
11+ src = fetchPypi {
12+ inherit pname version;
13+ sha256 = "007dg4f5fby2yl7cc44x6xwvcrf2w2ifmn0rmk56ss33mhs8l6qy";
14+ };
15+
16+ propagatedBuildInputs = [ mecab ];
17+
18+ meta = with lib; {
19+ description = "A python wrapper for mecab: Morphological Analysis engine";
20+ homepage = https://github.com/LuminosoInsight/wordfreq/;
21+ license = licenses.bsd0;
22+ maintainers = with maintainers; [ ixxie ];
23+ };
24+}
pkgs/development/python-modules/wordfreq/default.nixnew file+48
@@ -0,0 +1,48 @@
1+{ lib
2+, buildPythonPackage
3+, regex
4+, langcodes
5+, ftfy
6+, msgpack
7+, mecab-python3
8+, jieba
9+, nose
10+, pythonOlder
11+, fetchFromGitHub
12+}:
13+
14+buildPythonPackage rec {
15+ pname = "wordfreq";
16+ version = "2.0";
17+
18+ src = fetchFromGitHub {
19+ owner = "LuminosoInsight";
20+ repo = "wordfreq";
21+ rev = "e3a1b470d9f8e0d82e9f179ffc41abba434b823b";
22+ sha256 = "1wjkhhj7nxfnrghwvmvwc672s30lp4b7yr98gxdxgqcq6wdshxwv";
23+ };
24+
25+ checkInputs = [ nose ];
26+
27+ checkPhase = ''
28+ # These languages require additional dictionaries
29+ nosetests -e test_japanese -e test_korean -e test_languages
30+ '';
31+
32+ propagatedBuildInputs = [ regex langcodes ftfy msgpack mecab-python3 jieba ];
33+
34+ # patch to relax version requirements for regex
35+ # dependency to prevent break in upgrade
36+ postPatch = ''
37+ substituteInPlace setup.py --replace "regex ==" "regex >="
38+ '';
39+
40+ disabled = pythonOlder "3";
41+
42+ meta = with lib; {
43+ description = "A library for looking up the frequencies of words in many languages, based on many sources of data";
44+ homepage = https://github.com/LuminosoInsight/wordfreq/;
45+ license = licenses.mit;
46+ maintainers = with maintainers; [ ixxie ];
47+ };
48+}
pkgs/top-level/python-packages.nix+10
@@ -4988,6 +4988,8 @@ in {
49884988
49894989 jdcal = callPackage ../development/python-modules/jdcal { };
49904990
4991+ jieba = callPackage ../development/python-modules/jieba { };
4992+
49914993 internetarchive = callPackage ../development/python-modules/internetarchive {};
49924994
49934995 JPype1 = callPackage ../development/python-modules/JPype1 {};
@@ -9177,6 +9179,8 @@ in {
91779179 marisa = pkgs.marisa;
91789180 };
91799181
9182+ marisa-trie = callPackage ../development/python-modules/marisa-trie { };
9183+
91809184 markupsafe = buildPythonPackage rec {
91819185 name = "markupsafe-${version}";
91829186 version = "1.0";
@@ -10733,6 +10737,8 @@ in {
1073310737 };
1073410738 };
1073510739
10740+ langcodes = callPackage ../development/python-modules/langcodes { };
10741+
1073610742 livestreamer = buildPythonPackage rec {
1073710743 version = "1.12.2";
1073810744 name = "livestreamer-${version}";
@@ -11320,6 +11326,8 @@ in {
1132011326 propagatedBuildInputs = with self; [ six requests ];
1132111327 };
1132211328
11329+ mecab-python3 = callPackage ../development/python-modules/mecab-python3 { };
11330+
1132311331 mox3 = buildPythonPackage rec {
1132411332 name = "mox3-${version}";
1132511333 version = "0.23.0";
@@ -17098,6 +17106,8 @@ EOF
1709817106
1709917107 widgetsnbextension = callPackage ../development/python-modules/widgetsnbextension { };
1710017108
17109+ wordfreq = callPackage ../development/python-modules/wordfreq { };
17110+
1710117111 magic-wormhole = callPackage ../development/python-modules/magic-wormhole { };
1710217112
1710317113 magic-wormhole-transit-relay = callPackage ../development/python-modules/magic-wormhole-transit-relay { };