Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
1from pathlib import Path2from typing import Any, List, Union3 4from langchain_community.document_loaders.unstructured import (5    UnstructuredFileLoader,6    validate_unstructured_version,7)8 9 10class UnstructuredTSVLoader(UnstructuredFileLoader):11    """Load `TSV` files using `Unstructured`.12 13    Like other14    Unstructured loaders, UnstructuredTSVLoader can be used in both15    "single" and "elements" mode. If you use the loader in "elements"16    mode, the TSV file will be a single Unstructured Table element.17    If you use the loader in "elements" mode, an HTML representation18    of the table will be available in the "text_as_html" key in the19    document metadata.20 21    Examples22    --------23    from langchain_community.document_loaders.tsv import UnstructuredTSVLoader24 25    loader = UnstructuredTSVLoader("stanley-cups.tsv", mode="elements")26    docs = loader.load()27    """28 29    def __init__(30        self,31        file_path: Union[str, Path],32        mode: str = "single",33        **unstructured_kwargs: Any,34    ):35        file_path = str(file_path)36        validate_unstructured_version(min_unstructured_version="0.7.6")37        super().__init__(file_path=file_path, mode=mode, **unstructured_kwargs)38 39    def _get_elements(self) -> List:40        from unstructured.partition.tsv import partition_tsv41 42        return partition_tsv(filename=self.file_path, **self.unstructured_kwargs)43 
codekingpro/portable-devtools · Team Ai