From 53e646a1fd27735ada7ce1f0d23bf5cf1009ee50 Mon Sep 17 00:00:00 2001 From: ars Date: Wed, 21 Oct 2020 22:45:57 +0100 Subject: most of the stuff in _wod was already being done in _define so move everything there. --- oedquery.sh | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/oedquery.sh b/oedquery.sh index b99cf0a..a255839 100755 --- a/oedquery.sh +++ b/oedquery.sh @@ -64,10 +64,14 @@ _getdata() { # Return definition for the first sense of each lexical entry and create output string _define() { _getdata + if [[ $wod == true ]] + then + output="$output $word - " + fi for json in $(echo "${result}" | jq -r '.results[].lexicalEntries[] | @base64') do output="$output $(_jq '.lexicalCategory.text'): " - output="$output $(_jq '.entries[0].senses[0].definitions[0]'). " + output="$output $(_jq '.entries[0].senses[0].definitions[0]') " examplePhrase=$(_jq '.entries[0].senses[0].examples[0].text') if [[ "$examplePhrase" != "null" ]] then @@ -132,24 +136,11 @@ _audio() { # Return first defintion with lexical category for Lexico's word of the day. _wod() { + wod=true # Get word from lexico word=$( curl --silent https://www.lexico.com/ | hxnormalize -x | hxselect -i "a.linkword" | grep -o '>.*<' | sed 's/[><]//g') _getdata - definition=$(echo $result | jq '.results[].lexicalEntries[].entries[0].senses[0].definitions[]') - lexicalCategory=$(echo $result | jq '.results[].lexicalEntries[0].lexicalCategory.text') - examplePhrase=$(echo $result | jq '.results[].lexicalEntries[0].entries[0].senses[0].examples[0].text') - # Remove surrounding quotes - definition=$(echo "${definition:1: -1}") - lexicalCategory=$(echo "${lexicalCategory:1: -1}") - # Don't output example sentence if not returned from OED - if [[ "$examplePhrase" != "null" ]] - then - output=$word" - "$lexicalCategory" - "$definition" - "$examplePhrase - else - output=$word" - "$lexicalCategory" - "$definition - fi - echo $output - exit 0 + _define } _help() { -- cgit v1.2.3