#!/bin/sh

mkdirhier dics
mkdirhier dl
mkdirhier docs
mkdirhier tmp

#EDICT
wget -c http://ftp.cc.monash.edu.au/pub/nihongo/edict.gz -O dl/edict.gz
gunzip   <dl/edict.gz >tmp/edict
iconv -c -f EUC-JP -t UTF-8 tmp/edict -o dics/edict

#Japanese Names
wget -c http://ftp.cc.monash.edu.au/pub/nihongo/enamdict.gz -O dl/enamdict.gz
gunzip   <dl/enamdict.gz >tmp/enamdict
iconv -c -f EUC-JP -t UTF-8 tmp/enamdict -o dics/enamdict

#Kanjidic
wget -c http://ftp.cc.monash.edu.au/pub/nihongo/kanjidic.gz -O dl/kanjidic.gz
gunzip   <dl/kanjidic.gz >tmp/kanjidic
iconv -c -f EUC-JP -t UTF-8 tmp/kanjidic -o dics/kanjidic

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/jddict.v02.gz -O dl/jddict.gz
gunzip   <dl/jddict.gz >tmp/jddict
iconv -c -f EUC-JP -t UTF-8 tmp/jddict -o dics/jddict

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/compdic.gz -O dl/compdic.gz
gunzip   <dl/compdic.gz >tmp/compdic
iconv -c -f EUC-JP -t UTF-8 tmp/compdic -o dics/compdic

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/engscidic.gz -O dl/engscidic.gz
gunzip   <dl/engscidic.gz >tmp/engscidic
iconv -c -f EUC-JP -t UTF-8 tmp/engscidic -o dics/engscidic

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/j_places.gz -O dl/j_places.gz
gunzip   <dl/j_places.gz >tmp/j_places
iconv -c -f EUC-JP -t UTF-8 tmp/j_places -o dics/j_places

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/geodic.gz -O dl/geodic.gz
gunzip   <dl/geodic.gz >tmp/geodic
iconv -c -f EUC-JP -t UTF-8 tmp/geodic -o dics/geodic

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/compverb.gz -O dl/compverb.gz
gunzip   <dl/compverb.gz >tmp/compverb
iconv -c -f EUC-JP -t UTF-8 tmp/compverb -o dics/compverb

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/4jwords.gz -O dl/4jwords.gz
gunzip   <dl/4jwords.gz >tmp/4jwords
iconv -c -f EUC-JP -t UTF-8 tmp/4jwords -o dics/4jwords

#########Uncompressed######
#this doesn't work well, because of it's bad format.
#wget -c http://ftp.cc.monash.edu.au/pub/nihongo/pandpgls.euc -O dl/pandpgls
#iconv -c -f EUC-JP -t UTF-8 dl/pandpgls -o dics/pandpgls

##BAD FORMAT
#wget -c http://ftp.cc.monash.edu.au/pub/nihongo/lawgloss.euc -O dl/lawgloss
#iconv -c -f EUC-JP -t UTF-8 dl/lawgloss -o dics/lawgloss

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/jisterme.wip -O dl/jisterme
iconv -c -f EUC-JP -t UTF-8 dl/jisterme -o dics/jisterme


#ZIP
wget -c http://ftp.cc.monash.edu.au/pub/nihongo/ediclsd3.zip -O dl/ediclsd3.zip
unzip -o  dl/ediclsd3.zip -d tmp
iconv -c -f EUC-JP -t UTF-8 tmp/ediclsd3 -o dics/ediclsd3
mv tmp/readme-e.euc docs/ediclsd_en.txt
mv tmp/readme-j.euc docs/ediclsd_ja.txt

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/classical.zip -O dl/classical.zip
unzip -o  dl/classical.zip -d tmp
iconv -c -f EUC-JP -t UTF-8 tmp/classical -o dics/classical
mv tmp/classical.euc docs/classical.txt

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/lingdic.zip -O dl/lingdic.zip
unzip -o  dl/lingdic.zip -d tmp
iconv -c -f EUC-JP -t UTF-8 tmp/lingdic -o dics/lingdic
mv tmp/lingdic.txt docs/lingdic.txt

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/forsdic.zip -O dl/forsdic.zip
unzip -o  dl/forsdic.zip -d tmp
iconv -c -f EUC-JP -t UTF-8 tmp/forsdic_e -o dics/forsdic
mv tmp/forsdic_e_doc.txt docs/forsdic.txt

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/aviation.zip -O dl/aviation.zip
unzip -o  dl/aviation.zip -d tmp
iconv -c -f EUC-JP -t UTF-8 tmp/aviation -o dics/aviation
mv tmp/aviation.txt docs/aviation.txt

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/concrete.zip -O dl/concrete.zip
unzip -o  dl/concrete.zip -d tmp
iconv -c -f EUC-JP -t UTF-8 tmp/concrete -o dics/concrete
mv tmp/concrete.doc docs/concrete.txt

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/findic.zip -O dl/findic.zip
unzip -o  dl/findic.zip -d tmp
iconv -c -f EUC-JP -t UTF-8 tmp/findic -o dics/findic
mv tmp/findic.doc docs/findic.txt

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/mktdic.zip -O dl/mktdic.zip
unzip -o  dl/mktdic.zip -d tmp
iconv -c -f EUC-JP -t UTF-8 tmp/mktdic -o dics/mktdic
mv tmp/mktdic.doc docs/mktdic.txt

wget -c http://ftp.cc.monash.edu.au/pub/nihongo/stardict.zip -O dl/stardict.zip
unzip -o  dl/stardict.zip -d tmp
iconv -c -f EUC-JP -t UTF-8 tmp/stardict -o dics/stardict

rm -rf tmp

echo ""
echo ""
echo "---------------------------"
echo UTF-8 Dicfiles are in dics/
echo "---------------------------"
