Initialize all global variables (:attr:`.KW_DICT`, :attr:`.KEYWORDS`,
    :attr:`.KEYWORDS_LOWER`, :attr:`.KW_CACHE_PATH`) to their values.

    Global variables are then used from analyzers and so on.

def init():
    """
    Initialize all global variables (:attr:`.KW_DICT`, :attr:`.KEYWORDS`,
    :attr:`.KEYWORDS_LOWER`, :attr:`.KW_CACHE_PATH`) to their values.

    Global variables are then used from analyzers and so on.
    """
    global _INITIALIZED

    if _INITIALIZED:
        return

    global KW_DICT
    global KEYWORDS
    global KW_CACHE_PATH
    global KEYWORDS_LOWER

    KW_DICT = build_kw_dict(read_kw_file())
    KEYWORDS = sorted([k.decode("utf-8") for k in KW_DICT.keys()])
    KEYWORDS_LOWER = {
        k.lower(): k
        for k in KEYWORDS
    }
    keywords_json = json.dumps(KEYWORDS)
    KW_CACHE_PATH = "/tmp/wa_kat_cache_keywords.json"

    # create cached files
    with open(KW_CACHE_PATH, "w") as f:
        f.write(keywords_json)
    with open(KW_CACHE_PATH + ".gz", "w") as f:
        to_gzipped_file(keywords_json, out=f)

    _INITIALIZED = True