summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xoedquery.sh23
1 files 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() {