kanji/readings_generator/compounds_script

14 lines
990 B
Plaintext
Raw Normal View History

2020-12-02 13:21:57 +01:00
#!/bin/bash
#Doanloads readings from nihongo.monash using the EUC-JP standard of the Kanji in question.
while read -r line; do
index="$( echo "$line" | cut -f1)"
EUCJP="$( echo "$line" | cut -f2)"
url="http://nihongo.monash.edu/cgi-bin/wwwjdic?1MKJ${EUCJP}#"
curl -s "$url" > raw_html
ON="$(hxnormalize -i 0 -x raw_html | hxselect 'table' | awk 'BEGIN {printout=100000000000}; NR==printout+2 {print $0}; /ON reading/ {printout=NR}'| sed 's/<td><b>//; s/<\/b><\/td>//' )"
KUN="$(hxnormalize -i 0 -x raw_html | hxselect 'table' | awk 'BEGIN {printout=100000000000}; NR==printout+2 {print $0}; /KUN reading/ {printout=NR}'| sed 's/<td><b>//; s/<\/b><\/td>//')"
NAN="$(hxnormalize -i 0 -x raw_html | hxselect 'table' | awk 'BEGIN {printout=100000000000}; NR==printout+2 {print $0}; /Nanori reading/ {printout=NR}'| sed 's/<td><b>//; s/<\/b><\/td>//')"
2021-02-11 21:47:54 +01:00
printf '%s\t%s\t%s\t%s\n' "$index" "$ON" "$KUN" "$NAN" | sed 's/ /、/g' | sed 's/、\t/\t/g; s/、$//'
2020-12-02 13:21:57 +01:00
rm raw_html
done<index_kanji