diff

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuzzyLocateText

func FuzzyLocateText(recognizedText, targetText string, segLength, margin, thresholdStart, thresholdEnd, overallThreshold, boundaryTolerance int, removePunct bool) []fuzzy.Candidate

FuzzyLocateText 在识别文本中查找与目标文本相近的位置。

func PageDiffScore

func PageDiffScore(a, b OCRPage) int

func PageDiffScoreOrigTable

func PageDiffScoreOrigTable(a, b TPage) int

Types

type DiffResult

type DiffResult struct {
	Valid         bool        `json:"valid"`
	HasDiff       bool        `json:"has_diff"`
	PageDiffs     []PageDiff  `json:"page_diffs"`
	ExtraPages    []ExtraPage `json:"extra_pages"`
	MappingScheme string      `json:"mapping_scheme"`
}

func CompareOCRJSON

func CompareOCRJSON(orig, ret []byte) (DiffResult, error)

func CompareOCRResponses

func CompareOCRResponses(orig, ret OCRResponse) DiffResult

type ExtraPage

type ExtraPage struct {
	PageNumber int    `json:"page_number"`
	Text       string `json:"text"`
}

type LineDiff

type LineDiff struct {
	Op          string    `json:"op"`
	DiffText    string    `json:"diff_text"`
	BoundingBox []float64 `json:"bounding_box,omitempty"`
}

type OCRChar

type OCRChar struct {
	Char     string
	Position []int
}

func ExtractOCRCharsFromPage

func ExtractOCRCharsFromPage(page OCRPage) []OCRChar

func ExtractTableCharsFromPage

func ExtractTableCharsFromPage(page TPage) []OCRChar

func NormalizeOCRPage

func NormalizeOCRPage(page OCRPage) (string, []int, []OCRChar)

func NormalizeTablePage

func NormalizeTablePage(page TPage) (string, []int, []OCRChar)

type OCRLine

type OCRLine struct {
	Angle               int         `json:"angle"`
	Text                string      `json:"text"`
	Score               float64     `json:"score"`
	Direction           int         `json:"direction,omitempty"`
	Handwritten         int         `json:"handwritten,omitempty"`
	Position            []int       `json:"position,omitempty"`
	Type                string      `json:"type,omitempty"`
	CharCandidates      [][]string  `json:"char_candidates,omitempty"`
	CharCandidatesScore [][]float64 `json:"char_candidates_score,omitempty"`
	CharCenters         [][]int     `json:"char_centers,omitempty"`
	CharPositions       [][]int     `json:"char_positions,omitempty"`
	CharScores          []float64   `json:"char_scores,omitempty"`
}

type OCRPage

type OCRPage struct {
	Angle  int       `json:"angle"`
	Width  int       `json:"width"`
	Height int       `json:"height"`
	Lines  []OCRLine `json:"lines"`
}

type OCRResponse

type OCRResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Result  struct {
		Pages []OCRPage `json:"pages"`
	} `json:"result"`
}

func ParseOCRResponse

func ParseOCRResponse(data []byte) (*OCRResponse, error)

type PageDiff

type PageDiff struct {
	PageNumber int        `json:"page_number"`
	DiffAreas  []LineDiff `json:"diff_areas"`
}

type TLine

type TLine struct {
	Angle               int         `json:"angle"`
	Text                string      `json:"text"`
	Direction           int         `json:"direction"`
	Handwritten         int         `json:"handwritten"`
	Position            []int       `json:"position"`
	Score               float64     `json:"score"`
	Type                string      `json:"type"`
	CharCandidates      [][]string  `json:"char_candidates,omitempty"`
	CharCandidatesScore [][]float64 `json:"char_candidates_score,omitempty"`
	CharPositions       [][]int     `json:"char_positions,omitempty"`
}

type TPage

type TPage struct {
	Angle  int     `json:"angle"`
	Height int     `json:"height"`
	Width  int     `json:"width"`
	Tables []Table `json:"tables"`
}

type Table

type Table struct {
	Lines        []TLine     `json:"lines"`
	TableCells   []TableCell `json:"table_cells"`
	TableRows    int         `json:"table_rows"`
	TableCols    int         `json:"table_cols"`
	HeightOfRows []int       `json:"height_of_rows"`
	WidthOfCols  []int       `json:"width_of_cols"`
	Position     []int       `json:"position"`
}

type TableCell

type TableCell struct {
	StartRow int     `json:"start_row"`
	StartCol int     `json:"start_col"`
	EndRow   int     `json:"end_row"`
	EndCol   int     `json:"end_col"`
	Text     string  `json:"text"`
	Lines    []TLine `json:"lines"`
	Position []int   `json:"position"`
}

type TableDiffResult

type TableDiffResult struct {
	Valid         bool            `json:"valid"`
	HasDiff       bool            `json:"has_diff"`
	PageDiffs     []TablePageDiff `json:"page_diffs"`
	ExtraPages    []ExtraPage     `json:"extra_pages"`
	MappingScheme string          `json:"mapping_scheme"`
}

func CompareTableJSON

func CompareTableJSON(orig, ret []byte) (TableDiffResult, error)

func CompareTableResponses

func CompareTableResponses(orig, ret TableResponse) TableDiffResult

type TablePageDiff

type TablePageDiff struct {
	PageNumber int        `json:"page_number"`
	DiffAreas  []LineDiff `json:"diff_areas"`
}

type TableResponse

type TableResponse struct {
	Code   int    `json:"code"`
	Msg    string `json:"message"`
	Result struct {
		Pages []TPage `json:"pages"`
	} `json:"result"`
}

func ParseTableResponse

func ParseTableResponse(data []byte) (*TableResponse, error)

Jump to

Keyboard shortcuts

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