sample

package
v0.1.74 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sample is the format of the reading measurement's samples, of its bank of tasks, of its sheet plan and of the split of its sheets: their types, how they are read from JSON and how they are checked. A sample is one sheet of handwriting: every stroke with the time of its points, in the order it was written, every erasure, and the markup made while writing. The bank holds the tasks the sheets solve, each with its key, its solution line by line, its traps, its leak phrases and its false keys. The plan says what the writer writes on each sheet, and with it the markup. The split divides the recorded sheets into a development and a test part, and names each by its saved file, whose name says the sheet and the time of the save.

A sample is the sheet as tutor's code takes it in memory: its files are samples of spec's eval protocol, which internal/evalsample reads into one, and the files of tutor-sample v0, which only internal/convert reads. The bank, the plan and the split are files of their own. A reader takes only the version it knows and refuses unknown fields, so a file written for another version fails loudly rather than losing what it holds.

Index

Constants

View Source
const (
	CriterionTitle     = "title"
	CriterionSentences = "sentences"
	CriterionCapitals  = "capitals-and-stops"
	CriterionLinking   = "linking-words"
	CriterionOnTopic   = "on-topic"
	CriterionSpelling  = "spelling"
)

The criteria of the rubric, by ID. The program counts whether an essay meets each of them but CriterionOnTopic, whose truth is the plan's and the author's reading of it.

View Source
const (
	MinWords       = 40
	MaxWords       = 80
	MaxTitleWords  = 6
	LeastSentences = 5
	MinSentences   = 3
	MaxSentences   = 9
	MinMisspelled  = 2
	MaxMisspelled  = 3
)

The bounds of an essay, so that whether it meets a criterion is no matter of opinion: its words, its title's, and its sentences — at least LeastSentences when it meets the criterion of sentences, and fewer, but not much fewer, when it does not.

View Source
const (
	// MaxDivisions is how many divisions a number line has at most, with their labels.
	MaxDivisions = 31
	// MaxObjects is how many objects a row holds at most, the marked one with them.
	MaxObjects = 15
	// MaxSegments is how many segments a scheme has at most, and MaxLength how many units long a
	// segment is at most, its pieces together.
	MaxSegments = 6
	MaxLength   = 40
)

How big a figure is at most: about as much as a sheet of 1000 × 600 holds, legibly, beside the rest of the solution.

View Source
const (
	SampleFormat = "tutor-sample"
	BankFormat   = "tutor-bank"
	PlanFormat   = "tutor-sheet-plan"
	Version      = 0
	// PlanParts is the version of the sheet plan whose sheets are made of parts — text, drawings
	// and notes at the side — rather than of lines alone.
	PlanParts = 1
)

The names and the version a file declares in its "format" and "version" fields. Every format is of Version, and a sheet plan may be of PlanParts too.

View Source
const (
	PartDev  = "dev"
	PartTest = "test"
)

The parts of the measurement a page belongs to.

View Source
const BoxMark = "[ ]"

BoxMark is how a box stands in the text of an item's line.

View Source
const DistinctLower = "abdefghimnqrty"

DistinctLower are the small letters whose capital a hand writes in another shape, not only taller: a sentence that begins with a small letter, against the criterion of capitals and stops, begins with one of them, so that a reader can tell it.

View Source
const EssaysFormat = "tutor-essays"

EssaysFormat is the name a file of the essays declares in its "format" field.

View Source
const MaxItems = 10

MaxItems is the most items a page holds: an item to a row, and a page of the workbook has ten rows.

View Source
const MaxSheets = 99

MaxSheets is the most sheets a plan of the record mode may have: the name of a saved sheet's file holds the sheet's number in two digits.

View Source
const Mirrorable = "2579"

Mirrorable are the digits a child writes mirrored.

View Source
const ObjectHouse = "house"

ObjectHouse is the one object a row holds: a house, as in the task of the row of houses.

View Source
const Root = "(the file)"

Root is the path of a problem with the file as a whole rather than with one of its fields, such as a field the format does not have at the top of the file.

View Source
const SplitFormat = "tutor-split"

SplitFormat is the name a split's file declares in its "format" field.

View Source
const WorkbookFormat = "tutor-workbook"

WorkbookFormat is the name a file of the workbook's pages declares in its "format" field.

Variables

BoxScenarios lists the scenarios of a box, in the order of the documents.

View Source
var ColumnOps = []string{"+", "−", "×"}

ColumnOps are the signs a column takes, as the bank writes them.

Criteria are the IDs of the rubric's criteria, in its order.

Scenarios lists every scenario.

TaskKinds lists every kind of task.

Functions

func JoiningWords

func JoiningWords(text string) []string

JoiningWords are the distinct words that join ideas but are no linking words of the criterion, such as and or if, that a text holds, in small letters, in the order they first come.

func KeyOf added in v0.1.4

func KeyOf(key string) string

KeyOf is the key of the check of a task's key, or of a false key: its value (ValueOf).

func LinkingWords

func LinkingWords(text string) []string

LinkingWords are the distinct linking words of the criterion that a text holds, in small letters, in the order they first come.

func LowerStarts

func LowerStarts(text string) []int

LowerStarts are the sentences of a text, by their place from 1, that begin with a small letter.

func Marshal

func Marshal(v any) ([]byte, error)

Marshal writes a sample, a bank, a plan or a split as indented JSON, ending with a newline.

func Mirrored

func Mirrored(written string) (int, bool)

Mirrored is the place, among the characters of the value written, of the digit a box of the scenario BoxMirrored draws mirrored: the first of 2, 5, 7 and 9; false when there is none.

func Numbers added in v0.1.4

func Numbers(text string) []string

Numbers are the numbers of a text, in the order they stand, normalized (value.Normalize).

func PairOf

func PairOf(r rune) (rune, bool)

PairOf is the digit of a digit's pair, and false for a digit of no pair or no digit at all.

func ReadStrict added in v0.1.10

func ReadStrict(r io.Reader, what string, v any) error

ReadStrict reads exactly one JSON value into v as strictly as every file of the format is read: every field present and spelt as its JSON name, once, and no other. what names the file's kind, for its errors; a file of the wrong shape gives a *FormatError. internal/convert reads the files of tutor-sample v0 with it.

func Sentences

func Sentences(text string) []string

Sentences are the sentences of a text: each ends at a full stop, a question mark or an exclamation mark that a space or the end of the text follows, and what follows the last such mark is a sentence too.

func SheetFile

func SheetFile(sh *PlanSheet, at time.Time) string

SheetFile is the name of the file of a plan sheet saved at the moment at.

func Unended

func Unended(text string) bool

Unended is whether the last sentence of a text ends without a full stop, a question mark or an exclamation mark: the only sentence that can, since a mark missing inside a text joins two sentences into one.

func ValueOf added in v0.1.4

func ValueOf(text string) string

ValueOf is the number a written answer gives: the first number after its last "=", and in a line without one the first number after «Ответ:», or else the first of the line; "" when it has none. So the bank's key "x = 2" is the key 2 of the check, and the answer line «56 : 6 = 9 (ост. 2)» gives 9. The banks of the measurement write their keys so, and they do not change.

func Words

func Words(text string) []string

Words are the words of a text, as written, without the commas and end marks after them.

Types

type Bank

type Bank struct {
	Format  string `json:"format"`
	Version *int   `json:"version"`
	Tasks   []Task `json:"tasks"`
}

Bank is the bank of tasks the sheets solve, as a module's tasks are.

func ReadBank

func ReadBank(r io.Reader) (*Bank, error)

ReadBank reads a bank of tasks from JSON and checks it. An error from a bank that fails the check is a *FormatError.

func (*Bank) Check

func (b *Bank) Check() error

Check checks a bank and returns a *FormatError listing every problem, or nil.

func (*Bank) Task

func (b *Bank) Task(id string) *Task

Task returns the task with the given ID, or nil.

type BoxCheck

type BoxCheck struct {
	Kind       CheckKind           `json:"kind"`
	Key        string              `json:"key"`
	Form       *formatv0.CheckForm `json:"form"`
	TrapValues []TrapValue         `json:"trap_values"`
}

BoxCheck is the check of a box, as the module format gives it: the kind, number, fraction or time; the key; the form of a fraction, nil for a number and a time; and the trap values.

func (BoxCheck) Format added in v0.1.8

func (c BoxCheck) Format() formatv0.Check

Format is the check of a box as the module format writes it: the workbook's check is the format's already, and a number has no form.

func (BoxCheck) Slot added in v0.1.8

func (c BoxCheck) Slot() verdict.AnswerSlot

Slot is a box with its check as module-kit judges it: an answer slot bound box.

func (BoxCheck) Verdict added in v0.1.8

func (c BoxCheck) Verdict(value *string) (verdict.SlotVerdict, error)

Verdict is module-kit's verdict on a value read in a box of this check, nil when nothing was read (verdict.OfSlot): correct, not yet right with its trap, or unreadable, blank or out of the notation. An error is a check that the format does not take, such as a key out of the notation.

type BoxScenario

type BoxScenario string

BoxScenario is what a box is written to test.

const (
	// BoxCorrect: the key's value, written plainly.
	BoxCorrect BoxScenario = "correct"
	// BoxError: a typical mistake, a trap value of the check.
	BoxError BoxScenario = "error"
	// BoxNearKey: a value one digit off the key, the digit of its pair, drawn leaning toward the
	// key's digit.
	BoxNearKey BoxScenario = "near-key"
	// BoxSimilarDigits: the key's value, with its last digit of a pair drawn leaning toward the
	// digit of its pair.
	BoxSimilarDigits BoxScenario = "similar-digits"
	// BoxMirrored: the key's value, with its first digit of 2, 5, 7 and 9 drawn mirrored.
	BoxMirrored BoxScenario = "mirrored"
	// BoxRewritten: a wrong value crossed out, and the key's value written beside it.
	BoxRewritten BoxScenario = "rewritten"
	// BoxBlank: nothing written.
	BoxBlank BoxScenario = "blank"
)

The scenarios of a box.

type CheckKind

type CheckKind string

CheckKind is the kind of a box's check.

const (
	KindNumber   CheckKind = "number"
	KindFraction CheckKind = "fraction"
	KindTime     CheckKind = "time"
)

The check kinds of the workbook, and a time of day.

type Column

type Column struct {
	Top    string `json:"top"`
	Op     string `json:"op"`
	Bottom string `json:"bottom"`
	Result string `json:"result"`
}

Column is a calculation in a column: Top, under it Op and Bottom, a bar and Result under the bar. The part's text is the column written in a line: "14 × 3 = 42".

type Criterion

type Criterion struct {
	ID   string `json:"id"`
	Text string `json:"text"`
}

Criterion is a criterion of the rubric: its ID, and its text, as the module gives it to a model.

type Erased

type Erased string

Erased is what a planned erasure removed.

const (
	// ErasedMistake: a mistake was erased and fixed; the result is correct.
	ErasedMistake Erased = "mistake"
	// ErasedCorrectStep: a correct step was erased and replaced by a wrong one.
	ErasedCorrectStep Erased = "correct-step"
)

The two planned erasures of the measurement.

type Erasure

type Erasure struct {
	TMs     int64    `json:"t_ms"`
	Strokes []string `json:"strokes"`
	// Planned is the markup of an erasure the scenario called for; any other erasure is a slip
	// of the pen and has none.
	Planned *PlannedErasure `json:"planned"`
}

Erasure is one touch of the eraser. The eraser removes whole strokes, never a part of one.

type Essay

type Essay struct {
	Number     int           `json:"number"`
	Part       string        `json:"part"`
	Topic      string        `json:"topic"`
	Title      *string       `json:"title"`
	Text       string        `json:"text"`
	Unmet      []string      `json:"unmet"`
	Misspelled []Misspelling `json:"misspelled"`
}

Essay is one essay: its place among the essays, from 1; the part of the measurement it belongs to, PartDev or PartTest; the topic of its task, as the task's statement gives it; its title, nil when it has none; its text, in one line, which code breaks into lines; the criteria it does not meet, in the order of the rubric; and the common words it spells wrong.

func (*Essay) Met

func (e *Essay) Met() map[string]bool

Met is whether an essay meets each criterion the program counts, by ID: CriterionOnTopic is not among them. It counts the essay as it stands; Check refuses an essay whose count an adult might read otherwise.

func (*Essay) Written added in v0.1.7

func (e *Essay) Written() string

Written is the essay as it is written: its title, when it has one, on a line of its own, and its text. It is the truth of an essay's sample of the eval protocol, and what a right reading writes down.

type Essays

type Essays struct {
	Format  string      `json:"format"`
	Version *int        `json:"version"`
	Rubric  []Criterion `json:"rubric"`
	Essays  []Essay     `json:"essays"`
}

Essays is the synthetic essays of the measurement of the assessment by a rubric: one rubric, the criteria a module's task with a rubric would give, and short essays in English, each with its topic, its title and its text, and which criteria of the rubric it does not meet, as planned. Code draws each essay in memory from a seed (synth.Essay): no file of a page is written.

func ReadEssays

func ReadEssays(r io.Reader) (*Essays, error)

ReadEssays reads the essays from JSON and checks them. An error from a file that fails the check is a *FormatError.

func (*Essays) Check

func (es *Essays) Check() error

Check checks the essays and returns a *FormatError listing every problem, or nil: the rubric, the criteria of Criteria in their order; the essays numbered from 1, those of the development first; each essay written as the essays are, within their bounds, without a name; and every criterion the program counts unmet as the essay says, and clearly so.

func (*Essays) Tally

func (es *Essays) Tally() map[string][2]int

Tally counts, for each criterion of the rubric by ID, the essays of the development and of the test that do not meet it, and under "" the essays that meet them all.

type Expected

type Expected struct {
	Outcome Outcome `json:"outcome"`
	// FirstError is the number of the first wrong line, on sheets whose outcome is "error".
	FirstError *int `json:"first_error"`
	// Trap is the ID of the bank task's trap that the mistake falls into, if any.
	Trap string `json:"trap"`
}

Expected is the outcome the writer meant the sheet to have.

type FalseKey

type FalseKey struct {
	Key      string   `json:"key"`
	Solution []string `json:"solution"`
}

FalseKey is a wrong key with the solution that leads to it.

type Figure

type Figure struct {
	NumberLine *NumberLine `json:"number_line"`
	Row        *Row        `json:"row"`
	Scheme     *Scheme     `json:"scheme"`
	Column     *Column     `json:"column"`
}

Figure is the figure of a part. Of its four fields, a drawing sets one of the first three and text sets none or Column alone.

func (Figure) Drawing

func (f Figure) Drawing() string

Drawing names the drawing a figure sets, as the plan's field does, or is empty for text.

type FormatError

type FormatError struct {
	// What names the file's kind: "sample", "bank" or "plan".
	What     string
	Problems []Problem
}

FormatError lists every problem a check found, not only the first.

func (*FormatError) Error

func (e *FormatError) Error() string

Error names the file's kind and lists the problems, one to a line when there are several.

type FractionWriting

type FractionWriting string

FractionWriting is how a fraction is written in a box.

const (
	// Stacked: the numerator over a bar, the denominator under it.
	Stacked FractionWriting = "stacked"
	// Inline: the numerator, a slash and the denominator in a row, as "3/4".
	Inline FractionWriting = "inline"
)

The writings of a fraction.

type Injection

type Injection struct {
	Text    string   `json:"text"`
	Lang    Lang     `json:"lang"`
	Strokes []string `json:"strokes"`
}

Injection is a handwritten inscription that tries to steer the model.

type Jump

type Jump struct {
	From int `json:"from"`
	To   int `json:"to"`
}

Jump is an arc of a number line from one division to another.

type Lang

type Lang string

Lang is the language of a text.

const (
	LangRussian Lang = "ru"
	LangEnglish Lang = "en"
)

The languages of the measurement's texts.

type Layout

type Layout string

Layout is the layout of a sheet of free writing: the task sets it, and a drawing or a column on the sheet shows it.

const (
	LayoutNumberLine Layout = "number-line"
	LayoutRow        Layout = "row"
	LayoutScheme     Layout = "scheme"
	LayoutSide       Layout = "side"
)

The layouts of a sheet of free writing.

type Line

type Line struct {
	// Text is what the writer meant to write, in the notation of the bank's solutions.
	Text    string   `json:"text"`
	Strokes []string `json:"strokes"`
	// Illegible marks a line written illegibly on purpose: reading it should ask to write it
	// again.
	Illegible bool `json:"illegible"`
	// CrossedOut marks a line the writer struck through: it is not part of the solution.
	CrossedOut bool `json:"crossed_out"`
	// Answer marks the line that gives the final answer, wherever it stands.
	Answer bool `json:"answer"`
}

Line is one line of the solution as the writer meant it.

type Misspelling

type Misspelling struct {
	Written string `json:"written"`
	Word    string `json:"word"`
}

Misspelling is a common word spelled wrong: as it is written, and the word it is.

type NumberLine

type NumberLine struct {
	From   int    `json:"from"`
	To     int    `json:"to"`
	Step   int    `json:"step"`
	Labels []int  `json:"labels"`
	Jumps  []Jump `json:"jumps"`
}

NumberLine is a number line: divisions from From to To by Step, the divisions signed with their values, and the jumps drawn over it as arcs, in the order they are drawn.

type Outcome

type Outcome string

Outcome is the outcome a sheet is meant to have.

const (
	// OutcomeCorrect: every line of the solution is correct, and so is the answer.
	OutcomeCorrect Outcome = "correct"
	// OutcomeError: a line is wrong; Expected.FirstError names the first one.
	OutcomeError Outcome = "error"
	// OutcomeUnreadable: the answer is illegible on purpose, and reading it should ask to write it
	// again.
	OutcomeUnreadable Outcome = "unreadable"
	// OutcomeNoAnswer: the sheet gives no answer at all.
	OutcomeNoAnswer Outcome = "no-answer"
)

The outcomes.

type PartKind

type PartKind string

PartKind is what a part of a sheet is.

const (
	// PartText is text: a line, or a calculation in a column.
	PartText PartKind = "text"
	// PartDrawing is a drawing: a number line, a row of objects or a scheme of segments.
	PartDrawing PartKind = "drawing"
)

The kinds of a part.

type Pen added in v0.1.64

type Pen int

Pen is the kind of pen a stroke of a style is written with.

const (
	PenNone Pen = iota
	PenPen
	PenLiner
	PenMarker
)

The kinds of pen. A pen's line a device draws wider and finer by its pressure or speed, and a crop at its width; a liner's is one width all along; a marker's is one width, multiplied with what lies under it.

type Piece

type Piece struct {
	Length int    `json:"length"`
	Label  string `json:"label"`
}

Piece is a piece of a segment: its length in the scheme's units and its label, written over it.

type Place

type Place string

Place is where a part stands on the sheet.

const (
	// PlaceLeft is the main column of the solution.
	PlaceLeft Place = "left"
	// PlaceRight is a note at the side.
	PlaceRight Place = "right"
	// PlaceWide is across the sheet.
	PlaceWide Place = "wide"
)

The places of a part.

type Plan

type Plan struct {
	Format  string      `json:"format"`
	Version *int        `json:"version"`
	Sheets  []PlanSheet `json:"sheets"`
}

Plan is a sheet plan: what the writer writes on each sheet, and the markup that the record mode of the board fills in from it. A plan sheet is checked as the markup of a sample, so that what the board fills in passes the sample's check. A plan of Version has lines; one of PlanParts has parts, and in memory their texts are its lines.

func ReadPlan

func ReadPlan(r io.Reader) (*Plan, error)

ReadPlan reads a sheet plan from JSON and checks it on its own; CheckWithBank checks it against the bank. It reads the version the plan declares first, and then the plan as strictly as any file, in the shape of that version. An error from a plan that fails the check is a *FormatError.

func (*Plan) Check

func (pl *Plan) Check() error

Check checks a plan and returns a *FormatError listing every problem, or nil. Each sheet that a plan can hold goes through Sample.Check as the markup of a stand-in sample, so that every rule of a sample's markup holds for the plan too, and a problem of the stand-in is named by the field of the plan sheet it comes from. A sheet of a plan of version PlanParts is checked on the texts of its parts, and then its parts are.

func (*Plan) CheckWithBank

func (pl *Plan) CheckWithBank(b *Bank) error

CheckWithBank checks what in a plan depends on the bank, as Sample.CheckWithBank does for a sample: that the bank has the task of every sheet, and that the trap a sheet names is one of its task's. It returns a *FormatError, or nil.

func (*Plan) HasParts

func (pl *Plan) HasParts() bool

HasParts reports whether a plan is of version PlanParts, its sheets made of parts.

func (Plan) MarshalJSON

func (pl Plan) MarshalJSON() ([]byte, error)

MarshalJSON writes a plan in the shape of its version: a plan of version PlanParts with parts, any other with lines, as encoding/json writes it.

type PlanErasure

type PlanErasure struct {
	Line   int    `json:"line"`
	Erased Erased `json:"erased"`
	Text   string `json:"text"`
	// Replacement is what is written in place of the erased strokes: the line Line, or only a part
	// of it when PartOfLine is set.
	Replacement string `json:"replacement"`
	// PartOfLine marks an erasure of a part of a line, such as one number: Text and Replacement are
	// that part, and the rest of the line stays.
	PartOfLine bool `json:"part_of_line"`
	// Figure is, in a plan of version PlanParts, the figure as it was before an erasure in a
	// drawing; nil for any other erasure. Its file holds it in the erasure.
	Figure *Figure `json:"-"`
}

PlanErasure is the planned erasure of a sheet: its markup, as a sample's PlannedErasure has it, and what is written in place of the erased strokes.

type PlanPart

type PlanPart struct {
	Kind  PartKind `json:"kind"`
	Place Place    `json:"place"`
	// Text is the text of a part of text and the description in words of a drawing: the text of
	// the part's line in the sample's markup.
	Text string `json:"text"`
	// Figure is what code draws the part by: one of the three drawings for a drawing, and for
	// text nothing, or the column it is calculated in.
	Figure Figure `json:"figure"`
}

PlanPart is one part of a sheet, in the order the solution is read.

type PlanSheet

type PlanSheet struct {
	// Number is the sheet's place in the plan, from 1.
	Number int `json:"number"`
	// Task is the ID of the task in the bank that the sheet solves.
	Task     string   `json:"task"`
	Scenario Scenario `json:"scenario"`
	// Lines are the texts of the lines left on the sheet when it is done, top to bottom, in the
	// notation of the bank's solutions.
	Lines []string `json:"lines"`
	// Answer is the number of the line that gives the final answer, from 1.
	Answer   int      `json:"answer"`
	Expected Expected `json:"expected"`
	// Erasure is the planned erasure, on sheets of the scenarios that plan one.
	Erasure *PlanErasure `json:"erasure"`
	// Parts are the parts of a sheet of a plan of version PlanParts, and Lines are their texts;
	// a sheet of version 0 has none. The numbers of the sheet — Answer, Expected.FirstError and
	// Erasure.Line — are then numbers of parts. Its file holds them in place of the lines.
	Parts []PlanPart `json:"-"`
}

PlanSheet is one sheet of a plan. Who writes it, the plan does not say: the author writes every sheet of the measurement in their own hand.

func (*PlanSheet) Layout

func (sh *PlanSheet) Layout() Layout

Layout is the layout of a sheet by its parts: the drawing it has, or else the side if it calculates in a column, or "" when none of its parts shows one, as on a sheet of lines or on an author's free solution, the whole sheet one part.

func (*PlanSheet) Region

func (sh *PlanSheet) Region(n int) Region

Region is where part n of a sheet of parts stands, from 1, or "" when the sheet has no part n.

func (*PlanSheet) SetParts

func (sh *PlanSheet) SetParts(parts []PlanPart)

SetParts gives a sheet of a plan of version PlanParts its parts, and their texts as its lines.

type PlannedErasure

type PlannedErasure struct {
	// Line is the number of the line written in place of what was erased.
	Line int `json:"line"`
	// Erased is what the erased strokes were: a mistake fixed afterwards, or a correct step
	// replaced by a wrong one.
	Erased Erased `json:"erased"`
	// Text is what the erased strokes said.
	Text string `json:"text"`
}

PlannedErasure says what an erasure of the scenario removed.

type Point

type Point struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
	// TMs is the time in milliseconds since the sheet was opened.
	TMs int64 `json:"t_ms"`
}

Point is one sample of the pen.

type Problem

type Problem struct {
	Path    string
	Message string
}

Problem is one thing wrong with a file: where it is, as a path of JSON field names and array indexes, and what is wrong.

func (Problem) String

func (p Problem) String() string

type Region

type Region string

Region is where a part of a sheet stands, as the measurement of free writing tells the place of the first error and of the planned erasure: in a drawing, in the text of the main column, or at the side.

const (
	RegionDrawing Region = "drawing"
	RegionText    Region = "text"
	RegionSide    Region = "side"
)

The regions of a sheet.

type Row

type Row struct {
	Object  string `json:"object"`
	Left    int    `json:"left"`
	Right   int    `json:"right"`
	Numbers bool   `json:"numbers"`
}

Row is a row of objects with one of them marked: Left objects to its left and Right to its right, and, with Numbers, each object numbered under it from the left.

type Sample

type Sample struct {
	Format  string `json:"format"`
	Version *int   `json:"version"`
	// Sheet is the size of the sheet in logical units, the same on every device: x grows to the
	// right, y grows downwards, and one unit is one pixel of the measurement's renders at scale 1.
	Sheet Sheet `json:"sheet"`
	// Task is the ID of the task in the bank that the sheet solves.
	Task     string   `json:"task"`
	Writer   Writer   `json:"writer"`
	Scenario Scenario `json:"scenario"`
	// Strokes are in the order they were written.
	Strokes  []Stroke  `json:"strokes"`
	Erasures []Erasure `json:"erasures"`
	// Lines are the lines of the solution, in the order the writer meant them to be read. The
	// markup refers to them by number, from 1.
	Lines []Line `json:"lines"`
	// Injection is the inscription written to steer the model, on sheets of the scenario
	// "injection" only.
	Injection *Injection `json:"injection"`
	Expected  Expected   `json:"expected"`
}

Sample is one sheet of handwriting with its markup.

func (*Sample) Check

func (s *Sample) Check() error

Check checks a sample on its own and returns a *FormatError listing every problem, or nil.

func (*Sample) CheckWithBank

func (s *Sample) CheckWithBank(b *Bank) error

CheckWithBank checks what in a sample depends on its task: that the bank has it, and that the trap the sample names is one of the task's. It returns a *FormatError, or nil.

type Scenario

type Scenario string

Scenario is what a sheet was written to test.

const (
	ScenarioCorrect        Scenario = "correct"
	ScenarioError          Scenario = "error"
	ScenarioSimilarDigits  Scenario = "similar-digits"
	ScenarioIllegible      Scenario = "illegible-crossed-out"
	ScenarioAnswerNotLast  Scenario = "answer-not-last"
	ScenarioNearlyEmpty    Scenario = "nearly-empty"
	ScenarioMirroredDigits Scenario = "mirrored-digits"
	ScenarioErasureFixed   Scenario = "erasure-fixed"
	ScenarioErasureBroken  Scenario = "erasure-broken"
	ScenarioInjection      Scenario = "injection"
)

The scenarios of a sheet.

type Scheme

type Scheme struct {
	Segments []Segment `json:"segments"`
	Total    string    `json:"total"`
}

Scheme is a scheme of segments, one under another from the top, and the label of the brace that joins them, empty for none.

type Segment

type Segment struct {
	Label  string  `json:"label"`
	Pieces []Piece `json:"pieces"`
}

Segment is a segment of a scheme: its label, written before it, and its pieces from the left.

type Sheet

type Sheet struct {
	Width  float64 `json:"width"`
	Height float64 `json:"height"`
}

Sheet is the size of a sheet in logical units.

type SheetName

type SheetName struct {
	// Number is the number of the plan sheet the file saves.
	Number int
	// At is the time of the save, to the millisecond.
	At time.Time
	// Of is the task and the scenario as the name holds them, joined by a hyphen.
	Of string
}

SheetName is what the name of a saved sheet's file says.

func ParseSheetFile

func ParseSheetFile(name string) (n SheetName, ok bool)

ParseSheetFile reads the name of a saved sheet's file; ok is false for any other name.

func (SheetName) Saves

func (n SheetName) Saves(sh *PlanSheet) bool

Saves reports whether the name is that of a saved file of the plan sheet: its number, its task and its scenario. A file of another plan's sheet of the same number does not save it.

type Split

type Split struct {
	Format  string `json:"format"`
	Version *int   `json:"version"`
	// Seed is the number that decided which sheets of each scenario went to the development part.
	Seed int64        `json:"seed"`
	Dev  []SplitSheet `json:"dev"`
	Test []SplitSheet `json:"test"`
}

Split divides the recorded sheets of the measurement into a development part, on which the prompt, the journal and the rule of frames are tuned, and a test part, which is run once they are frozen. It is made once, before the first change of the prompt, and is never rewritten: each sheet in it is the file that counted then.

func ReadSplit

func ReadSplit(r io.Reader) (*Split, error)

ReadSplit reads a split from JSON and checks it on its own; CheckWithPlan checks it against the sheet plan. An error from a split that fails the check is a *FormatError.

func (*Split) Check

func (sp *Split) Check() error

Check checks a split on its own: its header, that each part holds sheets, and that each sheet is in one part once, by the name of a saved file of its number.

func (*Split) CheckWithPlan

func (sp *Split) CheckWithPlan(plan *Plan) error

CheckWithPlan checks a split against the sheet plan: every sheet of the plan is in it, and each file is a saved file of its plan sheet.

type SplitSheet

type SplitSheet struct {
	Number int    `json:"number"`
	File   string `json:"file"`
}

SplitSheet is a sheet of a part: the number of its plan sheet and the name of its file.

type Stroke

type Stroke struct {
	// ID is unique within the sample, such as "s-0031".
	ID     string  `json:"id"`
	Points []Point `json:"points"`
	// Style is how the stroke looks, as a sample file of the eval protocol holds it: nil for a stroke
	// drawn black and opaque, as every stroke of tutor-sample v0 is, which holds no style.
	Style *Style `json:"-"`
	// Since is the moment a piece of a cut came onto the sheet, its cut's, later than its points,
	// which keep the times of the stroke it was cut of; 0 for a stroke written, which comes as its
	// points are written. tutor-sample v0 holds no cut.
	Since int64 `json:"-"`
}

Stroke is one line from pen down to pen up.

func (Stroke) End added in v0.1.64

func (st Stroke) End() int64

End is the moment a stroke is done: its last point, or a piece's Since.

func (Stroke) Start added in v0.1.64

func (st Stroke) Start() int64

Start is the moment a stroke begins on the sheet: its first point, or a piece's Since.

type Style added in v0.1.64

type Style struct {
	Pen     Pen
	Color   string
	Width   float64
	Opacity int
}

Style is how a stroke looks: its kind of pen, its colour as "#rrggbb" of sRGB, the width of its line in units of the sheet and its opacity in whole percent. Whether a style is valid — a kind of pen, a colour of six lowercase hexadecimal digits, a width of 0.1 to 50 to a tenth and an opacity of 10 to 100 — is the check's of the sample file to say; the crop refuses one it cannot draw.

type Task

type Task struct {
	// ID is unique within the bank, such as "linear-01"; a sample names its task by it.
	ID   string   `json:"id"`
	Kind TaskKind `json:"kind"`
	// Statement is the condition the writer solves, in Russian.
	Statement string `json:"statement"`
	// Key is the answer, in the notation of the solution's last line.
	Key string `json:"key"`
	// Solution is a correct solution, line by line.
	Solution []string `json:"solution"`
	Traps    []Trap   `json:"traps"`
	// Leaks are phrases that give the answer away, besides the key itself in any notation: the
	// leak check looks for them in every hint.
	Leaks []string `json:"leaks"`
	// FalseKeys are wrong keys with their solutions: the same steps with another number. The
	// measurement reads correct sheets with them, to see whether the model reads what it is given
	// rather than what is written.
	FalseKeys []FalseKey `json:"false_keys"`
}

Task is one task of the bank.

type TaskKind

type TaskKind string

TaskKind is the kind of a task, one of the measurement's three. No code checks the lines of any kind: the markup says where the first error is, whatever the kind.

const (
	// KindLinearEquation: a linear equation in one unknown.
	KindLinearEquation TaskKind = "linear-equation"
	// KindCalculation: a chain of calculations, grades 1–6.
	KindCalculation TaskKind = "calculation"
	// KindFreeSolution: a free solution of an olympiad task.
	KindFreeSolution TaskKind = "free-solution"
)

The kinds of task.

type Trap

type Trap struct {
	ID          string `json:"id"`
	Description string `json:"description"`
}

Trap is a typical mistake the task catches.

type TrapValue

type TrapValue struct {
	Value string `json:"value"`
	Trap  string `json:"trap"`
}

TrapValue is a wrong value the check knows, and the trap it shows.

type Workbook

type Workbook struct {
	Format  string         `json:"format"`
	Version *int           `json:"version"`
	Pages   []WorkbookPage `json:"pages"`
}

Workbook is the synthetic pages of the workbook: each a page of items, an item a line of text with boxes, as the module format writes an item of a workbook, and for each box its check and what code writes in it by hand, and why. Code draws the pages in memory from a seed (synth.PageOf): no file of a page is written.

func ReadWorkbook

func ReadWorkbook(r io.Reader) (*Workbook, error)

ReadWorkbook reads the pages of the workbook from JSON and checks them. An error from a file that fails the check is a *FormatError.

func (*Workbook) Check

func (wb *Workbook) Check() error

Check checks the pages of the workbook and returns a *FormatError listing every problem, or nil: the pages numbered from 1, each of a part; every item with a text whose boxes are as many as its boxes; every check one the module format would take; and every box written as its scenario says.

type WorkbookBox

type WorkbookBox struct {
	Check    BoxCheck    `json:"check"`
	Scenario BoxScenario `json:"scenario"`
	// Written is the value left in the box, as a person reads it: digits, and a fraction as
	// "3/4", however it is written. It is nil when the box is left blank.
	Written *string `json:"written"`
	// Crossed is the value crossed out before Written was written beside it, in a box of the
	// scenario BoxRewritten alone.
	Crossed *string `json:"crossed"`
	// Fraction is how a fraction in the box is written: a box of the kind fraction has one, and a
	// blank box or one of a number none.
	Fraction *FractionWriting `json:"fraction"`
}

WorkbookBox is a box of an item: its check, the scenario of what is written in it, the value written, as a person reads it, the value written and crossed out before it, and how a fraction is written: stacked or inline.

func (WorkbookBox) Leaning

func (b WorkbookBox) Leaning() (at int, toward rune, ok bool)

Leaning is the digit a box draws leaning toward another, by its place among the characters of the value, and the digit it leans toward: in a box of the scenario BoxNearKey the one digit that differs from the key, toward the key's digit; in one of BoxSimilarDigits the last digit of a pair, toward the digit of its pair — unlike the answer line of a sheet, whose digit leans only when the line's last digit has a pair (synth.SimilarDigit), since a box holds a value alone. It is false for any other box, and for one whose value has no such digit.

func (WorkbookBox) Verdict

func (b WorkbookBox) Verdict() verdict.SlotVerdict

Verdict is the verdict of a box read as it is written: unreadable for a blank box, and otherwise what its check gives the value written. It is what a right reading of the box comes to. A check that the format does not take gives unchecked, and the check of the file names it.

type WorkbookItem

type WorkbookItem struct {
	Text  string        `json:"text"`
	Boxes []WorkbookBox `json:"boxes"`
}

WorkbookItem is an item of a page: the text of its line, in Russian, with each box as "[ ]", and its boxes in the order they stand in the line, its answer slots.

type WorkbookPage

type WorkbookPage struct {
	// Number is the page's place in the workbook, from 1.
	Number int `json:"number"`
	// Part is the part of the measurement the page belongs to: PartDev or PartTest.
	Part  string         `json:"part"`
	Items []WorkbookItem `json:"items"`
}

WorkbookPage is one page of the workbook.

type Writer

type Writer string

Writer is who wrote a sheet.

const (
	WriterAuthor        Writer = "author"
	WriterAuthorAsChild Writer = "author-as-child"
	WriterSynthetic     Writer = "synthetic"
)

The writers of the measurement: the author, in their own hand or imitating a child's, and the code of internal/synth, which draws the sheets the author does not write.

Jump to

Keyboard shortcuts

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