Search filter

nhayes264nhayes264 Member

Is there a way to filter out lemma that do not have definitions? There are several situations in which a search result does not have an accompanied definition.

My only recourse as of now is to make expensive API calls on each search result item and check the entries endpoint to filter out lemma without definitions.

For example:
https://od-api-demo.oxforddictionaries.com:443/api/v1/entries/en/insipidly

    {
      "metadata": {
        "provider": "Oxford University Press"
      },
      "results": [
        {
          "id": "insipidly",
          "language": "en",
          "lexicalEntries": [
            {
              "derivativeOf": [
                {
                  "id": "insipid",
                  "text": "insipid"
                }
              ],
              "entries": [
                {
                  "grammaticalFeatures": [
                    {
                      "text": "Positive",
                      "type": "Degree"
                    }
                  ],
                  "homographNumber": "000"
                }
              ],
              "language": "en",
              "lexicalCategory": "Adverb",
              "pronunciations": [
                {
                  "audioFile":  "http://audio.oxforddictionaries.com/en/mp3/insipidly_gb_1.mp3",
                  "dialects": [
                    "British English"
                  ],
                  "phoneticNotation": "IPA",
                  "phoneticSpelling": "ɪnˈsɪpɪdli"
                }
              ],
              "text": "insipidly"
            }
          ],
          "type": "headword",
          "word": "insipidly"
        }
      ]
    } 

Comments

  • AmosDuveenAmosDuveen Member, Administrator, Moderator admin

    Hi @nhayes264,

    I'm not sure what you mean by "expensive" as any call (except wordlists) costs you the same in terms of your usage; was it a reference to system resources or ISP data charges, maybe?

    To answer your question directly, you could use the definitions filter e.g. https://od-api.oxforddictionaries.com:443/api/v1/entries/en/insipidly/definitions (no definition) will return a 404 error wheras https://od-api.oxforddictionaries.com:443/api/v1/entries/en/insipid/definitions (with definition) will go through fine.

    Personally, I'm always a little cautious about this type of request because (as with any specialized occupation) we often have very precise meanings for terms that might mean something much more broad in common usage. As a result, users don't always realise the amount of useful content that is not contained within a definition element. I would recommend continuing to make full entry calls while you are developing your code because you may well find that some content you want is actually be located elsewhere in the structure.

  • nhayes264nhayes264 Member

    If I could just apply a filter to the search results, I wouldn't have to make several additional calls to the entries endpoint when performing searches. Right now, after a user performs a search, I have to call the entries endpoint on every single search result item.

  • AmosDuveenAmosDuveen Member, Administrator, Moderator admin

    Hi @nhayes264,

    What is it that you are actually trying to do with your app?

  • nhayes264nhayes264 Member

    Users have a list of words they are trying to learn. They search for a word and press "Add Word" to add it to their list.

    So if some of the search results that are shown don't have definitions, then it means that when the user presses "Add Word", the app will break.

  • AmosDuveenAmosDuveen Member, Administrator, Moderator admin

    Hi @nhayes264,

    I think you need to assess the value of entries such as https://od-api.oxforddictionaries.com:443/api/v1/entries/en/went and https://od-api.oxforddictionaries.com:443/api/v1/entries/en/telly (neither have a definition) to judge what you would lose by their omission.

    If you are happy with those and similar omissions then each time a user wants to add a word to their list, put a call through the definitions filter to tell you whether it contains a definition (result) or not (404 error) before adding it to the list.

    Alternatively, if you judge that the content for went and telly is indeed worthwhile, put a call into the search endpoint and, if there is a direct hit, add that word, otherwise offer the user the listed suggestions (or a selection thereof) to choose from.

  • shahoodshahood Member ✭✭
    edited July 2018

    @nhayes264 In my app (still a work in progress), I'm using derivativeOf to cover such cases. I tell the users that the searched word is a derivative of another word and provide that other word as a clickable link. Upon clicking, the user is taken to that word where they may add it to their list. This way u may easily save your app from crashing.

    So in case they search for Insipidly, I'll show them "See Insipid" in definitions area; they can go ahead and click on Insipid if they want. Also, just like a normal word, I show lexicalCategory, phoneticSpelling and audioFile link for Inspidly.
    Following screenshots will explain better:



    I hope it would help resolve this problem of yours.

    Good luck!

Sign In or Register to comment.