Upload files to "/"

This commit is contained in:
miro 2026-04-11 05:47:53 +00:00
parent e87019747c
commit ef189c65c4
2 changed files with 1748 additions and 0 deletions

1318
kanji-and-antonym.txt Normal file

File diff suppressed because it is too large Load Diff

430
trainjpnvocab.sh Normal file
View File

@ -0,0 +1,430 @@
#!/bin/bash
:<<'BCM' '
.----------------------------------------------------------------------.
| Nihongo Vacabulary Trainer 0.1a |
| Copyright (C) 2026 Miro <miro@danwin1210.de> |
| |
| This program is free software: you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by |
| the Free Software Foundation, either version 3 of the License, or |
| any later version of GNU. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See then |
| GNU General Public License for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with this program. If not, see https://www.gnu.org/licenses/. |
`-----------------------------------------------------------------------`
'
BCM
function exitprogram() {
echo "Closing program - exiting"
kill -TERM -$$ 2>/dev/null
exit 1
}
declare syllable
declare syllableAd
# AKARIN Ascii art my miro CC BY 4.0
AKARIN="<b><span foreground='#FC4367' font='Droid Sans' font-size='small'> 𜰾 ︵🯓𜰶 ︹🯐◜𜰱⎺⎺🯒🯓⋌𜰱🯒. ︵ 🯓 \n 🯐🯑 🯒🯓 ⎛ 🯐 ⎮ ⎞ 𜰱𜰲🯓 \n 🯐︵🯐🯑 ⎝ 🯗 ⎮ ⎠ 🯒🯓 \n 𜰵🮡𜰰 𜰱 𜰹 𜰶 𜰶 \n𜰱𜰹𜰻 . 𜰶 𜰶 𜰶 𜰶 🯒🯓 🯔 \n 𜰴🯗 ⎞ 🯗𜰹 𜰻𜰹 𜰼 🯗 𜰸 ⎞𜰾🯛\n 🯖 ⎠ 🯖⎝ 🯗 🯒🯓🯒🯓 🯗 🯒🯓 ՝ 🯗 🯔. 🯐🯑 \n𜰽| 🯗🯜 🯔🯗⁔≈ 𜰶 ⎠🯒🯓𜰻 ⁔ 𜰲🯓 🯗 .𜰻⁄ \n 𜰹 |🯗 ᑆ𜰱 ,𜲦⁙𜲩◝ ㄔ՝⎻ ҇՟९🯟𜰶𜰺 𜰸՝ ֊ 𜰻. 🯗 \n 𜰼🯗⎠𜰶 𜰲‛𜲮⎽𜲯 ︵.. 🭲 𜰸 𜰻 𜰻 \n 🯗⎮ ⎞ 🭲 🯔 🯗𜰸 🯗 \n 🯗𜰻 𜰸 𜰻 🯗 ⎮ 𜰻 \n 𜰹𜰴𜰸 🮡🯓 ◟⎽𜰾 𜰻 🯐🯑🯗 ⎝ 🯗 \n 🯕 𜰻 🯒 𜰽 ◞𜰺🯐🯑🯗 𜰸𜰴🯔 🯗 \n 𜰹𜰴⎞ 🯗⎝ ̡⎯⎯ ⌍ ⎟𜰻𜰶 𜰻 🯔🯗𜰷𜰴 \n 𜰷𜰴 𜰸🯐🯑𜰶⎽🯔⎠ ︳ ⎢🯢𜰹 ⎢ 𜰷𜰴 \n 🯐🯑⎺⎺⎺🯝⎺⎺ ◟ ◞ ⎺⎺ 🯟⎺⎺⎺🯒🯓 \n 🯐🯑 𜸰𜸰𜸰𜸰𜸰🯒🯓 🯐🯑 𜸰𜸰𜸰𜸰 🯒🯓 \n ⎽ 🯝⁛⁛⁛⁛⁛ ⁛.🯒🯓⎼⎼⎼⎼🯐🯑⁛⁛⁛⁛⁛⁛.. 🯟🯓 \n 𜰸𜰶 𜰻 🯒🯓 ⎝ ⁛ 𜰻 .🯐🯑 🯒🯓 \n ⎞ ⎲𜰶🯗 🯒🯓..⁛⁛⁛⁛: : 🯔⁛ 🯗 ⁛⁛⁛⁛ .🯐🯑 ⎞ \n 𜰵 ⎻⎻⎞𜰶. 🯒🯓⎽⎽⎽⎽⎽ (⎺⎺) __⎽⎽⎽⎽⎽🯐🯑 🯔\n 𜰹 ⎻⎻ ⎫⎞ __ ⎫ 🯗⎺⎺⎺🯔 ⎲ ⎢\n ⎩ ⎺⎺𜰺𜰾🭰⁙⁙⎞ ⎢⁛⁛ .⎢ ⎞ 𜰻 \n 𜲪.🯔⎺ 🯔⎺𜰶 .🯔 ⎟ . ⎢ 🯗⎼⎼⎼⎼_𜰻 \n 𜰸🯔 🯔:𜰺. ⎤ ⎢⁛⁛ .⎢ 𜰻⁛ ⁛ ⁛ 𜰻 \n 🯝⎣: 🯔 🯐🯑: :⎢⎞ ⎢ . ⎢ 𜰻⎼⎼⎼⎼⎼.𜰻 \n ⎜ 𜰹𜰼🯐🯑: : ::𜰺𜰾𜰸. 🯗⁛⁛. 🯔 𜰻: : : : : :𜰻 \n ⎜ 𜰸𜰹:⎽: ⋌𜰱: : 𜰸. 🯗 .🯔 .🯗: : : : : 𜰻 \n 𜰲\_________/: :⎠ . 🯒🯓⁛⁛ 🯐🯑 .🯗: : : : : 𜰻 </span></b>"
TITLE="Nihongo Vacabulary Trainer ver 0.1a"
WICON="package-x-generic"
function selectsyl1(){
yad --center --title="$TITLE" \
--window-icon="$WICON" \
--text-align=center --text="<span foreground='orange'><b><big><big>\n\Choose which syllablelable batch vocabulary list that you would like to learn\n\n</big></big></b></span>" \
--buttons-layout=center \
--button="<span foreground='lightgreen'><b><big>あ</big></b></span>":11 \
--button="<span foreground='lightgreen'><b><big>い</big></b></span>":12 \
--button="<span foreground='lightgreen'><b><big>う</big></b></span>":13 \
--button="<span foreground='lightgreen'><b><big>え</big></b></span>":14 \
--button="<span foreground='lightgreen'><b><big>お</big></b></span>":15 \
--button="<span foreground='lightgreen'><b><big>か</big></b></span>":16 \
--button="<span foreground='lightgreen'><b><big>き</big></b></span>":17 \
--button="<span foreground='lightgreen'><b><big>く</big></b></span>":18 \
--button="<span foreground='lightgreen'><b><big>け</big></b></span>":19 \
--button="<span foreground='lightgreen'><b><big>こ</big></b></span>":20 \
--button="<span foreground='lightgreen'><b><big>さ</big></b></span>":21 \
--button="<span foreground='lightgreen'><b><big>し</big></b></span>":22 \
--button="<span foreground='lightgreen'><b><big>す</big></b></span>":23 \
--button="<span foreground='lightgreen'><b><big>Next</big></b></span>":100
local chosesly1=$?
[[ $chosesly1 -le 3 ]] && exitprogram
[[ $chosesly1 -lt 24 && $chosesly1 -ge 11 && intermediate -eq 1 ]] && RBatchlist $chosesly1 && questioning && exit 1 || [[ $chosesly1 -le 23 && $chosesly1 -ge 11 && hard -eq 1 ]] && RBatchlist $chosesly1 && questioning && exit 1
[[ $chosesly1 -eq 100 ]] && selectsyl2 && exit 1
}
function selectsyl2(){
yad --center --title="$TITLE" \
--window-icon="$WICON" \
--text-align=center --text="<span foreground='orange'><b><big><big>\n\Choose which syllablelable batch vocabulary list that you would like to learn\n\n</big></big></b></span>" \
--buttons-layout=center \
--button="<span foreground='lightgreen'><b><big>Previous</big></b></span>":8 \
--button="<span foreground='lightgreen'><b><big>せ</big></b></span>":24 \
--button="<span foreground='lightgreen'><b><big>そ</big></b></span>":25 \
--button="<span foreground='lightgreen'><b><big>た</big></b></span>":26 \
--button="<span foreground='lightgreen'><b><big>ち</big></b></span>":27 \
--button="<span foreground='lightgreen'><b><big>つ</big></b></span>":28 \
--button="<span foreground='lightgreen'><b><big>て</big></b></span>":29 \
--button="<span foreground='lightgreen'><b><big>と</big></b></span>":30 \
--button="<span foreground='lightgreen'><b><big>な</big></b></span>":31 \
--button="<span foreground='lightgreen'><b><big>に</big></b></span>":32 \
--button="<span foreground='lightgreen'><b><big>ぬ</big></b></span>":33 \
--button="<span foreground='lightgreen'><b><big>ね</big></b></span>":34 \
--button="<span foreground='lightgreen'><b><big>の</big></b></span>":35 \
--button="<span foreground='lightgreen'><b><big>Next</big></b></span>":101
local chosesly2=$?
[[ $chosesly2 -le 3 ]] && exitprogram
[[ $chosesly2 -eq 8 ]] && selectsyl1 && exit 1
[[ $chosesly2 -eq 101 ]] && selectsyl3 && exit 1
[[ $chosesly2 -gt 23 && $chosesly2 -lt 36 && intermediate -eq 1 ]] && RBatchlist $chosesly2 && questioning && exit 1 || [[ $chosesly2 -gt 23 && $chosesly2 -lt 36 && hard -eq 1 ]] && RBatchlist $chosesly2 && questioning && exit 1
}
function selectsyl3(){
yad --center --title="$TITLE" \
--window-icon="$WICON" \
--text-align=center --text="<span foreground='orange'><b><big><big>\n\Sorry, this program currently work in progress.\nの batch list is the last batch available for version 1.0\nThe rest of the batch will be available in the next upcoming version\n\n</big></big></b></span>" \
--buttons-layout=center \
--height=500 --fixed \
--button="<span foreground='lightgreen'><b><big>Previous</big></b></span>":100
local chosesly3=$?
[[ $chosesly3 -ne 100 ]] && exitprogram
[[ $chosesly3 -eq 100 ]] && selectsyl2 && exit 1
}
function RBatchlist(){
#Random list chooser
local recchosesly1=$1
local recchosesly2=$1
if [[ $intermediate -eq 1 || $hard -eq 1 ]]; then
case $recchosesly1 in
11) declare -g ad1=1 && declare -g ad2=1 && declare -g ad3=1 && declare -g ad44=1 ;;
12) declare -g ad1=53 && declare -g ad2=53 && declare -g ad3=53 && declare -g ad4=53 ;;
13) declare -g ad1=105 && declare -g ad2=105 && declare -g ad3=105 && declare -g ad4=105 ;;
14) declare -g ad1=157 && declare -g ad2=157 && declare -g ad3=157 && declare -g ad4=157 ;;
15) declare -g ad1=209 && declare -g ad2=209 && declare -g ad3=209 && declare -g ad4=209 ;;
16) declare -g ad1=261 && declare -g ad2=261 && declare -g ad3=261 && declare -g ad4=261 ;;
17) declare -g ad1=313 && declare -g ad2=313 && declare -g ad3=313 && declare -g ad4=313 ;;
18) declare -g ad1=365 && declare -g ad2=365 && declare -g ad3=365 && declare -g ad4=365 ;;
19) declare -g ad1=417 && declare -g ad2=417 && declare -g ad3=417 && declare -g ad4=417 ;;
20) declare -g ad1=469 && declare -g ad2=469 && declare -g ad3=469 && declare -g ad4=469 ;;
21) declare -g ad1=521 && declare -g ad2=521 && declare -g ad3=521 && declare -g ad4=521 ;;
22) declare -g ad1=573 && declare -g ad2=573 && declare -g ad3=573 && declare -g ad4=573 ;;
23) declare -g ad1=625 && declare -g ad2=625 && declare -g ad3=625 && declare -g ad4=625 ;;
esac
fi
if [[ $intermediate -eq 1 || $hard -eq 1 ]]; then
case $recchosesly2 in
24) declare -g ad1=677 && declare -g ad2=677 && declare -g ad3=677 && declare -g ad4=677 ;;
25) declare -g ad1=729 && declare -g ad2=729 && declare -g ad3=729 && declare -g ad4=729 ;;
26) declare -g ad1=781 && declare -g ad2=781 && declare -g ad3=781 && declare -g ad4=781 ;;
27) declare -g ad1=833 && declare -g ad2=833 && declare -g ad3=833 && declare -g ad4=833 ;;
28) declare -g ad1=885 && declare -g ad2=885 && declare -g ad3=885 && declare -g ad4=885 ;;
29) declare -g ad1=937 && declare -g ad2=937 && declare -g ad3=937 && declare -g ad4=937 ;;
30) declare -g ad1=989 && declare -g ad2=989 && declare -g ad3=989 && declare -g ad4=989 ;;
31) declare -g ad1=1041 && declare -g ad2=1041 && declare -g ad3=1041 && declare -g ad4=1041 ;;
32) declare -g ad1=1093 && declare -g ad2=1093 && declare -g ad3=1093 && declare -g ad4=1093 ;;
33) declare -g ad1=1145 && declare -g ad2=1145 && declare -g ad3=1145 && declare -g ad4=1145 ;;
34) declare -g ad1=1197 && declare -g ad2=1197 && declare -g ad3=1197 && declare -g ad4=1197 ;;
35) declare -g ad1=1249 && declare -g ad2=1249 && declare -g ad3=1249 && declare -g ad4=1249 ;;
esac
fi
leftright=$((($RANDOM % 2)+1))
RealA=$((($RANDOM % 4)+1))
}
function qa1ri(){
[[ $intermediate -eq 1 ]] && nn1=$((ad1+rad1)) && nn2=$((ad2+rad2)) && nn3=$((ad3+rad3)) && nn4=$((ad4+rad4))
[[ $hard -eq 1 ]] && adforitm=1 && nn1=$((ad1+rad1)) && ad2=$(((rds2*52)+1)) && ad3=$(((rds3*52)+1)) && ad4=$(((rds4*52)+1))
[[ $ridiculous -eq 1 ]] && adforrdc=1 && ad1=$(((rds1*52)+1)) && ad2=$(((rds2*52)+1)) && ad3=$(((rds3*52)+1)) && ad4=$(((rds1*52)+1))
[[ $adforitm -eq 1 ]] && nn2=$((ad2+rad2)) && nn3=$((ad3+rad3)) && nn4=$((ad4+rad4))
[[ $adforrdc -eq 1 ]] && nn1=$((ad1+rad1)) && nn2=$((ad2+rad2)) && nn3=$((ad3+rad3)) && nn4=$((ad4+rad4))
rg=$(awk -v line1="$nn1" 'NR==line1' "kanji-and-antonym.txt")
w1=$(awk -v line2="$nn2" 'NR==line2' "kanji-and-antonym.txt")
w2=$(awk -v line3="$nn3" 'NR==line3' "kanji-and-antonym.txt")
w3=$(awk -v line4="$nn4" 'NR==line4' "kanji-and-antonym.txt")
[[ leftright -eq 1 ]] && outcq=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs) && out1=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && revalf=1
[[ leftright -eq 2 ]] && outcq=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||') && out1=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && revalf=2
acw1=(correct)
[[ leftright -eq 1 ]] && out2=$(echo $w1 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout2=$(echo $w1 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out2=$(echo $w1 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout2=$(echo $w1 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw2=(wrong) && abswans="_wca2"
[[ leftright -eq 1 ]] && out3=$(echo $w2 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout3=$(echo $w2 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out3=$(echo $w2 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout3=$(echo $w2 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw3=(wrong) && abswans="_wca3"
[[ leftright -eq 1 ]] && out4=$(echo $w3 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout4=$(echo $w3 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out4=$(echo $w3 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout4=$(echo $w3 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw4=(wrong) && abswans="_wca4"
[[ revalf -eq 1 ]] && reva=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||')
[[ revalf -eq 2 ]] && reva=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
}
function qa2ri(){
[[ $intermediate -eq 1 ]] && nn1=$((ad1+rad1)) && nn2=$((ad2+rad2)) && nn3=$((ad3+rad3)) && nn4=$((ad4+rad4))
[[ $hard -eq 1 ]] && adforitm=1 && ad1=$(((rds1*52)+1)) && nn2=$((ad2+rad2)) && ad3=$(((rds3*52)+1)) && ad4=$(((rds4*52)+1))
[[ $ridiculous -eq 1 ]] && adforrdc=1 && ad1=$(((rds1*52)+1)) && ad2=$(((rds2*52)+1)) && ad3=$(((rds3*52)+1)) && ad4=$(((rds4*52)+1))
[[ $adforitm -eq 1 ]] && nn1=$((ad1+rad1)) && nn3=$((ad3+rad3)) && nn4=$((ad4+rad4))
[[ $adforrdc -eq 1 ]] && nn1=$((ad1+rad1)) && nn2=$((ad2+rad2)) && nn3=$((ad3+rad3)) && nn4=$((ad4+rad4))
rg=$(awk -v line1="$nn1" 'NR==line1' "kanji-and-antonym.txt")
w1=$(awk -v line2="$nn2" 'NR==line2' "kanji-and-antonym.txt")
w2=$(awk -v line3="$nn3" 'NR==line3' "kanji-and-antonym.txt")
w3=$(awk -v line4="$nn4" 'NR==line4' "kanji-and-antonym.txt")
[[ leftright -eq 1 ]] && outcq=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs) && out2=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && revalf=1
[[ leftright -eq 2 ]] && outcq=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||') && out2=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && revalf=2
acw2=(correct)
[[ leftright -eq 1 ]] && out1=$(echo $w1 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout1=$(echo $w1 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out1=$(echo $w1 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout1=$(echo $w1 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw1=(wrong) && abswans="_wca1"
[[ leftright -eq 1 ]] && out3=$(echo $w2 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout3=$(echo $w2 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out3=$(echo $w2 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout3=$(echo $w2 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw3=(wrong) && abswans="_wca3"
[[ leftright -eq 1 ]] && out4=$(echo $w3 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout4=$(echo $w3 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out4=$(echo $w3 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout4=$(echo $w3 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw4=(wrong) && abswans="_wca4"
[[ revalf -eq 1 ]] && reva=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||')
[[ revalf -eq 2 ]] && reva=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
}
function qa3ri(){
[[ $intermediate -eq 1 ]] && nn1=$((ad1+rad1)) && nn2=$((ad2+rad2)) && nn3=$((ad3+rad3)) && nn4=$((ad4+rad4))
[[ $hard -eq 1 ]] && adforitm=1 && ad1=$(((rds1*52)+1)) && ad2=$(((rds2*52)+1)) && nn3=$((ad3+rad3)) && ad4=$(((rds4*52)+1))
[[ $ridiculous -eq 1 ]] && adforrdc=1 && ad1=$(((rds1*52)+1)) && ad2=$(((rds2*52)+1)) && ad3=$(((rds3*52)+1)) && ad4=$(((rds4*52)+1))
[[ $adforitm -eq 1 ]] && nn1=$((ad1+rad1)) && nn2=$((ad2+rad2)) && nn4=$((ad4+rad4))
[[ $adforrdc -eq 1 ]] && nn1=$((ad1+rad1)) && nn2=$((ad2+rad2)) && nn3=$((ad3+rad3)) && nn4=$((ad4+rad4))
rg=$(awk -v line1="$nn1" 'NR==line1' "kanji-and-antonym.txt")
w1=$(awk -v line2="$nn2" 'NR==line2' "kanji-and-antonym.txt")
w2=$(awk -v line3="$nn3" 'NR==line3' "kanji-and-antonym.txt")
w3=$(awk -v line4="$nn4" 'NR==line4' "kanji-and-antonym.txt")
[[ leftright -eq 1 ]] && outcq=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs) && out3=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && revalf=1
[[ leftright -eq 2 ]] && outcq=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||') && out3=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && revalf=2
acw3=(correct)
[[ leftright -eq 1 ]] && out1=$(echo $w1 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout1=$(echo $w1 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out1=$(echo $w1 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout1=$(echo $w1 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw1=(wrong) && abswans="_wca1"
[[ leftright -eq 1 ]] && out2=$(echo $w2 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout2=$(echo $w2 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out2=$(echo $w2 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout2=$(echo $w2 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw2=(wrong) && abswans="_wca2"
[[ leftright -eq 1 ]] && out4=$(echo $w3 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout4=$(echo $w3 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out4=$(echo $w3 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout4=$(echo $w3 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw4=(wrong) && abswans="_wca4"
[[ revalf -eq 1 ]] && reva=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||')
[[ revalf -eq 2 ]] && reva=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
}
function qa4ri(){
[[ $intermediate -eq 1 ]] && nn1=$((ad1+rad1)) && nn2=$((ad2+rad2)) && nn3=$((ad3+rad3)) && nn4=$((ad4+rad4))
[[ $hard -eq 1 ]] && adforitm=1 && ad1=$(((rds1*52)+1)) && ad2=$(((rds2*52)+1)) && ad3=$(((rds3*52)+1)) && nn4=$((ad4+rad4))
[[ $ridiculous -eq 1 ]] && adforrdc=1 && ad1=$(((rds1*52)+1)) && ad2=$(((rds2*52)+1)) && ad3=$(((rds3*52)+1)) && ad4=$(((rds4*52)+1))
[[ $adforitm -eq 1 ]] && nn1=$((ad1+rad1)) && nn2=$((ad2+rad2)) && nn3=$((ad3+rad3))
[[ $adforrdc -eq 1 ]] && nn1=$((ad1+rad1)) && nn2=$((ad2+rad2)) && nn3=$((ad3+rad3)) && nn4=$((ad4+rad4))
rg=$(awk -v line1="$nn1" 'NR==line1' "kanji-and-antonym.txt")
w1=$(awk -v line2="$nn2" 'NR==line2' "kanji-and-antonym.txt")
w2=$(awk -v line3="$nn3" 'NR==line3' "kanji-and-antonym.txt")
w3=$(awk -v line4="$nn4" 'NR==line4' "kanji-and-antonym.txt")
[[ leftright -eq 1 ]] && outcq=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs) && out4=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && revalf=1
[[ leftright -eq 2 ]] && outcq=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||') && out4=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && revalf=2
acw4=(correct)
[[ leftright -eq 1 ]] && out1=$(echo $w1 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout1=$(echo $w1 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out1=$(echo $w1 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout1=$(echo $w1 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw1=(wrong) && abswans="_wca1"
[[ leftright -eq 1 ]] && out2=$(echo $w2 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout2=$(echo $w2 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out2=$(echo $w2 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout2=$(echo $w2 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw2=(wrong) && abswans="_wca2"
[[ leftright -eq 1 ]] && out3=$(echo $w3 | grep -o "→..*" | sed -e 's|→ ||' | cut -d' ' -f1) && wrout3=$(echo $w3 | grep -o "→..*" | sed -e 's|→ ||')
[[ leftright -eq 2 ]] && out3=$(echo $w3 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | cut -d' ' -f2 | xargs) && wrout3=$(echo $w3 | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
acw3=(wrong) && abswans="_wca3"
[[ revalf -eq 1 ]] && reva=$(echo $rg | grep -o "→..*" | sed -e 's|→ ||')
[[ revalf -eq 2 ]] && reva=$(echo $rg | cut -d'.' -f2 | grep -oe "..*→" | sed -e 's| →||' | xargs)
}
function correct(){
[[ -z $crt ]] && declare -g crt=0
[[ -z $wrg ]] && declare -g wrg=0
crt=$((crt+1))
1rem-anbswans-wrout(){
abswans="" && wrout1="" && wrout2="" && wrout3="" && wrout4=""
}
yad --title="$TITLE" \
--window-icon="$WICON" \
--center --text-align=center --text="\n<span foreground='lightgreen' font-size='xx-large'><b>Your answer is\nCORRECT\nThe antonym of\n\n</b></span><span foreground='aqua' background='#244949' font='System-ui' font-size='xx-large'><big><big>$outcq</big></big></span><span foreground='lightgreen' font-size='xx-large'><b>\nis:\n</b></span><span foreground='aqua' background='#244900' font='System-ui' font-size='xx-large'><big><big>$reva</big></big>\n\n\n</span>" \
--buttons-layout=spread \
--height=500 --fixed \
--button="<span foreground='orange'><b><big>Continue</big></b></span>":8
local chosercont=$?
[[ $chosercont -ne 8 ]] && exitprogram
[[ $chosercont -eq 8 && $intermediate -eq 1 ]] && 1rem-anbswans-wrout && out1="" && out2=""&& out3="" && out4="" && outcq="" && reva="" && questioning && exit 1
[[ $chosercont -eq 8 && $hard -eq 1 ]] && 1rem-anbswans-wrout && out1="" && out2=""&& out3="" && out4="" && outcq="" reva="" && questioning && exit 1
[[ $chosercont -eq 8 && $ridiculous -eq 1 ]] && 1rem-anbswans-wrout && out1="" && out2=""&& out3="" && out4="" && outcq="" && reva="" && questioning && exit 1
}
function wrong(){
local abswansc=$1
local wrouta=$(echo $2$3 $4 $5 $6 $7 $8 $9 $10 | cut -d"_" -f1)
[[ $abswansc -eq "_wca1" ]] && wrgsel="$wrouta"
[[ $abswansc -eq "_wca2" ]] && wrgsel="$wrouta"
[[ $abswansc -eq "_wca3" ]] && wrgsel="$wrouta"
[[ $abswansc -eq "_wca4" ]] && wrgsel="$wrouta"
2rem-anbswans-wrout(){
abswans="" && wrout1="" && wrout2="" && wrout3="" && wrout4=""
}
[[ -z $wrg ]] && declare -g wrg=0
[[ -z $crt ]] && declare -g crt=0
wrg=$((wrg+1))
yad --title="$TITLE" \
--window-icon="$WICON" \
--center --text-align=center --text="\n<span foreground='red' font-size='xx-large'><b>Your answer is\nWRONG\nThe antonym of\n</b><span foreground='lightblue' font='System-ui' font-size='xx-large'><big><big>$outcq</big></big><span foreground='red' font-size='xx-large'><b>\nis:\n</b><span foreground='lightblue' font='System-ui' font-size='xx-large'><big><big>$reva</big></big>\n</span></span></span></span><span foreground='red' font-size='xx-large'><b>not\n</b></span><span foreground='#DB926D' background='#922424' font='System-ui' font-size='xx-large'><big><big>$wrgsel</big></big>\n</span>" \
--buttons-layout=center \
--height=500 --fixed \
--button="<span foreground='orange'><b><big>Continue</big></b></span>":7
local chosewcont=$?
[[ $chosewcont -ne 7 ]] && exitprogram
[[ $chosewcont -eq 7 && $intermediate -eq 1 ]] && 2rem-anbswans-wrout && out1="" && out2=""&& out3="" && out4="" && outcq="" && reva="" && questioning && exit 1
[[ $chosewcont -eq 7 && $hard -eq 1 ]] && 2rem-anbswans-wrout && out1="" && out2="" && out3="" && out4="" && outcq="" && reva="" && questioning && exit 1
[[ $chosewcont -eq 7 && $ridiculous -eq 1 ]] && 2rem-anbswans-wrout && out1="" && out2=""&& out3="" && out4="" && outcq="" && reva="" && questioning && exit 1
}
function finished(){
[[ crt -le 4 ]] && status="<span foreground='#6D4924'> TERRIBLE</span>"
[[ crt -ge 5 && crt -le 6 ]] && status="<span foreground='#B6496D'> POOR</span>"
[[ crt -ge 7 && crt -le 9 ]] && status="<span foreground='yellow'> OK</span>"
[[ crt -eq 10 ]] && status="<span foreground='#24FF24'> GOOD</span>"
yad --center --title="$TITLE" \
--window-icon="$WICON" \
--text-align=center --text="<span foreground='Gold'><b><big><big><big>\n\nFinished!\n\n<span foreground='lightgreen'>You are right $crt out of $qst</span>\n\n<span foreground='#FF6D6D'>Total wrong is $wrg out of $qst</span>\n\n<span foreground='#9292B6'>Result : $status</span>\n\n</big></big></big></b></span>" \
--buttons-layout=spread \
--height=500 --fixed \
--button="<span foreground='orange'><b><big>Continue</big></b></span>":9
fincont=$?
[[ $fincont -gt 9 ]] && exitprogram
[[ $fincont -eq 9 && $intermediate -eq 1 ]] && qst=0 && declare -g intermediate=0 && declare -g wrg=0 && declare -g crt=0 && diffsel && exit 1
[[ $fincont -eq 9 && $hard -eq 1 ]] && qst=0 && declare -g hard=0 && declare -g wrg=0 && declare -g crt=0 && diffsel && exit 1
[[ $fincont -eq 9 && $ridiculous -eq 1 ]] && qst=0 && declare -g ridiculous=0 && declare -g wrg=0 && declare -g crt=0 && diffsel && exit 1
}
function questioning(){
# Add fallback for empty results
if [ -z "$outcq" ]; then
outcq="[No Data Found]"
fi
[[ -z $qst ]] && qst=0
#gen and gen2 random number generator that assigned each of the result to numbers of different variables, where each of them were unrepeated.
gen=""
for ((ran=1;ran<=40;ran++)); do
while true; do
an=$((($RANDOM % 50) + 1 ))
case " $gen " in
*" $an "* ) continue ;;
* ) break ;;
esac
done
gen="$gen $an "
printf -v "an$ran" "%d" "$an"
done
gen2=""
for ((ran2=1;ran2<=24;ran2++)); do
while true; do
rds=$((($RANDOM % 24) + 0 ))
case " $gen2 " in
*" $rds "* ) continue ;;
* ) break ;;
esac
done
gen2="$gen2 $rds "
printf -v "rds$ran2" "%d" "$rds"
done
#unrepeated answer's choices generation per question
case $qst in
2) an1=an5 && rds1=rds5 && an2=an6 && rds2=rds6 && an3=an7 && rds3=rds7 && an4=an8 && rds4=rds8 ;;
3) an1=an9 && rds1=rds9 && an2=an10 && rds2=rds10 && an3=an11 && rds3=rds11 && an4=an12 && rds4=rds12 ;;
4) an1=an13 && rds1=rds13 && an2=an14 && rds2=rds14 && an3=an15 && rds3=rds15 && an4=an16 && rds4=rds16 ;;
5) an1=an17 && rds1=rds17 && an2=an18 && rds2=rds18 && an3=an19 && rds3=rds19 && an4=an20 && rds4=rds20 ;;
6) an1=an21 && rds1=rds21 && an2=an22 && rds2=rds22 && an3=an23 && rds3=rds23 && an4=an24 && rds4=rds24 ;;
7) an1=an25 && rds1=rds2 && an2=an26 && rds2=rds4 && an3=an27 && rds3=rds6 && an4=an28 && rds4=rds8 ;;
8) an1=an29 && rds1=rds10 && an2=an30 && rds2=rds12 && an3=an31 && rds3=rds14 && an4=an32 && rds4=rds16 ;;
9) an1=an33 && rds1=rds18 && an2=an34 && rds2=rds20 && an3=an35 && rds3=rds24&& an4=an36 && rds4=rds23 ;;
10) an1=an37 && rds1=rds21 && an2=an38 && rds2=rds19 && an3=an39 && rds3=rds17 && an4=an40 && rds4=rds15 ;;
esac
while true; do
[[ qst -eq 10 ]] && break
qst=$((qst+1))
RBatchlist
#Define real answer that were fetched from RBatchlist. For each iteration of loop questions, 1 out of 4 answer is correct.
case $RealA in
1) rad1=an1 && rad2=an2 && rad3=an3 && rad4=an4 && qa1ri ;;
2) rad1=an1 && rad2=an2 && rad3=an3 && rad4=an4 && qa2ri ;;
3) rad1=an1 && rad2=an2 && rad3=an3 && rad4=an4 && qa3ri ;;
4) rad1=an1 && rad2=an2 && rad3=an3 && rad4=an4 && qa4ri ;;
esac
yad --center --title="$TITLE" \
--window-icon="$WICON" \
--text-align=center --text="<span foreground='gold'><b><big><big><big>\n\nWhat is the antonym of\n </big></big></big></b><span foreground='magenta' font='System-ui' font-size='xx-large'><big><big><big>$outcq</big></big></big></span>\n\n\n</span>" \
--buttons-layout=start \
--button="<span background='#262642'><span foreground='lightblue' font='System-ui' font-size='x-large'>$out1</span></span>":3 \
--button="<span background='#262642'><span foreground='lightblue' font='System-ui' font-size='x-large'>$out2</span></span>":4 \
--button="<span background='#262642'><span foreground='lightblue' font='System-ui' font-size='x-large'>$out3</span></span>":5 \
--button="<span background='#262642'><span foreground='lightblue' font='System-ui' font-size='x-large'>$out4</span></span>":6
local choseans=$?
[[ $choseans -ne 3 && $choseans -ne 4 && $choseans -ne 5 && $choseans -ne 6 ]] && exitprogram
[[ $choseans -eq 3 ]] && $acw1 $abswans $wrout1 && exit 1
[[ $choseans -eq 4 ]] && $acw2 $abswans $wrout2 && exit 1
[[ $choseans -eq 5 ]] && $acw3 $abswans $wrout3 && exit 1
[[ $choseans -eq 6 ]] && $acw4 $abswans $wrout4 && exit 1
done
for can in {1..40}; do
declare an${can}=""
done
for crds in {1..24}; do
declare rds${crds}=""
done
finished && exit 1
}
function diffsel(){
# Add file existence check
if [ ! -f "kanji-and-antonym.txt" ]; then
yad --center --text="Error: kanji-and-antonym.txt not found"
return 1
fi
yad --center --title="$TITLE" \
--window-icon="$WICON" \
--text-align=center --text="$AKARIN<span foreground='orange'><b><big><big><big>\n\nWelcome to Nihongo Vacabulary Trainer</big></big></big></b>\n\n</span><span foreground='#FF881C'><b><big><big>Please choose your skill level challenge\n</big></big></b></span>" \
--buttons-layout=center \
--height=900 --fixed \
--button="<span foreground='gold'><b><big>Intermediate</big></b></span>":51 \
--button="<span foreground='#4949B6'><b><big>Hard</big></b></span>":52 \
--button="<span foreground='red'><b><big>Ridiculous</big></b></span>":53
local chosediff=$?
[[ $chosediff -ne 51 && $chosediff -ne 52 && $chosediff -ne 53 ]] && exitprogram
[[ $chosediff -eq 51 ]] && declare -g intermediate=1 && selectsyl1 && exit 1
[[ $chosediff -eq 52 ]] && declare -g hard=1 && selectsyl1 && exit 1
[[ $chosediff -eq 53 ]] && declare -g ridiculous=1 && questioning && exit 1
}
diffsel