def test_threshold(meet_threshold: bool, config: Dict[str, Any]):
    """Tests abstention threshold.
    meet_threshold (bool): Whether to configure NEL setup so that confidence threshold is met.
    config (Dict[str, Any]): NEL architecture config.
    """
    nlp = English()
    nlp.add_pipe("sentencizer")
    text = "Mahler's Symphony No. 8 was beautiful."
    entities = [(0, 6, "PERSON")]
    links = {(0, 6): {"Q7304": 1.0}}
    sent_starts = [1, -1, 0, 0, 0, 0, 0, 0, 0]
    entity_id = "Q7304"
    doc = nlp(text)
    train_examples = [
        Example.from_dict(
            doc, {"entities": entities, "links": links, "sent_starts": sent_starts}
        )
    ]

    def create_kb(vocab):
        # create artificial KB
        mykb = InMemoryLookupKB(vocab, entity_vector_length=3)
        mykb.add_entity(entity=entity_id, freq=12, entity_vector=[6, -4, 3])
        mykb.add_alias(
            alias="Mahler",
            entities=[entity_id],
            probabilities=[1 if meet_threshold else 0.01],
        )
        return mykb

    # Create the Entity Linker component and add it to the pipeline
    entity_linker = nlp.add_pipe(
        "entity_linker",
        last=True,
        config={"threshold": 0.99, "model": config},
    )
    entity_linker.set_kb(create_kb)  # type: ignore
    nlp.initialize(get_examples=lambda: train_examples)

    # Add a custom rule-based component to mimick NER
    ruler = nlp.add_pipe("entity_ruler", before="entity_linker")
    ruler.add_patterns([{"label": "PERSON", "pattern": [{"LOWER": "mahler"}]}])  # type: ignore
    doc = nlp(text)

    assert len(doc.ents) == 1
    assert doc.ents[0].kb_id_ == entity_id if meet_threshold else EntityLinker.NIL
Tests abstention threshold.
    meet_threshold (bool): Whether to configure NEL setup so that confidence threshold is met.
    config (Dict[str, Any]): NEL architecture config.
    
spacy/tests/pipeline/test_entity_linker.py