diff options
| author | ars <asav1410@gmail.com> | 2020-06-12 21:44:14 +0100 | 
|---|---|---|
| committer | ars <asav1410@gmail.com> | 2020-06-12 21:44:14 +0100 | 
| commit | a40e79917cf4fc322483ca449769adb25b30f7bd (patch) | |
| tree | 4e90b76f19f2fc896bb5d5cbc2c53fc7ee61ba8d | |
Inital commit
| -rwxr-xr-x | oeddefine.sh | 36 | ||||
| -rwxr-xr-x | oedwordday.sh | 22 | 
2 files changed, 58 insertions, 0 deletions
| diff --git a/oeddefine.sh b/oeddefine.sh new file mode 100755 index 0000000..46d06a3 --- /dev/null +++ b/oeddefine.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +read word +word=$(echo $word | tr '[:upper:]' '[:lower:]') +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"' + +# get lemmas to link an inflected form back to its headword (required to get definition) +result=$(eval curl $OPTS $lemmasUrl) +ret=$? +if [ "$ret" -ne 0 ] +then +  echo "cURL error $ret when fetching." +  exit +fi +headWord=$(echo $result | jq '.results[0].lexicalEntries[0].inflectionOf[0].id') +if [ "$headWord" == "null" ] +then +  echo "Word not found." +  exit +fi +entriesUrl=https://od-api.oxforddictionaries.com/api/v2/entries/$language/$headWord + +# get definition of headword +result=$(eval curl $OPTS $entriesUrl) +ret=$? +if [ "$ret" -ne 0 ] +then +  echo "cURL error $ret when fetching." +  exit +fi +definition=$(echo $result | jq '.results[0].lexicalEntries[0].entries[].senses[0].definitions') +echo $definition diff --git a/oedwordday.sh b/oedwordday.sh new file mode 100755 index 0000000..33fcc44 --- /dev/null +++ b/oedwordday.sh @@ -0,0 +1,22 @@ +#!/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 + +# get definition of headword +result=$(eval curl $OPTS $entriesUrl) +ret=$? +if [ "$ret" -ne 0 ] +then +  echo "cURL error $ret when fetching." +  exit +fi +definition=$(echo $result | jq '.results[0].lexicalEntries[0].entries[].senses[0].definitions') +echo $definition | 
