DEV Community

Cover image for How to use a Dictionary API
random
random

Posted on

How to use a Dictionary API

Hey!

Step 1: Get the words

  1. I manually scraped tough English words from the internet and stored it in a json file.

Step 2: Finding a dictionary API

  1. I used the Merriam Webster Dictionary API
  2. Understanding the API seems a bit intimidating..Let's make a request with the API and check out the json response we receive: https://www.dictionaryapi.com/api/v3/references/thesaurus/json/umpire?key=yourkey

Screenshot 2021-01-17 at 8.23.42 PM

So at the topmost level we have 5 keys -

I. meta

Screenshot 2021-01-17 at 8.44.09 PM

  • The key refers to metadata(a shorthand representation of data) and gives a shorthand representation of the word. It contains:
    1. "id" - the word itself (here, "umpire")
    2. "uuid" - universally unique identifier ( a string)
    3. "src" - source data set (like collegiate thesaurus)
    4. "section" - indicates section (alpha - alphabetical, geog - geographic etc..)
    5. "stems" - other words which stem from this word - lists all of the word's variants - querying the API with this word would also return the same response
    6. "syns" - synonyms

II. hwi

Screenshot 2021-01-17 at 8.47.48 PM

  • means head word information
  • "hw" : string headword

III. fl

Screenshot 2021-01-17 at 8.50.24 PM

  • means functional label
  • tells grammatical function(noun, adj etc..)

IV. def

Screenshot 2021-01-17 at 8.59.44 PM

  • groups together all sense sequences and verb dividers(transitive/intransitive)
    1. sseq - sense sequence contains a series of senses Screenshot 2021-01-17 at 9.30.21 PM

sense - a unit which contains all content relevant to a particular meaning
Screenshot 2021-01-17 at 9.31.00 PM

dt - defining text is an array which contains:

  1. ["text", string] - string is definition of word
  2. ["vis", [{object}]] - verbal illustration is an example sentence and each object may contain the members:

"t" : string text of verbal illustration

Screenshot 2021-01-17 at 11.18.41 PM

V. shortdef

a highly abridged version of the main definition section, consisting of just the definition text for the first three senses.

Screenshot 2021-01-17 at 11.21.19 PM

That's all for now.
Bye!
@stratospher

Top comments (0)