diff options
author | ars <asav1410@gmail.com> | 2020-10-16 14:08:15 +0100 |
---|---|---|
committer | ars <asav1410@gmail.com> | 2020-10-16 14:08:15 +0100 |
commit | eb4becd0407063213b2394df490014c6074d609b (patch) | |
tree | 87f432a90e9ab6738d887445d46e2389af8e9a54 /oedwordday.sh | |
parent | a40e79917cf4fc322483ca449769adb25b30f7bd (diff) |
Add word, and lexical category output. Clean up existing output.
Diffstat (limited to 'oedwordday.sh')
-rwxr-xr-x | oedwordday.sh | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/oedwordday.sh b/oedwordday.sh index 33fcc44..d54d403 100755 --- a/oedwordday.sh +++ b/oedwordday.sh @@ -1,11 +1,9 @@ #!/bin/bash - word=$( curl --silent https://www.lexico.com/ | hxnormalize -x | hxselect -i "a.linkword" | grep -o '>.*<' | sed 's/[><]//g') appId= key= language=en-gb -lemmasUrl=https://od-api.oxforddictionaries.com/api/v2/lemmas/$language/$word OPTS='--silent -L -H "app_id: $appId" -H "app_key: $key"' entriesUrl=https://od-api.oxforddictionaries.com/api/v2/entries/$language/$word @@ -18,5 +16,16 @@ then echo "cURL error $ret when fetching." exit fi -definition=$(echo $result | jq '.results[0].lexicalEntries[0].entries[].senses[0].definitions') -echo $definition + +# Get first definition from received json +definition=$(echo $result | jq '.results[].lexicalEntries[].entries[0].senses[0].definitions[]') + +# Get lexical category for first definition +lexicalCategory=$(echo $result | jq '.results[].lexicalEntries[0].lexicalCategory.text') + +# Remove surrounding quotes +definition=$(echo "${definition:1: -1}") +lexicalCategory=$(echo "${lexicalCategory:1: -1}") + +# Return word, lexical category and first definition. +echo ${word^}" - "$lexicalCategory" - "$definition |