Test that evaluate works with a multilabel textcat pipe.
(en_vocab)
| 130 | |
| 131 | |
| 132 | def test_evaluate_textcat_multilabel(en_vocab): |
| 133 | """Test that evaluate works with a multilabel textcat pipe.""" |
| 134 | nlp = Language(en_vocab) |
| 135 | textcat_multilabel = nlp.add_pipe("textcat_multilabel") |
| 136 | for label in ("FEATURE", "REQUEST", "BUG", "QUESTION"): |
| 137 | textcat_multilabel.add_label(label) |
| 138 | nlp.initialize() |
| 139 | |
| 140 | annots = {"cats": {"FEATURE": 1.0, "QUESTION": 1.0}} |
| 141 | doc = nlp.make_doc("hello world") |
| 142 | example = Example.from_dict(doc, annots) |
| 143 | scores = nlp.evaluate([example]) |
| 144 | labels = nlp.get_pipe("textcat_multilabel").labels |
| 145 | for label in labels: |
| 146 | assert scores["cats_f_per_type"].get(label) is not None |
| 147 | for key in example.reference.cats.keys(): |
| 148 | if key not in labels: |
| 149 | assert scores["cats_f_per_type"].get(key) is None |
| 150 | |
| 151 | |
| 152 | def test_evaluate_multiple_textcat_final(en_vocab): |
nothing calls this directly
no test coverage detected
searching dependent graphs…