summaryrefslogtreecommitdiff
blob: b3165b5e4a61eb38bae6713d33ecb5dfd85fbe8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

PYTHON_COMPAT=( python3_6 )
PYTHON_REQ_USE="sqlite,tk?,xml(+)"

inherit distutils-r1

DESCRIPTION="Natural Language Toolkit"
HOMEPAGE="https://www.nltk.org/ https://github.com/nltk/nltk/"
SRC_URI="https://github.com/nltk/nltk/archive/${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~x86-solaris"
IUSE="tk"

RDEPEND="dev-python/six[${PYTHON_USEDEP}]"
BDEPEND="
	test? (
		dev-python/nltk-data
		dev-python/numpy[${PYTHON_USEDEP}]
		dev-python/pyparsing[${PYTHON_USEDEP}]
		dev-python/twython[${PYTHON_USEDEP}]
		sci-libs/scikits_learn[${PYTHON_USEDEP}]
		sci-libs/scipy[${PYTHON_USEDEP}]
	)"
PDEPEND="dev-python/nltk-data"

distutils_enable_tests nose

PATCHES=(
	"${FILESDIR}"/nltk-3.4.5-corpus-tests.patch
)

src_prepare() {
	# requires unpackaged pycrfsuite
	sed -i -e '/>>>/s@$@ # doctest: +SKIP@' nltk/tag/crf.py || die
	# replace fetching from network with duplicate file URL
	sed -e 's@https://raw.githubusercontent.com/nltk/nltk/develop/nltk/test/toy.cfg@nltk:grammars/sample_grammars/toy.cfg@' \
		-i nltk/test/data.doctest || die
	# requires X and hangs in Xvfb
	sed -e 's:test_plot:_&:' \
		-i nltk/test/unit/test_cfd_mutation.py || die

	distutils-r1_src_prepare
}

src_test() {
	cd nltk/test || die
	distutils-r1_src_test
}

python_test() {
	"${EPYTHON}" runtests.py -v || die "Tests failed with ${EPYTHON}"
}