<commit_before>{ stdenv, fetchurl, autoconf, automake, libtool, leptonica, libpng, libtiff }:

let
  majVersion = "3.02";
  version = "${majVersion}.02";

  f = lang : sha256 : let
      src = fetchurl {
        url = "http://tesseract-ocr.googlecode.com/files/tesseract-ocr-${majVersion}.${lang}.tar.gz";
        inherit sha256;
      };
    in 
      "tar xfvz ${src} -C $out/share/ --strip=1";

  extraLanguages = ''
    ${f "cat" "0d1smiv1b3k9ay2s05sl7q08mb3ln4w5iiiymv2cs8g8333z8jl9"}
    ${f "rus" "059336mkhsj9m3hwfb818xjlxkcdpy7wfgr62qwz65cx914xl709"}
    ${f "spa" "1c9iza5mbahd9pa7znnq8yv09v5kz3gbd2sarcgcgc1ps1jc437l"}
    ${f "nld" "162acxp1yb6gyki2is3ay2msalmfcsnrlsd9wml2ja05k94m6bjy"}
    ${f "eng" "1y5xf794n832s3lymzlsdm2s9nlrd2v27jjjp0fd9xp7c2ah4461"}
    ${f "slv" "0rqng43435cly32idxm1lvxkcippvc3xpxbfizwq5j0155ym00dr"}
  '';
in

stdenv.mkDerivation rec {
  name = "tesseract-${version}";

  src = fetchurl {
    url = "http://tesseract-ocr.googlecode.com/files/tesseract-ocr-${version}.tar.gz";
    sha256 = "0g81m9y4iydp7kgr56mlkvjdwpp3mb01q385yhdnyvra7z5kkk96";
  };

  buildInputs = [ autoconf automake libtool leptonica libpng libtiff ];

  preConfigure = ''
      ./autogen.sh
      substituteInPlace "configure" \
        --replace 'LIBLEPT_HEADERSDIR="/usr/local/include /usr/include"' \
                  'LIBLEPT_HEADERSDIR=${leptonica}/include'
  '';

  postInstall = extraLanguages;

  meta = {<commit_msg>Add Japanese to default tesseract languages<commit_after>{ stdenv, fetchurl, autoconf, automake, libtool, leptonica, libpng, libtiff }:

let
  majVersion = "3.02";
  version = "${majVersion}.02";

  f = lang : sha256 : let
      src = fetchurl {
        url = "http://tesseract-ocr.googlecode.com/files/tesseract-ocr-${majVersion}.${lang}.tar.gz";
        inherit sha256;
      };
    in
      "tar xfvz ${src} -C $out/share/ --strip=1";

  extraLanguages = ''
    ${f "cat" "0d1smiv1b3k9ay2s05sl7q08mb3ln4w5iiiymv2cs8g8333z8jl9"}
    ${f "rus" "059336mkhsj9m3hwfb818xjlxkcdpy7wfgr62qwz65cx914xl709"}
    ${f "spa" "1c9iza5mbahd9pa7znnq8yv09v5kz3gbd2sarcgcgc1ps1jc437l"}
    ${f "nld" "162acxp1yb6gyki2is3ay2msalmfcsnrlsd9wml2ja05k94m6bjy"}
    ${f "eng" "1y5xf794n832s3lymzlsdm2s9nlrd2v27jjjp0fd9xp7c2ah4461"}
    ${f "slv" "0rqng43435cly32idxm1lvxkcippvc3xpxbfizwq5j0155ym00dr"}
    ${f "jpn" "07v8pymd0iwyzh946lxylybda20gsw7p4fsb09jw147955x49gq9"}
  '';
in

stdenv.mkDerivation rec {
  name = "tesseract-${version}";

  src = fetchurl {
    url = "http://tesseract-ocr.googlecode.com/files/tesseract-ocr-${version}.tar.gz";
    sha256 = "0g81m9y4iydp7kgr56mlkvjdwpp3mb01q385yhdnyvra7z5kkk96";
  };

  buildInputs = [ autoconf automake libtool leptonica libpng libtiff ];

  preConfigure = ''
      ./autogen.sh
      substituteInPlace "configure" \
        --replace 'LIBLEPT_HEADERSDIR="/usr/local/include /usr/include"' \
                  'LIBLEPT_HEADERSDIR=${leptonica}/include'
  '';

  postInstall = extraLanguages;

  meta = {
{'fraction_non_alphanumeric': 0.1334453781512605, 'fraction_numerical': 0.10621848739495798, 'mean_word_length': 3.8947368421052633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '522243', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1331, 'n_words': 166}