structurizer

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(text string, mime string) (*core.StructuredDocument, error)

New 根据文本内容和 MIME 类型创建结构化文档

func Open

func Open(file string) (*core.StructuredDocument, error)

Open 根据文件路径打开文件并结构化

Types

type Block

type Block struct {
	Text       string
	Lines      []string
	LineCount  int
	Type       string  // heading, paragraph, list, code_block, quote, table, definition_list
	Level      int     // 仅对 heading 有效
	Confidence float64 // 分类置信度 (0.0 - 1.0)
	StartLine  int     // 起始行号
	EndLine    int     // 结束行号

	// 列表特定属性
	IsOrdered bool     // 是否有序列表
	ListItems []string // 列表项

	// 表格特定属性
	HasTable  bool
	TableRows [][]string

	// 任务列表
	IsTaskList bool
	TaskItems  []TaskItem
}

Block 表示文本块的分类结果(带置信度)

type ClassificationConfig

type ClassificationConfig struct {
	// 标题识别
	HeadingMinLength  int     // 标题最小长度
	HeadingMaxLength  int     // 标题最大长度
	HeadingConfidence float64 // 标题分类置信度阈值

	// 代码块识别
	CodeIndentThreshold float64 // 缩进特征阈值(有缩进行的比例)
	CodeCharThreshold   float64 // 代码字符特征阈值
	CodeMinLines        int     // 代码块最小行数

	// 列表识别
	ListMarkerPatterns []string // 列表标记模式

	// 引用识别
	QuoteMarker string // 引用标记
}

ClassificationConfig 分类规则配置

func DefaultConfig

func DefaultConfig() *ClassificationConfig

DefaultConfig 返回默认配置

type CodeStructurizer

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

func NewCodeStructurizer

func NewCodeStructurizer() *CodeStructurizer

func (*CodeStructurizer) Parse

type ConfigStructurizer

type ConfigStructurizer struct {
	// MaxDepth 最大嵌套深度限制,防止循环引用导致栈溢出
	MaxDepth int
	// ExtractTitleFields 用于提取标题的字段名列表(优先级从高到低)
	ExtractTitleFields []string
}

ConfigStructurizer 配置文件结构化分析器 支持 JSON、YAML、TOML 等配置文件格式的结构化解析

func NewConfigStructurizer

func NewConfigStructurizer() *ConfigStructurizer

NewConfigStructurizer 创建默认配置的结构化分析器

func (*ConfigStructurizer) Parse

Parse 实现 Structurizer 接口

type MarkdownStructurizer

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

func NewMarkdownStructurizer

func NewMarkdownStructurizer() *MarkdownStructurizer

func (*MarkdownStructurizer) Close

func (ms *MarkdownStructurizer) Close()

func (*MarkdownStructurizer) Parse

type PlainTextStructurizer

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

PlainTextStructurizer 纯文本结构化分析器 使用启发式规则将纯文本分割为标题、段落、列表、代码块等结构

func NewPlainTextStructurizer

func NewPlainTextStructurizer() *PlainTextStructurizer

NewPlainTextStructurizer 创建带默认配置的纯文本结构化分析器

func NewPlainTextStructurizerWithConfig

func NewPlainTextStructurizerWithConfig(config *ClassificationConfig) *PlainTextStructurizer

NewPlainTextStructurizerWithConfig 创建带自定义配置的纯文本结构化分析器

func (*PlainTextStructurizer) Parse

Parse 实现 Structurizer 接口

type Structurizer

type Structurizer interface {
	Parse(raw core.Document) (*core.StructuredDocument, error)
}

Structurizer 接口,定义结构化分析器的通用行为

type TaskItem

type TaskItem struct {
	Text    string
	Checked bool
}

TaskItem 任务列表项

type WebStructurizer

type WebStructurizer struct {
	// SkipTags 跳过处理的标签列表(如 script、style 等)
	SkipTags map[string]bool
	// InlineTags 内联标签列表(不作为独立节点)
	InlineTags map[string]bool
	// ExtractAttributes 需要提取的属性列表
	ExtractAttributes []string
}

WebStructurizer HTML/XML 结构化分析器 支持解析 HTML 和 XML 文档,提取文档结构树

func NewWebStructurizer

func NewWebStructurizer() *WebStructurizer

NewWebStructurizer 创建默认配置的 Web 结构化分析器

func (*WebStructurizer) Parse

Parse 实现 Structurizer 接口

Jump to

Keyboard shortcuts

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