From 65d4676373dbb0a9f9c147e0de61eb66e595b91a Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 13 Dec 2023 01:33:28 +0100 Subject: [PATCH] word: remove obsolete languageless include selection --- Makefile | 4 +--- tools/mkwordlist | 9 ++------- tools/word.pg.sql | 15 --------------- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 7d1e2e3..f48ffa7 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ UPDATE: $(download) $(call cmdsave,git log -1 --date=short --pretty="%ad %s") cache: $(patsubst %.inc.pl,data/%.json,$(wildcard charset-*.inc.pl) writing-latn.inc.pl) -word: word/put.min.js data/wordlist.inc.pl data/wordlist.en.json data/wordlist.nl.json data/wordlist.ru.json data/wordpairs.json +word: word/put.min.js data/wordlist.en.json data/wordlist.nl.json data/wordlist.ru.json data/wordpairs.json word/put.js: $(download) tools/wget-ifmodified https://github.com/kriszyp/put-selector/raw/master/put.js $@ @@ -83,8 +83,6 @@ data/wordlist.version.txt: force @[ -e $@ ] || date -Is >$@ tools/lastword $@ || true -data/wordlist.inc.pl: tools/mkwordlist data/wordlist.version.txt - $(call cmdsave,$<) data/wordlist.%.inc.pl: tools/mkwordlist data/wordlist.version.txt $(call cmdsave,$< $*) data/word%.json: data/word%.inc.pl diff --git a/tools/mkwordlist b/tools/mkwordlist index 81c3630..7611b9f 100755 --- a/tools/mkwordlist +++ b/tools/mkwordlist @@ -11,7 +11,8 @@ say 'use utf8;'; use Data::Dump 'pp'; my %rows; -if (my $lang = shift @ARGV) { +my $lang = shift @ARGV or die "Missing language\n"; +{ my %filter = (lang => $lang); my $cols = "ref, array_to_string(form || alt, '/'), prio, id, sub"; %rows = $db->select(_word => $cols, \%filter)->map_arrays; @@ -22,10 +23,4 @@ if (my $lang = shift @ARGV) { ]; say pp \%rows =~ s/\\x\{([0-9A-F]+)\}/chr hex $1/ger; - exit; -} -else { - %rows = $db->select(_cat_words => "coalesce(id::text, ''), forms")->map; - $_ = [ map { [split /:/, $_, 3] } @{$_} ] for values %rows; - say pp \%rows; } diff --git a/tools/word.pg.sql b/tools/word.pg.sql index 7f97ada..9f972dc 100644 --- a/tools/word.pg.sql +++ b/tools/word.pg.sql @@ -54,14 +54,6 @@ CREATE TABLE kind ( COMMENT ON COLUMN kind.truth IS 'link validity ranging from 0 (never) to 100 (always)'; -CREATE OR REPLACE FUNCTION exportform(word) RETURNS text AS $$ - SELECT concat( - coalesce($1.ref, $1.id), ':', - $1.prio, CASE WHEN $1.cover THEN 'c' ELSE '' END, ':', - array_to_string($1.form || $1.alt, '/') - ); -$$ LANGUAGE SQL IMMUTABLE; - CREATE OR REPLACE VIEW _word_ref AS SELECT r.form, r.alt, r.lang, @@ -102,10 +94,3 @@ CREATE OR REPLACE VIEW _word AS w.* FROM _word_ref w ; - -CREATE OR REPLACE VIEW _cat_words AS - SELECT exportform(word.*) form, sub.*, word.lang, word.ref - FROM word RIGHT JOIN ( - SELECT cat id, array_agg(exportform(word.*) ORDER BY grade, form) forms - FROM word WHERE ref IS NULL GROUP BY cat - ) sub USING (id); -- 2.30.0