MCPcopy Create free account
hub / github.com/MaartenGr/BERTopic / get_topics

Method get_topics

bertopic/_bertopic.py:1598–1620  ·  view source on GitHub ↗

Return topics with top n words and their c-TF-IDF score. Arguments: full: If True, returns all different forms of topic representations for each topic, including aspects Returns: self.topic_representations_: The top n words per topic and th

(self, full: bool = False)

Source from the content-addressed store, hash-verified

1596 self._create_topic_vectors()
1597
1598 def get_topics(self, full: bool = False) -> Mapping[str, Tuple[str, float]]:
1599 """Return topics with top n words and their c-TF-IDF score.
1600
1601 Arguments:
1602 full: If True, returns all different forms of topic representations
1603 for each topic, including aspects
1604
1605 Returns:
1606 self.topic_representations_: The top n words per topic and the corresponding c-TF-IDF score
1607
1608 Examples:
1609 ```python
1610 all_topics = topic_model.get_topics()
1611 ```
1612 """
1613 check_is_fitted(self)
1614
1615 if full:
1616 topic_representations = {"Main": self.topic_representations_}
1617 topic_representations.update(self.topic_aspects_)
1618 return topic_representations
1619 else:
1620 return self.topic_representations_
1621
1622 def get_topic(self, topic: int, full: bool = False) -> Union[Mapping[str, Tuple[str, float]], bool]:
1623 """Return top n words for a specific topic and their c-TF-IDF scores.

Callers 5

_reduce_topicsMethod · 0.95
test_full_modelFunction · 0.80
test_get_topicsFunction · 0.80
visualize_topicsFunction · 0.80
visualize_hierarchyFunction · 0.80

Calls 1

check_is_fittedFunction · 0.90

Tested by 2

test_full_modelFunction · 0.64
test_get_topicsFunction · 0.64