I want to know if a word is in the dictionary.
Here is what I am trying.
import requests
def word_in_dictionary(word):
response = requests.get('https://en.wiktionary.org/wiki/'+word)
return response.status_code==200
print(word_in_dictionary('potato')) # True
print(word_in_dictionary('nobblebog')) # False
Run Code Online (Sandbox Code Playgroud)
But unfortunately the dictionary contains a lot of words that are not English and I don't want to match those.
print(word_in_dictionary('bardzo')) # WANT THIS TO BE FALSE
Run Code Online (Sandbox Code Playgroud)
So I tried to look in the content.
def word_in_dictionary(word):
response = requests.get('https://en.wiktionary.org/wiki/'+word)
return response.status_code==200 and 'English' in response.content.decode()
Run Code Online (Sandbox Code Playgroud)
But I …