diff options
author | ars <asav1410@gmail.com> | 2020-10-28 18:43:10 +0000 |
---|---|---|
committer | ars <asav1410@gmail.com> | 2020-10-28 18:43:10 +0000 |
commit | 57a6c030699b7a8770bca872cdc31dd3bd68ee60 (patch) | |
tree | 74381256d385798915a1eedaf4cbc3e289f0ba34 /oedquery.sh | |
parent | 74b7e8e734badb48e591eb2a0fc9449b8ef51675 (diff) |
Fallback to shortDefinition if definition isn't available.
Diffstat (limited to 'oedquery.sh')
-rwxr-xr-x | oedquery.sh | 9 |
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 |