2015-04-16 03:34:35 +02:00
|
|
|
{ stdenv, fetchFromGitHub, fetchurl, pythonPackages, curl }:
|
2014-05-28 12:12:26 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
getmodel = name: sha256: {
|
2016-01-25 20:08:34 +01:00
|
|
|
inherit name;
|
2014-05-28 12:12:26 +02:00
|
|
|
src = fetchurl {
|
2015-04-16 03:34:35 +02:00
|
|
|
url = "http://www.tmbdev.net/ocropy/${name}";
|
2014-05-28 12:12:26 +02:00
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
models = [
|
|
|
|
(getmodel "en-default.pyrnn.gz"
|
|
|
|
"1xyi3k3p81mfw0491gb1haisazfyi2i18f1wjs1m34ak39qfqjdp")
|
|
|
|
(getmodel "fraktur.pyrnn.gz"
|
|
|
|
"1wlwvxn91ilgmlri1hj81arl3mbzxc24ycdnkf5icq4hdi4c6y8b")
|
|
|
|
];
|
2015-04-16 03:34:35 +02:00
|
|
|
|
2014-05-28 12:12:26 +02:00
|
|
|
in
|
2016-02-19 13:12:11 +01:00
|
|
|
pythonPackages.buildPythonApplication rec {
|
2014-05-28 12:12:26 +02:00
|
|
|
name = "ocropus-${version}";
|
2017-09-06 13:45:49 +02:00
|
|
|
version = "20170811";
|
2014-05-28 12:12:26 +02:00
|
|
|
|
2015-04-16 03:34:35 +02:00
|
|
|
src = fetchFromGitHub {
|
2017-09-06 13:45:49 +02:00
|
|
|
sha256 = "0qx0d8yj0w66qglkrmfavp5dh1sky72njfaqii7bnrpv5n4j3q39";
|
|
|
|
rev = "ae84a8edaf0b76135f749ba66fc30c272d0726d0";
|
2015-04-16 03:34:35 +02:00
|
|
|
repo = "ocropy";
|
|
|
|
owner = "tmbdev";
|
2014-05-28 12:12:26 +02:00
|
|
|
};
|
|
|
|
|
2014-05-28 12:39:54 +02:00
|
|
|
propagatedBuildInputs = with pythonPackages; [ curl numpy scipy pillow
|
2014-05-29 10:13:31 +02:00
|
|
|
matplotlib beautifulsoup4 pygtk lxml ];
|
2014-05-28 12:12:26 +02:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
2015-11-20 19:58:38 +01:00
|
|
|
|
2014-05-28 12:12:26 +02:00
|
|
|
preConfigure = with stdenv.lib; ''
|
2015-11-20 19:58:38 +01:00
|
|
|
${concatStrings (map (x: "cp -R ${x.src} models/`basename ${x.name}`;")
|
2015-04-16 03:34:35 +02:00
|
|
|
models)}
|
|
|
|
|
2017-09-06 13:45:49 +02:00
|
|
|
substituteInPlace ocrolib/common.py --replace /usr/local $out
|
|
|
|
substituteInPlace ocrolib/default.py --replace /usr/local $out
|
2015-04-16 03:34:35 +02:00
|
|
|
'';
|
2014-05-29 09:45:12 +02:00
|
|
|
|
2015-11-20 19:58:38 +01:00
|
|
|
doCheck = false; # fails
|
2015-04-16 03:34:35 +02:00
|
|
|
checkPhase = ''
|
2015-05-31 17:52:41 +02:00
|
|
|
patchShebangs .
|
2015-04-16 03:34:35 +02:00
|
|
|
substituteInPlace ./run-test \
|
|
|
|
--replace 'ocropus-rpred' 'ocropus-rpred -Q $NIX_BUILD_CORES'
|
|
|
|
PATH=".:$PATH" ./run-test
|
2014-05-28 12:12:26 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Open source document analysis and OCR system";
|
|
|
|
license = licenses.asl20;
|
2015-04-16 03:34:35 +02:00
|
|
|
homepage = https://github.com/tmbdev/ocropy/;
|
2018-01-16 22:59:13 +01:00
|
|
|
maintainers = with maintainers; [ domenkozar viric ];
|
2014-05-28 12:12:26 +02:00
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|