tvl-depot/corp/russian/data-import/default.nix
Vincent Ambo 429c0d00c4 feat(corp/data-import): add import of OpenRussian 'words' table
This is actually the lemmata table of this corpus, not the forms of
all words (they're in a separate table).

Change-Id: I89a2c2817ccce840f47406fa2a636f4ed3f49154
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7893
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
2023-01-21 17:49:33 +00:00

55 lines
1.5 KiB
Nix

{ depot, lib, pkgs, ... }:
let
buildInputs = with pkgs; [
sqlite
pkg-config
];
# mirrored input data from OpenCorpora, as of 2023-01-17.
#
# This data is licensed under CC-BY-SA.
openCorporaArchive = pkgs.fetchurl {
name = "dict.opcorpora.xml.bz";
url = "https://tazj.in/blobs/opencorpora-20230117.xml.bz2";
sha256 = "04n5g43fkfc93z6xlwf2qfdrfdfl562pc2ivdb3cbbbsy56gkqg6";
};
openCorpora = pkgs.runCommand "dict.opcorpora.xml" { } ''
${pkgs.bzip2}/bin/bunzip2 -k -c ${openCorporaArchive} > $out
'';
# mirrored input data from OpenRussian, as of 2023-01-17.
#
# This data is licensed under CC-BY-SA.
openRussianArchive = pkgs.fetchzip {
name = "openrussian-20230117";
url = "https://tazj.in/blobs/openrussian-20230117.tar.xz";
sha256 = "06jl7i23cx58a0n2626hb82xlzimixvnxp7lxdw0g664kv9bmw25";
};
# development shell with native deps
shell = pkgs.mkShell {
inherit buildInputs;
# make datasets available in the environment
OPENCORPORA_DATA = openCorpora;
OPENRUSSIAN_DATA = openRussianArchive;
};
in
lib.fix (self: depot.third_party.naersk.buildPackage {
src = depot.third_party.gitignoreSource ./.;
inherit buildInputs;
passthru = depot.nix.readTree.drvTargets {
inherit shell openCorpora;
# target that actually builds an entire database
database = pkgs.runCommand "tvl-russian-db.sqlite"
{
OPENCORPORA_DATA = openCorpora;
OPENRUSSIAN_DATA = openRussianArchive;
} "${self}/bin/data-import --output $out";
};
})