From 0e0be4892ca1ab6af60e1e2067b098b98e8de466 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 2 Sep 2013 16:34:52 +0200 Subject: util bin dic: initial import from the past --- util/bin/dic | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 util/bin/dic (limited to 'util/bin') diff --git a/util/bin/dic b/util/bin/dic new file mode 100755 index 00000000..d9f0a77f --- /dev/null +++ b/util/bin/dic @@ -0,0 +1,84 @@ +#! /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 + +# all three are used by GET +search="$1" +langlang="${2-en}de" +lang="de" + +main() { + 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 + + ' +} + +main "$@" +exit + + #s|\([^<]\|<[^/]\|]\)*|\nREPR: &\n|g + #s/]*>//g + #s/<[^>]*>//g +| { + IFS="`printf '\t'`" + while read a b; do + printf '%30s %-30s\n' "$a" "$b" + done +} +} +#| tr -d \\n | +#tr \\n +#s/^REPR: /en:/; +#s/^REPR: /de:/; -- cgit v1.2.3