Oxford API - tech help needed!

All discussion relevant to Countdown that is not too spoilerific. New members: come here first to introduce yourself. We don't bite, or at least rarely.
Post Reply
Fiona T
Kiloposter
Posts: 1482
Joined: Mon Mar 18, 2019 12:54 pm

Oxford API - tech help needed!

Post by Fiona T »

Any techie folk out there who are bored...

I'm putting something together to return a short definition of a word using the Oxford API. (Happy to supply more details to anyone who needs some motivation to help with this problem!) You can get an API key for free that gives you 3,000 requests per month which should be more than enough for my intended use.

It mostly works pretty well...

The thing I can't work out how to do is search for variants - the things listed under 'also' on the main dictionary page.

so AWHETOS, RHAGADE, PIVA as examples.

These are returned under variantForms in the results on the entries endpoint if you search for the headword - e.g.

Code: Select all

{
  "id": "aweto",
  "metadata": {
    "operation": "retrieve",
    "provider": "Oxford University Press",
    "schema": "RetrieveEntry"
  },
  "results": [
    {
      "id": "aweto",
      "language": "en-gb",
      "lexicalEntries": [
        {
          "entries": [
            {
              "etymologies": [
                "mid 19th century. From Maori āwhato, āwheto any of various large caterpillars, including those affected by the Ophiocordyceps fungus"
              ],
              "senses": [
                {
                  "definitions": [
                    "A caterpillar of a New Zealand porina moth (genus Wiseana, family Hepialidae) that has been infected by the parasitic fungus Ophiocordyceps robertsii, which mummifies the insect below a covering of soil or leaf litter before sending up a slender fruiting body; also called vegetable caterpillar. In later use also: a caterpillar of the same family parasitized by the fungus O. sinensis, found in the highlands of central Asia and used in traditional medicine."
                  ],
                  "id": "m_en_gb_oed13942.002"
                }
              ],
              "variantForms": [
                {
                  "text": "aweta"
                },
                {
                  "text": "awhato"
                },
                {
                  "text": "awheto"
                }
              ]
            }
          ],
          "language": "en-gb",
          "lexicalCategory": {
            "id": "noun",
            "text": "Noun"
          },
          "text": "aweto"
        }
      ],
      "type": "headword",
      "word": "aweto"
    }
  ],
  "word": "aweto"
}
but I can't find a way of getting to this with awheto(s) as the starting point. I thought lemmas were my friend, but that just seems to do inflections not variants (useful for other scenarios but not this!). This affects a surprisingly large number of words in our lexicon and very much limits the usefulness of what I'm trying to build. Typing AWHETOS into the main Oxford premium site takes you to the right page, so I'm guessing it's possible - but I can't find it! There's a pint for you at the next co-event if you can work out how to do it! (I have emailed their support as well...)
Fiona T
Kiloposter
Posts: 1482
Joined: Mon Mar 18, 2019 12:54 pm

Re: Oxford API - tech help needed!

Post by Fiona T »

Update - they got back to me

They suggested using the 'search' function, which works pretty well if the word you're looking for is listed as a variant (e.g. awheto/piva) - returns a match saying it's a variant and gives you the headword to look up.

It works less well for inflections of variants - so awhetos does give aweto as a fuzzy match, but pivas suggests nivas/diva/kiva as better matches than pivo. Can probs work with it, but it's not going to be great....

edit: pivas doesn't work in the main dictionary either - so I guess it's gonna work as well as that - it'll do...
Post Reply