summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xoedwordday.sh17
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