<commit_before>/* hunspell dictionaries */

{ stdenv, fetchurl, unzip }:

with stdenv.lib;

let

  mkDict =
  { name, src, meta, readmeFile, dictFileName, ... }:
  let
    isFrench = hasSuffix "fr_" dictFileName;
    isItaly = hasSuffix "it_" dictFileName;
    isSpanish = hasSuffix "es_" dictFileName;
    isEnglish = hasSuffix "en_" dictFileName;
  in
  stdenv.mkDerivation rec {
    inherit name src meta;
    buildInputs = [ unzip ];
    sourceRoot = ".";
    phases = "unpackPhase installPhase" + (if isItaly then "patchPhase" else "");
    unpackCmd = "unzip $src ${readmeFile} ${dictFileName}.dic ${dictFileName}.aff";
    prePatch = if isItaly then ''
    # Fix dic file empty lines (FS#22275)
    sed '/^\/$/d' -i it_IT.dic
    '' else "";

    installPhase = ''
      # hunspell dicts
      install -dm755 "$out/share/hunspell"
      install -m644 ${dictFileName}.dic "$out/share/hunspell/"
      install -m644 ${dictFileName}.aff "$out/share/hunspell/"
      # myspell dicts symlinks
      install -dm755 "$out/share/myspell/dicts"
      ln -sv "$out/share/hunspell/${dictFileName}.dic" "$out/share/myspell/dicts/"
      ln -sv "$out/share/hunspell/${dictFileName}.aff" "$out/share/myspell/dicts/"
      # docs
      install -dm755 "$out/share/doc"
      install -m644 ${readmeFile} $out/share/doc/${name}.txt
    '';
  };

  mkDictFromRedIRIS =
    { shortName, shortDescription, dictFileName, src }:
    mkDict rec {
      inherit src dictFileName;
      version = "0.7";
      name = "hunspell-dict-${shortName}-rediris-${version}";
      readmeFile = "README.txt";
      meta = with stdenv.lib; {
        description = "Hunspell dictionary for ${shortDescription} from RedIRIS";
        homepage = https://forja.rediris.es/projects/rla-es/;
        license = with licenses; [ gpl3 lgpl3 mpl11 ];
        maintainers = with maintainers; [ renzo ];
        platforms = platforms.all;
      };
    };

  mkDictFromDicollecte =
    { shortName, shortDescription, longDescription, dictFileName }:
    mkDict rec {
      inherit dictFileName;
      version = "5.2";
      name = "hunspell-dict-${shortName}-dicollecte-${version}";
      readmeFile = "README_dict_fr.txt";
      src = fetchurl {
         url = "http://www.dicollecte.org/download/fr/hunspell-french-dictionaries-v${version}.zip";
         sha256 = "c5863f7592a8c4defe8b4ed2b3b45f6f10ef265d34ae9881c1f3bbb3b80bdd02";
      };
      meta = with stdenv.lib; {
        inherit longDescription;
        description = "Hunspell dictionary for ${shortDescription} from Dicollecte";
        homepage = http://www.dicollecte.org/home.php?prj=fr;
        license = licenses.mpl20;
        maintainers = with maintainers; [ renzo ];
        platforms = platforms.all;
      };
    };

  mkDictFromWordlist =
    { shortName, shortDescription, dictFileName, src }:
    mkDict rec {
      inherit src dictFileName;
      version = "2014.11.17";<commit_msg>hunspell-dictionaries: update french dictonary to fix the build<commit_after>/* hunspell dictionaries */

{ stdenv, fetchurl, unzip }:

with stdenv.lib;

let

  mkDict =
  { name, src, meta, readmeFile, dictFileName, ... }:
  let
    isFrench = hasSuffix "fr_" dictFileName;
    isItaly = hasSuffix "it_" dictFileName;
    isSpanish = hasSuffix "es_" dictFileName;
    isEnglish = hasSuffix "en_" dictFileName;
  in
  stdenv.mkDerivation rec {
    inherit name src meta;
    buildInputs = [ unzip ];
    sourceRoot = ".";
    phases = "unpackPhase installPhase" + (if isItaly then "patchPhase" else "");
    unpackCmd = "unzip $src ${readmeFile} ${dictFileName}.dic ${dictFileName}.aff";
    prePatch = if isItaly then ''
    # Fix dic file empty lines (FS#22275)
    sed '/^\/$/d' -i it_IT.dic
    '' else "";

    installPhase = ''
      # hunspell dicts
      install -dm755 "$out/share/hunspell"
      install -m644 ${dictFileName}.dic "$out/share/hunspell/"
      install -m644 ${dictFileName}.aff "$out/share/hunspell/"
      # myspell dicts symlinks
      install -dm755 "$out/share/myspell/dicts"
      ln -sv "$out/share/hunspell/${dictFileName}.dic" "$out/share/myspell/dicts/"
      ln -sv "$out/share/hunspell/${dictFileName}.aff" "$out/share/myspell/dicts/"
      # docs
      install -dm755 "$out/share/doc"
      install -m644 ${readmeFile} $out/share/doc/${name}.txt
    '';
  };

  mkDictFromRedIRIS =
    { shortName, shortDescription, dictFileName, src }:
    mkDict rec {
      inherit src dictFileName;
      version = "0.7";
      name = "hunspell-dict-${shortName}-rediris-${version}";
      readmeFile = "README.txt";
      meta = with stdenv.lib; {
        description = "Hunspell dictionary for ${shortDescription} from RedIRIS";
        homepage = https://forja.rediris.es/projects/rla-es/;
        license = with licenses; [ gpl3 lgpl3 mpl11 ];
        maintainers = with maintainers; [ renzo ];
        platforms = platforms.all;
      };
    };

  mkDictFromDicollecte =
    { shortName, shortDescription, longDescription, dictFileName }:
    mkDict rec {
      inherit dictFileName;
      version = "5.3";
      name = "hunspell-dict-${shortName}-dicollecte-${version}";
      readmeFile = "README_dict_fr.txt";
      src = fetchurl {
         url = "http://www.dicollecte.org/download/fr/hunspell-french-dictionaries-v${version}.zip";
         sha256 = "0ca7084jm7zb1ikwzh1frvpb97jn27i7a5d48288h2qlfp068ik0";
      };
      meta = with stdenv.lib; {
        inherit longDescription;
        description = "Hunspell dictionary for ${shortDescription} from Dicollecte";
        homepage = http://www.dicollecte.org/home.php?prj=fr;
        license = licenses.mpl20;
        maintainers = with maintainers; [ renzo ];
        platforms = platforms.all;
      };
    };

  mkDictFromWordlist =
    { shortName, shortDescription, dictFileName, src }:
    mkDict rec {
      inherit src dictFileName;
      version = "2014.11.17";
{'fraction_non_alphanumeric': 0.132448076268301, 'fraction_numerical': 0.02502553626149132, 'mean_word_length': 2.787878787878788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7553299', 'n_tokens_mistral': 2061, 'n_tokens_neox': 2001, 'n_words': 410}