ocr

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package ocr provides the PaddleOCR API client.

Index

Constants

View Source
const (
	LayoutParsingEndpoint = "/layout-parsing"
	HealthEndpoint        = "/health"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the PaddleOCR API client.

func NewClient

func NewClient(cfg *config.Config) *Client

NewClient creates a new OCR client.

func (*Client) IsConfigured

func (c *Client) IsConfigured() bool

IsConfigured checks if the client is properly configured.

func (*Client) OCRFile

func (c *Client) OCRFile(filePath string, opts OCROptions) *DocumentOCRResult

OCRFile performs OCR on a file.

func (*Client) ServerURL

func (c *Client) ServerURL() string

ServerURL returns the configured server URL.

func (*Client) TestConnection

func (c *Client) TestConnection() (bool, string)

TestConnection tests the connection to the OCR server.

type DocumentOCRResult

type DocumentOCRResult struct {
	Success      bool        `json:"success"`
	Pages        []OCRResult `json:"pages"`
	ErrorMessage string      `json:"error_message,omitempty"`
	LogID        string      `json:"log_id,omitempty"`
}

DocumentOCRResult represents the OCR result for an entire document.

func (*DocumentOCRResult) FullMarkdown

func (r *DocumentOCRResult) FullMarkdown() string

FullMarkdown returns combined markdown from all pages.

type FileType

type FileType int

FileType represents the type of file being processed.

const (
	FileTypePDF   FileType = 0
	FileTypeImage FileType = 1
)

type OCROptions

type OCROptions struct {
	UseDocOrientationClassify bool
	UseDocUnwarping           bool
	UseChartRecognition       bool
	Timeout                   time.Duration
}

OCROptions holds options for OCR processing.

func DefaultOCROptions

func DefaultOCROptions() OCROptions

DefaultOCROptions returns default OCR options.

type OCRResult

type OCRResult struct {
	PageIndex int               `json:"page_index"`
	Markdown  string            `json:"markdown"`
	Images    map[string]string `json:"images"`
}

OCRResult represents the OCR result for a single page.

Jump to

Keyboard shortcuts

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