Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37500465
en ru br
Репозитории ALT
S:1.2-alt6
5.1: 1.2-alt4
4.1: 1.2-alt4
4.0: 1.2-alt4
3.0: 1.2-alt4
www.altlinux.org/Changes

Группа :: Работа с текстами
Пакет: dict-mueller7-utf8

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

#!/bin/sh
# A shell script for conversion of MOVA MuellerXX.koi dictionaries
# into DICT format.
# Written by Andrew Comech <comech@math.sunysb.edu>
# GNU GPL (2000)
# The latest version is available from
# http://www.math.sunysb.edu/~comech/tools/to-dict
# changes for engcom dictionary and dictfmt params by Alexey Dyachenko <alexd@altlinux.ru>
export LANG=C

version="0.3"
versiondate="September 28, 2003"

# We need the following binaries:
DICTFMT=`which dictfmt`
DICTZIP=`which dictzip`

INFO () {
echo "
to-dict, version $version ($versiondate).
Conversion of MOVA MuellerXX.koi dictionaries into DICT format.
Written by Andrew Comech <comech@math.sunysb.edu>. GNU GPL (2000)
Changes for engcom dictionary and dictfmt params by Alexey Dyachenko <alexd@altlinux.ru>

The latest version is available from
http://www.math.sunysb.edu/~comech/tools/to-dict
"
}

REQUIREMENTS () {
echo "
REQUIREMENTS: you need the binaries \`dictfmt' and \`dictzip'.

dictzip.c can be found in dictd-1.5.0.tar.gz (or later version) at
ftp://ftp.cs.unc.edu/pub/users/faith/dict/

dictfmt.c can be found in Debian/GNU Linux package dict-elements at
ftp://ftp.debian.org/debian/dists/potato/main/source/text/

Compiled binaries (dictfmt and dictzip) could be downloaded from
http://www.wh9.tu-dresden.de/~heinrich/dict/dict_leo_ftp/static-binaries/
or
http://iris.ltas.ulg.ac.be/download/apps/dict/
"
}

USAGE () {
echo "
USAGE:
-version: show version
-h, --help, or no parameters: show this help

(*) To make DICT database from Mueller7GPL.koi available from
http://www.chat.ru/~mueller_dic/Mueller7GPL.tgz

# Remove transcription:
./to-dict --no-trans Mueller7GPL.koi mueller7.notr
# Convert <source> into <data> (a file with %h, %d-headers):
./to-dict --src-data mueller7.notr mueller7.data && rm -i mueller7.notr
# Convert <data> into DICT-format (files <name>.dict.dz and <name>.index):
./to-dict --data-dict mueller7.data mueller7 && rm -i mueller7.data
# Expand index file (to be able to access lines like \"A, a\" by \"A\" and \"a\"):
./to-dict --expand-index mueller7.index mueller7.index.exp
# Install a new dictionary with expanded index (RUN AS ROOT).
# The location of files may depend on your distribution!!!
cp mueller7.dict.dz /usr/share/dictd/mueller7.dict.dz
cp mueller7.index.exp /usr/share/dictd/mueller7.index
dictdconfig -w && (killall dictd; dictd)

(*) To make DICT database from Mueller24.koi available from
http://www.chat.ru/~mueller_dic/Mueller24.tgz (this one is preferred)

# Convert <source> into <data> (a file with %h, %d):
./to-dict --src-data Mueller24.koi mueller24.data
# Convert <data> into DICT-format (files <name>.dict.dz and <name>.index):
./to-dict --data-dict mueller24.data mueller24 && rm -i mueller24.data
# Install a new dictionary with expanded index (RUN AS ROOT).
# The location of files may depend on your distribution!!!
cp mueller24.dict.dz /usr/share/dictd/mueller24.dict.dz
cp mueller24.index /usr/share/dictd/mueller24.index
dictdconfig -w && (killall dictd; dictd)

(*) To re-convert <dict> into <data> (a file with %h, %d-headers):

./to-dict --dict-data <dict> <data>

*************************************************************
!!WARNING!! !!WARNING!! !!WARNING!! !!WARNING!!

Temporary files created by this script occupy a lot of drive space!
15 MB for Mueller7GPL.koi (have to strip off transcription first)
12 MB for Mueller24.koi
*************************************************************
"
}

# To remove the transcription except for [r] and [ju:] which found in the text.
# This procedure should not change Mueller24.koi if applied to it.
NO_TRANS () {
sed 's/как\ \[juЫ\]/как\ "ju:"/; s/\[l\],/"l",/g; s/\[r\]/"r"/g; s/\], \[/A/g; s/\]\; _ам\. \[/A/g; s/\]\; _pl\. \[/A/g; s/\[[^]]*\]\ (полн.. форм.). \[[^]]*\] (редуцированн[^)]*)\ //g; s/\[[^]]*\]\ //g; s/\[[^]]*\],\ //; s/\ \[[^]]*\],/,/g; s/\ \[[^]]*\])/)/g; s/\ \[[^]]*\]:/:/g; s/\ \[[^]]*\];/;/g; s/\ \[[^]]*\]$//g; s/как\ "ju:"/как\ \[juЫ\]/g; s/"l"/\[l\]/g; s/"r"/\[r\]/g '
}

# Strip the copyright/info
STRIP () {
sed -n '/^_[aA]/,$p'
}

# Format the file
MK_DATA () {
sed 's/$/\
/g; s/[^]]*\ \ /%h&\
%d/; s/_[IVX][IVX]* /\
&/g; s/ [1-9]\. /\
&/g; s/[1-9][0-9]*>/\
&/g; s/[абвгдежзиклмнопрстуфчцчшхщъьэюя]>/(&>/g; s/>>/)/g; s/\ \_[AISE][a-z]*:/\
&/g; s/>/:/g'\
|sed ' s/%d$/%z/; s/%d/%d\
/ ; s/%z/%d/; s/%h/%h / ' \
|fmt -s -w 74;}

########################################################################

if [ "$1" = "-version" ]; then
INFO
exit 0
fi

if [ "$#" = 0 -o "$1" = "-h" -o "$1" = "--help" -o "$1" = "-help" ]; then
USAGE
exit 0
fi

if [ "$#" != 3 ]; then
USAGE; exit 1;
fi

## Will not go further if there are no dictfmt and dictzip binaries:
if [ "$DICTFMT" = "" -o "$DICTZIP" = "" ]; then
REQUIREMENTS
exit 1
fi
##

if [ ! -f "$2" ]; then
echo "No input file: $2"; USAGE; exit 1
fi

case $1 in
"--no-trans")
echo "Removing transcription ($2 -> $3)..";
cat $2 | NO_TRANS > $3 || exit 1
echo "."; exit 0
;;
"--src-data")
echo "Writing the header of $3.."
echo -e "%h 00-database-info\n%d" > $3
cat $2 | sed -n '1p' | sed 's/^/ /' | fmt -s -w 74 >> $3;
cat $2 | grep "^_" | sed 's/^/ /' | fmt -s -w 74 >> $3;
echo "" >> $3
echo "Formatting data ($2 -> $3).."
cat $2 | sed -n '/^_[aA]/,$p' | MK_DATA >> $3 || exit 1
echo "."; exit 0
;;
"--data-dict")
TITLE=${TITLE="Mueller English-Russian Dictionary"}
URL=${URL="http://www.chat.ru/~mueller_dic"}
echo "dictfmt: $2 -> $3.dict and $3.index.."
dictfmt $DICTFMT_OPT -p -u "$URL" \
-s "$TITLE" $3 < $2 || exit 1
echo "Compressing $3.dict.."; dictzip $3.dict || exit 1
# echo -n "Restarting daemons"; killall dictd; dictd
echo "."; exit 0
;;
"--expand-index")
# So that the line
# ``whisky, whiskey a sort of spirit I like''
# could be found not only by /usr/bin/dict "whisky, whiskey", but also by
# /usr/bin/dict "whisky" and /usr/bin/dict "whiskey"
cat $2 | sed 's/^[^,]*, [^,]*/%TAG1&\
%REM2&\
%TAG3&/; s/^%TAG1[^,]*, /&%REM1/; s/, %REM1[^'$'\t'']*//; s/%REM2[^,]*, //; s/%TAG[13]//g' > $3 || exit 1
exit 0
;;
"--dict-data")
if [ "` file $2 | grep gzip`" != "0" ]; then
CAT=zcat;
else
CAT=cat;
fi
$CAT $2 | sed 's/^[^\ ].*/%h &\
%d/; s/^[\ ][\ ]*/ /' >$3 || exit 1
echo "."; exit 0
;;
*) INFO; USAGE; exit 1
esac

echo "You are not supposed to be here."
exit 1
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin