2021-05-16 09:02:43 +01:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchurl
|
|
|
|
, jieba
|
|
|
|
, pymorphy2
|
|
|
|
, sentencepiece
|
|
|
|
, spacy
|
|
|
|
, spacy-pkuseg
|
|
|
|
, spacy-transformers }:
|
2017-09-13 18:32:46 +01:00
|
|
|
let
|
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-21 10:50:21 +01:00
|
|
|
buildModelPackage = { pname, version, sha256, license }:
|
|
|
|
let
|
|
|
|
lang = builtins.substring 0 2 pname;
|
|
|
|
in buildPythonPackage {
|
2017-09-13 18:32:46 +01:00
|
|
|
inherit pname version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/explosion/spacy-models/releases/download/${pname}-${version}/${pname}-${version}.tar.gz";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
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-21 10:50:21 +01:00
|
|
|
propagatedBuildInputs = [ spacy ]
|
2021-05-16 09:02:43 +01:00
|
|
|
++ lib.optionals (lang == "zh") [ jieba spacy-pkuseg ]
|
|
|
|
++ lib.optionals (lib.hasSuffix "_trf" pname) [ spacy-transformers ]
|
|
|
|
++ lib.optionals (lang == "ru") [ pymorphy2 ]
|
|
|
|
++ lib.optionals (pname == "fr_dep_news_trf") [ sentencepiece ];
|
|
|
|
|
|
|
|
postPatch = lib.optionals (pname == "fr_dep_news_trf") ''
|
|
|
|
substituteInPlace meta.json \
|
|
|
|
--replace "sentencepiece==0.1.91" "sentencepiece>=0.1.91"
|
|
|
|
'';
|
2017-09-13 18:32:46 +01:00
|
|
|
|
2020-08-18 18:32:01 +01:00
|
|
|
pythonImportsCheck = [ pname ];
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2017-09-13 18:32:46 +01:00
|
|
|
description = "Models for the spaCy NLP library";
|
|
|
|
homepage = "https://github.com/explosion/spacy-models";
|
2019-08-13 22:52:01 +01:00
|
|
|
license = licenses.${license};
|
2017-09-13 18:32:46 +01:00
|
|
|
maintainers = with maintainers; [ rvl ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-01-24 00:29:22 +00:00
|
|
|
makeModelSet = models: with lib; listToAttrs (map (m: nameValuePair m.pname (buildModelPackage m)) models);
|
2017-09-13 18:32:46 +01:00
|
|
|
|
2021-01-24 00:29:22 +00:00
|
|
|
in makeModelSet (lib.importJSON ./models.json)
|
2017-09-13 18:32:46 +01:00
|
|
|
|
|
|
|
# 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
|