Check existence of English infinitives efficiently

Hello there,
I use the API for research purposes. I have to one-time check, if 96’288 infinitives exist in the English lexicon. Most of them (approximately 80 %) will not exist in the English lexicon. The infinitives are in fact German verb stems. I use the lemma endpoint and python.
According to several tutorials in this forum I decided to use the status code to check if a word_id exists or not.
I would like to hear from you if the following approach is the most recommended and efficient way of doing this.
Consider this: The API receives status code 200 for 'hoer' although it's not a verb. this is true for other word_id's that exist in other lexical categories. How can I handle this?

#!/usr/bin/env python
# coding: utf-8

# This script checks if input list inf_sql_string exist as verbs in English part of lemma endpoint of the Oxford English Dictionary (OED). The output is 'FALSE' for non-existing words and input=output if the word exists. 

import requests
import json

#input
inf_sql_string = ['zeig', 'frag', 'koenn', 'hoer']

#define function for looking up input in OED API
def LookupInOED(lookup_lemma):
    url = url_consistent + 'lemmas/'  + language + '/'  + lookup_lemma.lower() + '?lexicalCategory=' + 'verb' 
    r = requests.get(url, headers = {'app_id' : app_id, 'app_key' : app_key})
    status_code = r.status_code
    if status_code == 200:
        result_lemma = lookup_lemma
    else:
        result_lemma = 'FALSE'
    return result_lemma

# consistent informations for API of OED (put your credentials here)
app_id = ' '
app_key = ' '
language = 'en'

url_consistent = 'https://od-api.oxforddictionaries.com:443/api/v2/'

# process with OED API
for lemma in inf_sql_string:
    result_lemma = LookupInOED(lemma) # look up in OED
    print(result_lemma)

Comments

Sign In or Register to comment.