Test issue that arises when too many labels are added to NER model. Used to cause segfault.
()
| 117 | |
| 118 | @pytest.mark.issue(2800) |
| 119 | def test_issue2800(): |
| 120 | """Test issue that arises when too many labels are added to NER model. |
| 121 | Used to cause segfault. |
| 122 | """ |
| 123 | nlp = English() |
| 124 | train_data = [] |
| 125 | train_data.extend( |
| 126 | [Example.from_dict(nlp.make_doc("One sentence"), {"entities": []})] |
| 127 | ) |
| 128 | entity_types = [str(i) for i in range(1000)] |
| 129 | ner = nlp.add_pipe("ner") |
| 130 | for entity_type in list(entity_types): |
| 131 | ner.add_label(entity_type) |
| 132 | optimizer = nlp.initialize() |
| 133 | for i in range(20): |
| 134 | losses = {} |
| 135 | random.shuffle(train_data) |
| 136 | for example in train_data: |
| 137 | nlp.update([example], sgd=optimizer, losses=losses, drop=0.5) |
| 138 | |
| 139 | |
| 140 | @pytest.mark.issue(3209) |
nothing calls this directly
no test coverage detected
searching dependent graphs…