def get_table_of_contents(self) -> HTMLDocument:
        """Identifies text sections that are likely the table of contents."""
        out_cls = self.__class__
        _raise_for_invalid_filing_type(self.filing_type)
        title_locs = to_sklearn_format(self.elements)
        if len(title_locs) == 0:
            return out_cls.from_elements([])
        # NOTE(alan): Might be a way to do the same thing that doesn't involve the transformations
        # necessary to get it into sklearn. We're just looking for densely packed Titles.
        res = DBSCAN(eps=6.0).fit_predict(title_locs)
        for i in range(res.max() + 1):
            idxs = cluster_num_to_indices(i, title_locs, res)
            cluster_elements: List[Text] = [self.elements[i] for i in idxs]
            if any(
                # TODO(alan): Maybe swap risk title out for something more generic? It helps to
                # have 2 markers though, I think.
                is_risk_title(el.text, self.filing_type)
                for el in cluster_elements
                if isinstance(el, Title)
            ) and any(
                is_toc_title(el.text)
                for el in cluster_elements
                if isinstance(el, Title)
            ):
                return out_cls.from_elements(
                    self._filter_table_of_contents(cluster_elements)
                )
        return out_cls.from_elements(self._filter_table_of_contents(self.elements))
Identifies text sections that are likely the table of contents.
llama-index-integrations/readers/llama-index-readers-sec-filings/llama_index/readers/sec_filings/prepline_sec_filings/sec_document.py