From 57a6c030699b7a8770bca872cdc31dd3bd68ee60 Mon Sep 17 00:00:00 2001 From: ars Date: Wed, 28 Oct 2020 18:43:10 +0000 Subject: Fallback to shortDefinition if definition isn't available. --- oedquery.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/oedquery.sh b/oedquery.sh index 239d2cf..49f0bfa 100755 --- a/oedquery.sh +++ b/oedquery.sh @@ -63,7 +63,14 @@ _define() { 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]') " + # Sometimes there's no definition and so we can fall back to shortDefinition + definition=$(_jq '.entries[0].senses[0].definitions[0]') + if [[ -z $defintion ]] + then + definition=$(_jq '.entries[0].senses[0].shortDefinitions[0]') + fi + output="$output $definition " examplePhrase=$(_jq '.entries[0].senses[0].examples[0].text') if [[ "$examplePhrase" != "null" ]] then -- cgit v1.2.3