From 3b65f33cb465124700f27e6fc4e34df42ea5634e Mon Sep 17 00:00:00 2001 From: nicoo Date: Sat, 28 Oct 2023 13:50:00 +0000 Subject: [PATCH 1/3] open-english-wordnet: init at 2022 --- .../op/open-english-wordnet/package.nix | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 pkgs/by-name/op/open-english-wordnet/package.nix diff --git a/pkgs/by-name/op/open-english-wordnet/package.nix b/pkgs/by-name/op/open-english-wordnet/package.nix new file mode 100644 index 000000000000..4220548f6a92 --- /dev/null +++ b/pkgs/by-name/op/open-english-wordnet/package.nix @@ -0,0 +1,62 @@ +{ lib +, fetchFromGitHub +, gzip +, python3 +, stdenvNoCC +}: + +stdenvNoCC.mkDerivation (self: { + pname = "open-english-wordnet"; + version = "2022"; + + src = fetchFromGitHub { + owner = "globalwordnet"; + repo = "english-wordnet"; + rev = "${self.version}-edition"; + hash = "sha256-a1fWIp39uuJZL1aFX/r+ttLB1+kwh/XPHwphgENTQ5M="; + }; + + # TODO(nicoo): make compression optional? + nativeBuildInputs = [ + gzip + (python3.withPackages (p: with p; [ pyyaml ])) + ]; + + # TODO(nicoo): generate LMF and WNDB versions with separate outputs + buildPhase = '' + runHook preBuild + + echo Generating wn.xml + python scripts/from-yaml.py + python scripts/merge.py + + echo Compressing + gzip --best --no-name ./wn.xml + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + install -Dt $out/share/wordnet wn.xml.gz + runHook postInstall + ''; + + meta = with lib; { + description = "Lexical network of the English language"; + longDescription = '' + Open English WordNet is a lexical network of the English language grouping + words into synsets and linking them according to relationships such as + hypernymy, antonymy and meronymy. It is intended to be used in natural + language processing applications and provides deep lexical information + about the English language as a graph. + + Open English WordNet is a fork of the Princeton Wordnet developed under an + open source methodology. + ''; + homepage = "https://en-word.net/"; + license = licenses.cc-by-40; + maintainers = with maintainers; [ nicoo ]; + platforms = platforms.all; + }; +}) From 281f03a6db70779c86b5de0550b1a56577b47011 Mon Sep 17 00:00:00 2001 From: nicoo Date: Mon, 30 Oct 2023 17:41:44 +0000 Subject: [PATCH 2/3] open-english-wordnet: Fix merge.py - Upstream left the wrong version number in the script as tagged for the release - The output depends on file iteration order. --- pkgs/by-name/op/open-english-wordnet/package.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/by-name/op/open-english-wordnet/package.nix b/pkgs/by-name/op/open-english-wordnet/package.nix index 4220548f6a92..bcc3e33a57c7 100644 --- a/pkgs/by-name/op/open-english-wordnet/package.nix +++ b/pkgs/by-name/op/open-english-wordnet/package.nix @@ -1,5 +1,6 @@ { lib , fetchFromGitHub +, fetchpatch , gzip , python3 , stdenvNoCC @@ -16,6 +17,16 @@ stdenvNoCC.mkDerivation (self: { hash = "sha256-a1fWIp39uuJZL1aFX/r+ttLB1+kwh/XPHwphgENTQ5M="; }; + patches = lib.mapAttrsToList (rev: hash: fetchpatch { + url = "https://github.com/globalwordnet/english-wordnet/commit/${rev}.patch"; + inherit hash; + }) { + # Upstream commit bumping the version number, accidentally ommited from the tagged release + "bc07902f8995b62c70f01a282b23f40f30630540" = "sha256-1e4MG/k86g3OFUhiShCCbNXnvDKrYFr1KlGVsGl++KI="; + # PR #982, “merge.py: Make result independent of filesystem order” + "6da46a48dd76a48ad9ff563e6c807b8271fc83cd" = "sha256-QkkJH7NVGy/IbeSWkotU80IGF4esz0b8mIL9soHdQtQ="; + }; + # TODO(nicoo): make compression optional? nativeBuildInputs = [ gzip From c29182bbb1c8f5e8bd9f9f181cf243102d70495a Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 5 Nov 2023 17:13:30 +0000 Subject: [PATCH 3/3] open-english-wordnet: Use unique filename under `share/` Otherwise users may have issues trying to bring multiple wordnets in their environment. --- pkgs/by-name/op/open-english-wordnet/package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/op/open-english-wordnet/package.nix b/pkgs/by-name/op/open-english-wordnet/package.nix index bcc3e33a57c7..ccd661753c05 100644 --- a/pkgs/by-name/op/open-english-wordnet/package.nix +++ b/pkgs/by-name/op/open-english-wordnet/package.nix @@ -42,14 +42,14 @@ stdenvNoCC.mkDerivation (self: { python scripts/merge.py echo Compressing - gzip --best --no-name ./wn.xml + gzip --best --no-name --stdout ./wn.xml > 'oewn:${self.version}.xml.gz' runHook postBuild ''; installPhase = '' runHook preInstall - install -Dt $out/share/wordnet wn.xml.gz + install -Dt $out/share/wordnet 'oewn:${self.version}.xml.gz' runHook postInstall '';