<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_matches(pattern, language, max_count=8):
 """ take a word pattern or a Python regexp and a language name, and return a list of all matching words. """

    if str(pattern) == pattern:
        pattern = compile_pattern(pattern)

    results = []

    if not dicts.exists(language):
        print("The language '%s' is not available locally." % language)
        return []

    with open(dicts.filepath(language), 'r') as f:
        for word in f:
            if max_count <= 0:
                break
            w = word.strip()
            if pattern.match(w) and w not in results:
                results.append(w)
                max_count -= 1

    return results