nixpkgs/pkgs/development/python-modules/spacy/models.nix
Daniël de Kok 4059ac951b pythonPackages.spacy_models: add more models
This change adds the missing language-specific spaCy models:

da_core_news_lg, da_core_news_md, da_core_news_sm, de_core_news_lg,
el_core_news_lg, es_core_news_lg, fr_core_news_lg, it_core_news_lg,
it_core_news_md, lt_core_news_lg, lt_core_news_md, nb_core_news_lg,
nb_core_news_md, nl_core_news_lg, nl_core_news_md, pl_core_news_lg,
pl_core_news_md, pl_core_news_sm, pt_core_news_lg, pt_core_news_md,
ro_core_news_sm, ro_core_news_md, ro_core_news_lg, zh_core_web_lg,
zh_core_web_md, zh_core_web_sm

I also checked the licenses and fixed them where necessary.
2020-06-27 23:03:39 -07:00

30 lines
1.1 KiB
Nix

{ stdenv, lib, buildPythonPackage, fetchurl, jieba, pkuseg, spacy }:
let
buildModelPackage = { pname, version, sha256, license }:
let
lang = builtins.substring 0 2 pname;
in buildPythonPackage {
inherit pname version;
src = fetchurl {
url = "https://github.com/explosion/spacy-models/releases/download/${pname}-${version}/${pname}-${version}.tar.gz";
inherit sha256;
};
propagatedBuildInputs = [ spacy ]
++ lib.optionals (lang == "zh") [ jieba pkuseg ];
meta = with stdenv.lib; {
description = "Models for the spaCy NLP library";
homepage = "https://github.com/explosion/spacy-models";
license = licenses.${license};
maintainers = with maintainers; [ rvl ];
};
};
makeModelSet = models: with stdenv.lib; listToAttrs (map (m: nameValuePair m.pname (buildModelPackage m)) models);
in makeModelSet (stdenv.lib.importJSON ./models.json)
# cat models.json | jq -r '.[] | @uri "https://github.com/explosion/spacy-models/releases/download/\(.pname)-\(.version)/\(.pname)-\(.version).tar.gz"' | xargs -n1 nix-prefetch-url