Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
1"""Loads Microsoft Excel files."""2 3from pathlib import Path4from typing import Any, List, Union5 6from langchain_community.document_loaders.unstructured import (7    UnstructuredFileLoader,8    validate_unstructured_version,9)10 11 12class UnstructuredXMLLoader(UnstructuredFileLoader):13    """Load `XML` file using `Unstructured`.14 15    You can run the loader in one of two modes: "single" and "elements".16    If you use "single" mode, the document will be returned as a single17    langchain Document object. If you use "elements" mode, the unstructured18    library will split the document into elements such as Title and NarrativeText.19    You can pass in additional unstructured kwargs after mode to apply20    different unstructured settings.21 22    Examples23    --------24    from langchain_community.document_loaders import UnstructuredXMLLoader25 26    loader = UnstructuredXMLLoader(27        "example.xml", mode="elements", strategy="fast",28    )29    docs = loader.load()30 31    References32    ----------33    https://unstructured-io.github.io/unstructured/bricks.html#partition-xml34    """35 36    def __init__(37        self,38        file_path: Union[str, Path],39        mode: str = "single",40        **unstructured_kwargs: Any,41    ):42        file_path = str(file_path)43        validate_unstructured_version(min_unstructured_version="0.6.7")44        super().__init__(file_path=file_path, mode=mode, **unstructured_kwargs)45 46    def _get_elements(self) -> List:47        from unstructured.partition.xml import partition_xml48 49        return partition_xml(filename=self.file_path, **self.unstructured_kwargs)50 
codekingpro/portable-devtools · Team Ai