extract

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package extract turns supported raw content into plain text for chunking. It handles text/plain, text/markdown, and text/csv; markdown is currently embedded as-is (heading-aware handling is a later refinement), and csv is passed through verbatim so the sheet chunker can treat its first line as a header row. Newlines are normalized to "\n" so a file's content hash is stable across platforms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Extractor

type Extractor struct{}

Extractor extracts text from supported content types. Its zero value is ready.

func New

func New() Extractor

New returns a text Extractor.

func (Extractor) Extract

func (Extractor) Extract(contentType string, raw []byte) (string, error)

Extract returns the UTF-8 text of raw, with newlines normalized to "\n".

func (Extractor) Supports

func (Extractor) Supports(contentType string) bool

Supports reports whether the content type can be extracted.

type Router

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

Router dispatches extraction to the first of its Extractors that supports a content type, presenting many format adapters as the single Extractor port the use cases consume. The composition root builds it from the concrete adapters (text, docx, pdf, ...).

func NewRouter

func NewRouter(extractors ...app.Extractor) *Router

NewRouter returns a Router over the given Extractors, tried in order.

func (*Router) Extract

func (r *Router) Extract(contentType string, raw []byte) (string, error)

Extract dispatches to the first Extractor that supports the content type, or fails if none does.

func (*Router) Supports

func (r *Router) Supports(contentType string) bool

Supports reports whether any underlying Extractor supports the content type.

Jump to

Keyboard shortcuts

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