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
- func Count(text string) (sentences, questions, words int)
- func FeedbackWords(language string) int
- func HintWords(language string) int
- func Over(n, limit int) bool
- func Plain(text string) []string
- func Readable(language string) bool
- type Breach
- func Correct(text, language, statement string) []Breach
- func CorrectForm(text, language, statement string, maxWords int) []Breach
- func Feedback(text, read, language string) []Breach
- func FeedbackForm(text, own, language string, maxWords int) (breaches []Breach, words int)
- func Hint(text, language, statement string) []Breach
- func HintForm(text, language, statement string, maxWords int) []Breach
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
Over is whether n words break a limit: none at all, or more than the limit, 0 being no limit.
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
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
CorrectForm is Correct with a limit of words of its own, 0 for none.
func Feedback ¶
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 ¶
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 ¶
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.