25 lines
580 B
Python
25 lines
580 B
Python
# Words in dictionary
|
|
words = set()
|
|
|
|
|
|
def check(word):
|
|
"""Return true if word is in dictionary else false"""
|
|
return word.lower() in words
|
|
|
|
|
|
def load(dictionary):
|
|
"""Load dictionary into memory, returning true if successful else false"""
|
|
with open(dictionary) as file:
|
|
words.update(file.read().splitlines())
|
|
return True
|
|
|
|
|
|
def size():
|
|
"""Returns number of words in dictionary if loaded else 0 if not yet loaded"""
|
|
return len(words)
|
|
|
|
|
|
def unload():
|
|
"""Unloads dictionary from memory, returning true if successful else false"""
|
|
return True
|