def _add_metadata(text_analyzer, annotations):
    """
    Add metadata to the annotations.

    :param class text_analyzer: the text_analyzer of nlp_components
    :param dict annotations: annotations made before
    :return dict: annotations with metadata
    """
    metadata = {
        "detected_language": text_analyzer.lang,
        "word_count": len(text_analyzer.words),
        "sentence_count": len(text_analyzer.sentences)
    }
    return {
        **annotations,
        "metadata": metadata
    }