$(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 $@
@[ -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
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;
];
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;
}
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,
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);