Skip to content

Import

summ.importers.Importer

Importers are responsible for extracting file-like buffers from a data source.

Source code in summ/importers/importer.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Importer:
    """Importers are responsible for extracting file-like buffers from a data source."""

    def __init__(self, dir: Path):
        """A default importer which reads from a directory of text files."""

        self.dir = dir

    @property
    def paths(self) -> Iterable[Path]:
        return self.dir.glob("*.txt")

    @property
    def blobs(self) -> Iterable[TextIO]:
        return map(Path.open, self.paths)

    def docs(self) -> Iterable[Document]:
        return [Document(page_content=blob.read()) for blob in self.blobs]

__init__(dir: Path)

A default importer which reads from a directory of text files.

Source code in summ/importers/importer.py
12
13
14
15
def __init__(self, dir: Path):
    """A default importer which reads from a directory of text files."""

    self.dir = dir