From 4858b91a264323750519bc2d2f6c75e509e15a54 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 11 Nov 2016 12:04:22 +0100 Subject: import from painload 35ccac7 --- dic | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 dic diff --git a/dic b/dic new file mode 100755 index 0000000..b3dac84 --- /dev/null +++ b/dic @@ -0,0 +1,78 @@ +#! /bin/sh +# usage: dic WORD [LANG] +# where LANG may be one of en, fr, es, it, ch, ru, pt, pl +# multiple WORDs may be seperated by + like this: multiple+words +set -euf + +main() { + + case $# in + 1|2) :;; # ok + *) usage; exit 23;; + esac + + # all three are used by GET + search="$1" + langlang="${2-en}de" + lang="de" + + GET | simplify | tac +} + +GET() { + curl -sS -b 'LEOABTEST=T; browser=webkit%3B5%3Bajax' \ + "https://dict.leo.org/dictQuery/m-vocab/$langlang/query.xml?tolerMode=nof&lp=$langlang&lang=$lang&rmWords=off&rmSearch=on&search=$search&searchLoc=0&resultOrder=basic&multiwordShowSingle=on" +} + +simplify() { + sed ' + s||\nREPR: |g + s||\n|g + ' | grep ^REPR | + sed ' + s/^REPR: // + 1~2{s/$//} + 2~2{s/$//} + ' | + tr -d \\n | + sed ' + s// - /g + s//\n/g + + #q + + s/⇔/⇔/g + s/ / /g; #   + s/ */ /g + + # + s/ *//g + + s| *|/|g + s| *|/|g + + s:1:¹:g; s:2:²:g; s:3:³:g; + s::^(:g + s::):g + + s:0:₀:g; + s:1:₁:g; s:2:₂:g; s:3:₃:g; + s:4:₄:g; s:5:₅:g; s:6:₆:g; + s:7:₇:g; s:8:₈:g; s:9:₉:g; + s::_(:g + s::):g + + s: *::g + s: *::g + + s| *||g + s| *||g + + ' +} + +usage() { + sed -rn '/^# usage:/,/^[^#]/{/^#/{s/# //;p}}' "$0" >&2 +} + +main "$@" -- cgit v1.2.3