Репозиторий Sisyphus
Последнее обновление: 21 октября 2019 | Пакетов: 17510 | Посещений: 15351736
en ru br
Репозитории ALT
S:0.1-alt6
5.1: 0.1-alt6
4.1: 0.1-alt5
4.0: 0.1-alt5
3.0: 0.1-alt5
www.altlinux.org/Changes

Группа :: Работа с текстами
Пакет: stardict-slovnyk_uk-be

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

#!/bin/sh

if [ $1 ] && [ -f $1 ] && [ $2 ]; then
slovn2dict_words=`mktemp`
slovn2dict_descr=`mktemp`
raw_file=`mktemp`
slovn2dict_head=`mktemp`
cat $1 |\
awk 'BEGIN{x=0;c=""} \
{z=split($0, a, /->/); \
if (z == 2) \
{++x; sub(/^ */,"",a[1]); if (a[1] != c) {print x " " a[1]}; c = a[1]}\
}\
'|iconv -f cp1251 -t utf-8>$slovn2dict_words

cat $1 |\
awk 'BEGIN{x=0;c="";ORS="";} \
{z=split($0, a, /->/); \
if (z == 2) \
{++x; sub(/^ */,"",a[1]); sub(/^ */,"",a[2]); sub(/\r/,"",a[2]);\
if (a[1] != c ) {print "\n" x " "}; \
if (a[1] == c ) {print ", "}; \
print a[2]; c = a[1]}\
}\
'>$slovn2dict_descr
words=`cat $slovn2dict_words|wc -l|awk '{print $1}'`
descr=`cat $slovn2dict_descr|wc -l|awk '{print $1}'`
if [ $words != $descr ]; then
echo "Sorry, but number of words is $words, and number of descr is $descr. It's is a error"
elif [ $words == 0 ]; then
echo "Sorry, but number of words is 0. May be you provide incorrect slovnyk* file"
else
echo Number of words is $words
join $slovn2dict_words $slovn2dict_descr |awk '{sub(/^[0123456789]+ /,"",$0); z=split($0,a,/ /); print a[1] "\n" a[2]}'>$raw_file
LANGUAGE=ru_RU.CP1251 LC_CTYPE=ru_RU.CP1251 oxford2dic $raw_file
size=`stat -c %s oxford.idxdata`
cat << EOF > $2.ifo
StarDict's dict ifo file
version=2.4.2
wordcount=$words
idxfilesize=$size
bookname=$2
sametypesequence=m
EOF
cp oxford.idxdata $2.idx
cp oxford.dict $2.dict
rm -f $slovn2dict_words
rm -f $slovn2dict_descr
rm -f $raw_file
rm -f oxford.idxdata
rm -f oxford.dict
echo "$2 dictionary succesfully created ($words - wordcount)"
fi
elif [ $1 ] && [ ! -f $1 ]; then
echo "Error: Please specify valid inputfile"
echo
elif [ $1 ] && [ -f $1 ] && [ ! $2 ]; then
echo "Error: Please specify outputfile"
echo
else
echo "Using: slovnyk2stardict.sh inputfile outputfile"
echo "where inputfile is dictionary in slovnyk format (cp1251 only)"
echo " outputfile is name of stardict dictionary."
echo
echo "slovnyk dictionaries available here "
echo " http://www.slovnyk.org/prg/gszotar/index.html (project page)"
echo " http://www.slovnyk.org.ua/prg/gszotar/win1251/ (download page)"
fi
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin