take a word pattern and return a Python regexp. A word pattern is a word
    with unknown letters replaced by a '?', e.g. 'di?ti??nar?'.

def compile_pattern(word):
    """
    take a word pattern and return a Python regexp. A word pattern is a word
    with unknown letters replaced by a '?', e.g. 'di?ti??nar?'.
    """
    return re.compile(r'^%s$' % re.sub(r'\?', '[a-z]',
                                       dicts.sanitize_word(word)))