summaryrefslogtreecommitdiff
path: root/oedquery.sh
diff options
context:
space:
mode:
authorars <asav1410@gmail.com>2020-10-28 18:43:10 +0000
committerars <asav1410@gmail.com>2020-10-28 18:43:10 +0000
commit57a6c030699b7a8770bca872cdc31dd3bd68ee60 (patch)
tree74381256d385798915a1eedaf4cbc3e289f0ba34 /oedquery.sh
parent74b7e8e734badb48e591eb2a0fc9449b8ef51675 (diff)
Fallback to shortDefinition if definition isn't available.
Diffstat (limited to 'oedquery.sh')
-rwxr-xr-xoedquery.sh9
1 files changed, 8 insertions, 1 deletions
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