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