Whitaker's Online Dictionary Commandline Unix Script

By bathtime, in 'Latin Language Resources', Feb 21, 2018.

  1. bathtime Member

    This is an extremely simple script that runs in Linux terminal. It grabs your word and opens a URL to Whitaker's Latin Dictionary to fetch it. No install is required.

    latin.sh
    Code:
    #!/bin/sh
     
    URL="http://www.archives.nd.edu/cgi-bin/wordz.pl?keyword=$1"
     
    wget -q -O- "$URL" | awk 'NR>3 {print prev} {prev = $0}' | grep -o '[^,]*$'
    Grant executable permissions:
    Code:
    $ chmod +x latin.sh
    Run and search for amo:
    Code:
    $ ./latin amo
    Result:
    Code:
    am.o                V      1 1 PRES ACTIVE  IND 1 S   
    amatus  V  [XXXAO] 
    like; fall in love with; be fond of; have a tendency to;

    I'll be taking a look at perhaps making Perseus do the same.

    Enjoy! :)
    Quasus likes this.
  2. bathtime Member

    Okay, here is the first part of Perseus done:

    It will grab the different definitions and the forms of the word searched:

    perseus
    Code:
    #!/bin/sh
     
    URL="http://www.perseus.tufts.edu/hopper/morph?l=$1&la=la"
     
    wFIN='<h4 class="la">'
    wFOUT='</h4>'
     
    wDefIn='<span class="lemma_definition">'
    wDefOut='</span>'
     
    wFormIn='<td class="la">'$1'</td>'
    wFormOut='<td style="font-size: x-small">'
     
    wget -q -O- "$URL" | mawk -v vDefIn="$wDefIn" -v vDefOut="$wDefOut" -v vFormIn="$wFormIn" -v vFormOut="$wFormOut" -v vWFIN="$wFIN" -v vWFOUT="$wFOUT" \
    '$0 ~ vWFIN,$0 ~ vWFOUT {printf "\n[" substr($0,18, length($0)-22)"]"}   $0 ~ vDefIn,$0 ~ vDefOut {{ if (!/>/) {{$1=$1}1; print " "$0;} }}   $0 ~ vFormIn,$0 ~ vFormOut {{ if (!/td /) {{$1=$1}1;   $0=substr($0,5, length($0)-9); print "-"$0;   } } }'
     
    echo
    Program in action:

    Code:
    $ ./perseus cum
     
    [Cos2] Apelles
    -noun sg fem acc
    -noun pl fem gen poetic
     
    [Cum2] when, at the time when
    -prep indeclform
    -conj indeclform
     
    [cos] a flint-stone, whetstone, grindstone
    -noun sg fem acc
    -noun pl fem gen poetic
     
    [cum] with, together with, in the company of, in connection with, along with, together, and
    -prep indeclform
    -conj indeclform
     
    $
    Quasus likes this.

Share This Page

 

Our Latin forum is a community for discussion of all topics relating to Latin language, ancient and medieval world.

Latin Boards on this Forum:

English to Latin, Latin to English translation, general Latin language, Latin grammar, Latine loquere, ancient and medieval world links.