[ create a new paste ] login | about

Link: http://codepad.org/guhCpl1i    [ raw code | fork ]

Plain Text, pasted on Jan 23:
#!/bin/sh
# Using: sdcv WORD | sdcvp [-e]
# Examples disabled by default for En-Ru and enabled for Ru-En.
# -e option enable examples for En-Ru.
# Parse sdcv Lingvo En-Ru/Ru-En translation output into more short variant.
# Mainly tested with Universal dict, so other dicts could fail.

IFS=""
INPUT=`cat`
ITEMS=`echo $INPUT | grep 'Found .* items' | awk '{print $2}'`

echo $INPUT | sed -n '1 s/Found [0-9]* items, similar to \(.*\)\./\1/p' |
grep [а-яА-Я] >/dev/null && LNG=ru

echo $INPUT |
if [ "$ITEMS" = "1" ]; then
    sed -e '/^-->/d'
else
    sed -e '
        s/^-->/# /
        /LingvoUniversal (En-Ru)/d
    '
fi |
sed -e "
    s/'/'/g
    /^Found .* items/d
    /^$/d
    /^ *[0-9][0-9]*[.)] *$/d
    /^ *- /d
    /^ *•/d
    /^  *\(\(сущ\.\)\|\(прил\.\)\|\(числ\.\)\|\(гл\.\)\|\(нареч\.\)\| \
    \(прич\.\)\|\(числ\.\)\|\(деепр\.\)\|\(арт\.\)\|\(союз$\)\| \
    \(предл\.\)\|\(межд\.\)\|\(частица\)\|\(муж\.\)\|\(жен\.\)\)/s/^  *//
    s/^  */  /
    /^ *[а-я])/s/[а-я]) //
    /^ *[0-9][0-9]*[.)]/s/[0-9][0-9]*[.)] //
    /^ *\[.*\] *$/d
" |
if [ "$LNG" = "ru" ]; then
    sed -e "
        s/^I //
        s/^II //
        s/^III //
        s/^IV //
        s/^V //
        s/^VI //
        s/^VII //
        s/^VIII //
        s/^IX //
        s/^X //
        /^ *[а-яА-Я()][а-яА-Я()]*.* [-—] .*[a-zA-Z][a-zA-Z]*.*/s/^ */    /
    "
else
    sed -e "
        /^I /d
        /^II /d
        /^III /d
        /^IV /d
        /^V /d
        /^VI /d
        /^VII /d
        /^VIII /d
        /^IX /d
        /^X /d
    " |
    case $1 in
        -e) sed -e "
                /^ *[a-zA-Z][a-zA-Z]*.*[-—].*[а-яА-Я][а-яА-Я]*.*/s/^ */    /
                /^ *[a-zA-Z][a-zA-Z,:;-!?\.()0-9 ]*$/d
            " ;;
        *) sed -e "/^ *[a-zA-Z][a-zA-Z,:;-!?\.()0-9]*/d" ;;
    esac
fi



Create a new paste based on this one


Comments: