Add radkfile data + update script

This commit is contained in:
2026-04-07 16:07:03 +09:00
parent 3c2971394e
commit 1a4ebd0dcd
4 changed files with 7660 additions and 0 deletions

6463
radkfile/kradfile Normal file

File diff suppressed because it is too large Load Diff

1141
radkfile/radkfile Normal file

File diff suppressed because it is too large Load Diff

1
radkfile/version.txt Normal file
View File

@@ -0,0 +1 @@
2023-05

55
scripts/update-radkfile.sh Executable file
View File

@@ -0,0 +1,55 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils curl gitMinimal gzip gnugrep gnused iconv
set -euo pipefail
set -x
RADK_URL='http://ftp.edrdg.org/pub/Nihongo/radkfile.gz'
KRAD_URL='http://ftp.edrdg.org/pub/Nihongo/kradfile.gz'
TMP="$(mktemp -d)"
PROJECT_ROOT="$(git rev-parse --show-toplevel)"
DATA_DIR="$PROJECT_ROOT/radkfile"
function cleanup {
rm -rf "$TMP"
}
trap cleanup EXIT
curl -L -o "$TMP/radkfile.gz" "$RADK_URL"
gzip -dkc "$TMP/radkfile.gz" > "$TMP/radkfile"
iconv -f EUC-JP -t UTF-8 -o "$DATA_DIR/radkfile" "$TMP/radkfile"
curl -L -o "$TMP/kradfile.gz" "$KRAD_URL"
gzip -dkc "$TMP/kradfile.gz" > "$TMP/kradfile"
iconv -f EUC-JP -t UTF-8 -o "$DATA_DIR/kradfile" "$TMP/kradfile"
# Retrieve the latest line from the changelog
declare -A MONTH_MAP=(
[Jan]="01"
[Feb]="02"
[Mar]="03"
[Apr]="04"
[May]="05"
[Jun]="06"
[Jul]="07"
[Aug]="08"
[Sep]="09"
[Oct]="10"
[Nov]="11"
[Dec]="12"
)
sed -n "$DATA_DIR/kradfile" -e '/^#\+ CHANGES (some of them) #\+/,/^#\{10,\}/p' \
| sed '1d;$d' \
| sed 's/^# //' \
| sed '/^[^A-Z]/d' \
| cut -d' ' -f1-2 \
| tail -n 1 \
| while read -r MONTH YEAR; do
echo "$YEAR-${MONTH_MAP[$MONTH]}"
done \
> "$DATA_DIR/version.txt"
cleanup