示例#1
0
def running():
    # gets a random source word and displays it
    word_utils.pre_process_words()
    sourceword = word_utils.get_source_word()
    print(sourceword)
    session['sourceword'] = sourceword
    session['start_time'] = time.perf_counter()

    return render_template('running.html',
                           the_title='WordGame',
                           sourceword=sourceword)
示例#2
0
# wordgame.py - the WordGame webapp - by Paul Barry.
# email: [email protected]

import enchant
import time

import data_utils
import word_utils

# Before we do anything else, pre-process the words, then
# update our enchant dictionary.  We do this only ONCE.
# Yes, that's right: these are GLOBAL.
word_utils.pre_process_words()
wordgame_dictionary = enchant.DictWithPWL('en_GB', word_utils.ALL_WORDS)


def check_spellings(words) -> list:
    """Check a list of words for spelling errors.

       Is the word in the dictionary.
       Accepts a list of words and returns a list of tuples,
       with each tuple containing (word, bool) based on
       whether or not the word is spelled correctly."""
    spellings = []
    for w in words:
        spellings.append((w, wordgame_dictionary.check(w)))
    return spellings


if __name__ == '__main__':
    while True: