Return a list of patterns compiled from the RDF/SKOS ontology.

    Uses cache if it exists and if the taxonomy hasn't changed.

def get_regular_expressions(taxonomy_name, rebuild=False, no_cache=False):
    """Return a list of patterns compiled from the RDF/SKOS ontology.

    Uses cache if it exists and if the taxonomy hasn't changed.
    """
    # Translate the ontology name into a local path. Check if the name
    # relates to an existing ontology.
    onto_name, onto_path, onto_url = _get_ontology(taxonomy_name)
    if not onto_path:
        raise TaxonomyError("Unable to locate the taxonomy: '%s'."
                            % taxonomy_name)

    cache_path = _get_cache_path(onto_name)
    current_app.logger.debug(
        'Taxonomy discovered, now we load it '
        '(from cache: %s, onto_path: %s, cache_path: %s)'
        % (not no_cache, onto_path, cache_path)
    )

    if os.access(cache_path, os.R_OK):
        if os.access(onto_path, os.R_OK):
            if rebuild or no_cache:
                current_app.logger.debug(
                    "Cache generation was manually forced.")
                return _build_cache(onto_path, skip_cache=no_cache)
        else:
            # ontology file not found. Use the cache instead.
            current_app.logger.warning(
                "The ontology couldn't be located. However "
                "a cached version of it is available. Using it as a "
                "reference."
            )
            return _get_cache(cache_path, source_file=onto_path)

        if (os.path.getmtime(cache_path) >
                os.path.getmtime(onto_path)):
            # Cache is more recent than the ontology: use cache.
            current_app.logger.debug(
                "Normal situation, cache is older than ontology,"
                " so we load it from cache"
            )
            return _get_cache(cache_path, source_file=onto_path)
        else:
            # Ontology is more recent than the cache: rebuild cache.
            current_app.logger.warning(
                "Cache '%s' is older than '%s'. "
                "We will rebuild the cache" %
                (cache_path, onto_path)
            )
            return _build_cache(onto_path, skip_cache=no_cache)

    elif os.access(onto_path, os.R_OK):
        if not no_cache and\
                os.path.exists(cache_path) and\
                not os.access(cache_path, os.W_OK):
            raise TaxonomyError('We cannot read/write into: %s. '
                                'Aborting!' % cache_path)
        elif not no_cache and os.path.exists(cache_path):
            current_app.logger.warning(
                'Cache %s exists, but is not readable!' % cache_path)
        current_app.logger.info(
            "Cache not available. Building it now: %s" % onto_path)
        return _build_cache(onto_path, skip_cache=no_cache)

    else:
        raise TaxonomyError("We miss both source and cache"
                            " of the taxonomy: %s" % taxonomy_name)