words

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: 5 Imported by: 1 module, 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 words holds the checks of the tutor's words that api makes before they reach the learner, beside the leak check: the form of a hint, the form of the words after a correct answer and the rule of feedback by a rubric. The eval of tutor measures the models by the same code, so that what it admits is what the platform lets through. The checks only count: they read no meaning, and what a word, a sentence and a quote are, this package decides.

Index

Constants

View Source
const (
	// HintSentences is the most sentences a hint has.
	HintSentences = 2
	// FeedbackSentences is the most sentences feedback has.
	FeedbackSentences = 3
	// QuoteWords is how many words a quoted span has at least to be held to the learner's own.
	QuoteWords = 4
)

The limits of the platform's rule of the tutor's words that hold in every language.

Variables

This section is empty.

Functions

func Count

func Count(text string) (sentences, questions, words int)

Count counts the sentences, the questions and the words of a text, read after NFKC, so that "…" is three points and a full-width "?" a question mark.

A word is a run of letters, marks and numbers (leak.IsWord), and a point, comma or slash between two digits joins them: 0.5 and 4/3 are a word each. A sentence ends at a run of ".", "!" and "?", among which closing quotes and brackets may stand, and then white space, a capital letter or the end; a question is a sentence whose run holds a "?". Its tail without a point is a sentence too, and a run with no word before it ends none. So "0.5" ends nothing, but an abbreviation such as «т. е.» ends a sentence: a limit of the rule.

func FeedbackWords

func FeedbackWords(language string) int

FeedbackWords is the most words the platform's rule lets feedback have: 80 in English, the one language the measurement of essays measured, and 0, no limit, in another.

func HintWords

func HintWords(language string) int

HintWords is the most words the platform's rule lets a hint have in a language, by the numbers of the measurement: 30 in Russian and 35 in English; 0, no limit, in a language the measurement did not measure. A language is its tag, such as "en", "ru-RU" or "en_US", and its first subtag counts.

func Over

func Over(n, limit int) bool

Over is whether n words break a limit: none at all, or more than the limit, 0 being no limit.

func Plain

func Plain(text string) []string

Plain are the words of a text in small letters, without the marks around them: what quotes are compared by, and the reading of an essay too. A typographic apostrophe is the straight one.

func Readable added in v0.1.18

func Readable(language string) bool

Readable is whether a language tag has a first subtag a check can read: two or three letters. A check of a tag that is not fails closed, with the breach Language.

Types

type Breach

type Breach string

Breach is a part of a check that words break, as a log names it.

const (
	// Questions: not exactly one sentence of a hint is a question.
	Questions Breach = "questions"
	// Sentences: more sentences than the check takes.
	Sentences Breach = "sentences"
	// Last: the question of the words after a correct answer is not their last sentence.
	Last Breach = "last"
	// Words: no word, or more than the limit of the language.
	Words Breach = "words"
	// Quote: a quoted span of QuoteWords words or more that the learner did not write.
	Quote Breach = "quote"
	// Script: a letter that is not of the script of the language.
	Script Breach = "script"
	// Language: the language is no tag a check can read, such as an empty one: the check fails
	// closed rather than drop its limits.
	Language Breach = "language"
)

The breaches, in the order the checks name them.

func Correct added in v0.1.34

func Correct(text, language, statement string) []Breach

Correct is what the words after a correct answer break of their form, in the order of the breaches; nil when they keep it: the praise of a step and one question on the technique that helped — exactly one question, and it the last sentence, so that no more than one sentence of praise stands before it; 1 to HintWords words of the language; and the letters of its script, as a hint's.

func CorrectForm added in v0.1.34

func CorrectForm(text, language, statement string, maxWords int) []Breach

CorrectForm is Correct with a limit of words of its own, 0 for none.

func Feedback

func Feedback(text, read, language string) []Breach

Feedback is what feedback by a rubric breaks of the rule the platform sets, in the order of the breaches; nil when it keeps it: no more than FeedbackSentences sentences, 1 to FeedbackWords words of its language, every quoted span of QuoteWords words or more the learner's own words in a row in the text read — the text the assessment got, not the essay as written, which the platform does not have —, and its letters of the script of its language.

func FeedbackForm

func FeedbackForm(text, own, language string, maxWords int) (breaches []Breach, words int)

FeedbackForm is Feedback with a limit of words of its own, 0 for none, against the learner's own text, whatever it is, with the words the feedback has: the measurement of essays held feedback to 60 words, against the essay as it was written. Its letters are read as written, not after NFKC, as the measurement read them.

func Hint

func Hint(text, language, statement string) []Breach

Hint is what a hint breaks of the form the platform sets, in the order of the breaches; nil when it keeps it: exactly one question, in no more than HintSentences sentences, of 1 to HintWords words of its language, and its letters of the script of its language. The statement is the task's, whose Latin letters, such as the x of an equation, may stand in a Russian hint.

func HintForm

func HintForm(text, language, statement string, maxWords int) []Breach

HintForm is Hint with a limit of words of its own, 0 for none: the measurement of hints held them to 30 words in either language, as its prompt said.

Jump to

Keyboard shortcuts

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