MCPcopy
hub / github.com/MaartenGr/BERTopic / test_generate_topic_labels

Function test_generate_topic_labels

tests/test_representation/test_labels.py:16–26  ·  view source on GitHub ↗
(model, request)

Source from the content-addressed store, hash-verified

14 ],
15)
16def test_generate_topic_labels(model, request):
17 topic_model = copy.deepcopy(request.getfixturevalue(model))
18 labels = topic_model.generate_topic_labels(topic_prefix=False)
19
20 assert sum([label[0].isdigit() for label in labels[1:]]) / len(labels) < 0.2
21
22 labels = [int(label.split("_")[0]) for label in topic_model.generate_topic_labels()]
23 assert labels == sorted(list(set(topic_model.topics_)))
24
25 labels = topic_model.generate_topic_labels(nr_words=1, topic_prefix=False)
26 assert all([True if len(label) < 15 else False for label in labels])
27
28
29@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 1

generate_topic_labelsMethod · 0.80

Tested by

no test coverage detected