Documentation
¶
Overview ¶
Package bench scores a converter's Markdown against a gold Markdown file, so a change to extraction, layout, or the sink can be judged by a number instead of a diff.
Both files are parsed with goldmark into the same shape: headings, paragraphs, list items, tables, and code blocks, plus the inline spans — bold, italic, code, strike — that live inside them. Scoring then matches the reference's blocks to whichever output blocks resemble them most, in reference order, and reports on that matching: how many characters survived once the blocks are back in order, how many of the reference's words came through anywhere, whether blocks landed in the right order, how many blocks came through intact, and how well headings, tables, and inline style reproduced.
Matching by content rather than by position is what lets this package score a reordered or merged document instead of just a line-for-line diff: a converter that emits the same two paragraphs in the wrong order should lose on Order and nothing else, and one that fuses four paragraphs into one should lose on Blocks because three of the four reference paragraphs no longer have an output block to themselves.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Scores ¶
type Scores struct {
// CER is the character error rate: edits per reference character, once the output's
// blocks are back in the reference's order.
CER float64
// Recall and Precision are word-bag overlap: how much of the reference's
// vocabulary came through anywhere in the output, and how much of the output's
// vocabulary was actually in the reference.
Recall, Precision float64
// Order is the fraction of consecutive matched reference blocks that also come out
// in increasing order in the output. A converter that only reorders blocks loses
// here and nowhere else.
Order float64
// Blocks is the F1 of blocks that matched the reference closely enough to call
// intact, over the reference and output block counts.
Blocks float64
Headings, Tables, Style float64
// RefHeadings, RefCells, and RefSpans are the reference counts behind Headings,
// Tables, and Style, so a caller can tell a vacuous 1.0 — neither side had any —
// from one actually measured against content.
RefHeadings, RefCells, RefSpans int
// Errs and Images count the literal "[err]" and "[image]" markers in got: the text
// and the pictures the converter marked rather than read.
Errs, Images int
}
Scores is what Score reports. Every field is a fraction except the two counters at the end; 1 is perfect for all of the fractions except CER, where 0 is perfect.