Documentation
¶
Index ¶
- Constants
- func PreviewText(text string, limit int) string
- func WriteJSONResult(path string, v interface{}) error
- func WriteText(path, content string) error
- type BaseResult
- type Client
- func (c *Client) RecognizeDetailed(path string, mode Mode, opts ...Option) (BaseResult, interface{}, error)
- func (c *Client) RecognizeDirectory(root string, mode Mode, opts ...Option) ([]FileResult, error)
- func (c *Client) RecognizeFiles(paths []string, mode Mode, opts ...Option) []FileResult
- func (c *Client) RecognizeHTML(path string, opts ...Option) (HTMLResult, error)
- func (c *Client) RecognizeStamp(path string, opts ...Option) (StampResult, error)
- func (c *Client) RecognizeTable(path string, opts ...Option) (TableResult, error)
- func (c *Client) RecognizeText(path string, opts ...Option) (TextResult, error)
- func (c *Client) RecognizeTextPages(path string, opts ...Option) (PageTextResult, error)
- type ClientOption
- type Coordinate
- type Dependencies
- type DiffResultSummary
- type DiffSummary
- type FileResult
- type HTMLResult
- type Meta
- type Mode
- type OCRPayload
- type OperationKind
- type Option
- type PageText
- type PageTextResult
- type Request
- type RequestOptions
- type Response
- type Service
- type StampDetail
- type StampPage
- type StampPageResult
- type StampPayload
- type StampResponse
- type StampResult
- type TablePage
- type TablePageResult
- type TablePayload
- type TableResponse
- type TableResult
- type TextBox
- type TextResult
Constants ¶
const ( OperationKindAny = model.OperationKindAny OperationKindOCR = model.OperationKindOCR OperationKindTable = model.OperationKindTable OperationKindStamp = model.OperationKindStamp )
Variables ¶
This section is empty.
Functions ¶
func WriteJSONResult ¶
WriteJSONResult 将结果以 JSON 形式写入文件。
Types ¶
type BaseResult ¶
type BaseResult struct {
Source string
Mode Mode
Meta Meta
Diff *DiffSummary
}
BaseResult 为快捷结果的通用部分。
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 封装 Service,提供按需的便捷接口。
func NewClientFromConfig ¶
func NewClientFromConfig(path string, opts ...ClientOption) (*Client, error)
NewClientFromConfig 从 YAML 配置构建 Client。
func NewClientFromService ¶
func NewClientFromService(svc *Service, opts ...ClientOption) *Client
NewClientFromService 从现有 Service 构建 Client。
func (*Client) RecognizeDetailed ¶
func (c *Client) RecognizeDetailed(path string, mode Mode, opts ...Option) (BaseResult, interface{}, error)
RecognizeDetailed 返回 BaseResult 和原始 Payload。
func (*Client) RecognizeDirectory ¶
RecognizeDirectory 会递归识别目录。
func (*Client) RecognizeFiles ¶
func (c *Client) RecognizeFiles(paths []string, mode Mode, opts ...Option) []FileResult
RecognizeFiles 批量处理文件。
func (*Client) RecognizeHTML ¶
func (c *Client) RecognizeHTML(path string, opts ...Option) (HTMLResult, error)
RecognizeHTML 返回整体 HTML 与按页 HTML。
func (*Client) RecognizeStamp ¶
func (c *Client) RecognizeStamp(path string, opts ...Option) (StampResult, error)
RecognizeStamp 返回印章识别结果。
func (*Client) RecognizeTable ¶
func (c *Client) RecognizeTable(path string, opts ...Option) (TableResult, error)
RecognizeTable 返回表格识别结果。
func (*Client) RecognizeText ¶
func (c *Client) RecognizeText(path string, opts ...Option) (TextResult, error)
RecognizeText 返回拼接文本。
func (*Client) RecognizeTextPages ¶
func (c *Client) RecognizeTextPages(path string, opts ...Option) (PageTextResult, error)
RecognizeTextPages 返回按页文本。
type ClientOption ¶
type ClientOption func(*Client)
ClientOption 配置 Client 的默认行为。
func WithDefaultContext ¶
func WithDefaultContext(ctx context.Context) ClientOption
WithDefaultContext 配置默认 Context。
func WithDefaultDiff ¶
func WithDefaultDiff(enabled bool, baseline string) ClientOption
WithDefaultDiff 配置默认 diff 行为。
func WithDefaultDiffPreview ¶
func WithDefaultDiffPreview(preview int) ClientOption
WithDefaultDiffPreview 配置默认 diff 预览数量。
func WithDefaultMaxPages ¶
func WithDefaultMaxPages(maxPages int) ClientOption
WithDefaultMaxPages sets a default per-request page cap for PDF inputs.
func WithDefaultNeedCharacter ¶
func WithDefaultNeedCharacter(on bool) ClientOption
WithDefaultNeedCharacter 设置默认 NeedCharacter。
type Coordinate ¶
type Coordinate = model.Coordinate
type Dependencies ¶
type Dependencies struct {
ProviderFactories map[string]provider.Factory
SplitterFactories map[string]splitter.Factory
CacheBuilder cache.Builder
ProcessorFactories processor.Registry
ProviderConfigValidators map[string]provider.ConfigValidator
}
Dependencies groups optional factories used to build the Service instance.
type DiffResultSummary ¶
type DiffResultSummary = model.DiffResultSummary
type DiffSummary ¶
type DiffSummary = model.DiffSummary
type FileResult ¶
type FileResult struct {
BaseResult
Output interface{}
Err error
}
FileResult 用于批量场景。
type HTMLResult ¶
type HTMLResult struct {
BaseResult
HTML string
Pages []string
}
HTMLResult 返回整体 HTML 及按页 HTML。
type Mode ¶
type Mode = OperationKind
Mode 是快捷接口使用的识别类型。
const ( ModeOCR Mode = OperationKindOCR ModeTable Mode = OperationKindTable ModeStamp Mode = OperationKindStamp )
type OCRPayload ¶
type OCRPayload = model.OCRPayload
type OperationKind ¶
type OperationKind = model.OperationKind
type Option ¶
type Option func(*RequestOptions)
Option 覆盖单次请求的设置。
func WithContext ¶
func WithDiffEnabled ¶
func WithMaxPages ¶
WithMaxPages limits how many pages a recognition request may process. Values <= 0 leave the service/pipeline default unchanged.
type PageTextResult ¶
type PageTextResult struct {
BaseResult
Pages []PageText
}
PageTextResult 返回按页文本。
type RequestOptions ¶
type RequestOptions struct {
NeedCharacter *bool
DiffEnabled *bool
DiffBaseline *string
DiffPreview *int
MaxPages *int
Context context.Context
}
RequestOptions 控制单次请求。
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service exposes the main OCR, table, and stamp recognition entry points. It acts as a façade coordinating the lower-level pipelines.
func NewService ¶
func NewService(cfg config.ServiceConfig, deps Dependencies) (*Service, error)
NewService constructs a Service from the provided configuration bundle.
func (*Service) RecognizeOCR ¶
RecognizeOCR runs the standard OCR pipeline.
func (*Service) RecognizeStamp ¶
func (s *Service) RecognizeStamp(ctx context.Context, req model.Request) (model.StampResponse, error)
RecognizeStamp runs the stamp detection pipeline.
func (*Service) RecognizeTable ¶
func (s *Service) RecognizeTable(ctx context.Context, req model.Request) (model.TableResponse, error)
RecognizeTable runs the table OCR pipeline.
type StampDetail ¶
type StampDetail = model.StampDetail
type StampPageResult ¶
type StampPageResult struct {
Index int
Stamps []StampDetail
}
type StampPayload ¶
type StampPayload = model.StampPayload
type StampResponse ¶
type StampResponse = model.StampResponse
type StampResult ¶
type StampResult struct {
BaseResult
Pages []StampPageResult
}
StampResult 返回印章识别结果。
type TablePageResult ¶
type TablePageResult struct {
Index int
Text string
NormalizedText string
HTML string
Coordinates []Coordinate
}
type TablePayload ¶
type TablePayload = model.TablePayload
type TableResponse ¶
type TableResponse = model.TableResponse
type TableResult ¶
type TableResult struct {
BaseResult
Pages []TablePageResult
CombinedText string
NormalizedCombinedText string
}
TableResult 返回表格识别结果。
type TextResult ¶
type TextResult struct {
BaseResult
Text string
NormalizedText string
}
TextResult 返回拼接后的纯文本。