loader

package
v0.0.0-beta.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBinaryFile = fmt.Errorf("file appears to be binary")

ErrBinaryFile is returned when a file appears to contain binary content.

Functions

func SupportedExtensions

func SupportedExtensions() []string

SupportedExtensions returns all supported file extensions.

Types

type DOCXLoader

type DOCXLoader struct{}

func (*DOCXLoader) Load

func (l *DOCXLoader) Load(path string) (*RawDocument, error)

func (*DOCXLoader) Supports

func (l *DOCXLoader) Supports(ext string) bool

type DocumentLoader

type DocumentLoader interface {
	Load(path string) (*RawDocument, error)
	Supports(ext string) bool
}

DocumentLoader can load a file and return its text.

type MarkdownLoader

type MarkdownLoader struct{}

func (*MarkdownLoader) Load

func (l *MarkdownLoader) Load(path string) (*RawDocument, error)

func (*MarkdownLoader) Supports

func (l *MarkdownLoader) Supports(ext string) bool

type PDFLoader

type PDFLoader struct{}

func (*PDFLoader) Load

func (l *PDFLoader) Load(path string) (*RawDocument, error)

func (*PDFLoader) Supports

func (l *PDFLoader) Supports(ext string) bool

type RawDocument

type RawDocument struct {
	Path    string
	Title   string
	DocType string
	Content string // full extracted text
}

RawDocument is the output of loading a file.

func Load

func Load(path string) (*RawDocument, error)

Load dispatches to the correct loader by file extension. Returns ErrBinaryFile (non-fatal) if the file looks like a binary.

type TXTLoader

type TXTLoader struct{}

func (*TXTLoader) Load

func (l *TXTLoader) Load(path string) (*RawDocument, error)

func (*TXTLoader) Supports

func (l *TXTLoader) Supports(ext string) bool

type WebLoader

type WebLoader struct {
	// contains filtered or unexported fields
}

WebLoader fetches a single URL and extracts its text content.

func NewWebLoader

func NewWebLoader() *WebLoader

func (*WebLoader) LoadURL

func (l *WebLoader) LoadURL(rawURL string) (*RawDocument, error)

LoadURL fetches a URL and returns a RawDocument.

func (*WebLoader) Supports

func (l *WebLoader) Supports(ext string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL