Documentation
¶
Overview ¶
Package normal normalizes a text as the check kinds of the module format and its leak check do, and reads a number in the notation that a kind takes: the steps 1 to 7 of a number and the units of step 6, the normal form of a choice of either notation, a time by its hours and minutes, and a number in notation as an exact rational. The verdict and the leak check share it, so that both read a text alike (R27, R30).
Its NFKC is golang.org/x/text/unicode/norm, and the version of Unicode that it follows is UnicodeVersion, which package verdict names for a release.
Index ¶
- Constants
- func Choice(text string) string
- func ChoiceOf(c formatv0.Check, text string) string
- func Compared(c formatv0.Check, units []string, text string) (string, bool)
- func Lower(text string) string
- func Number(value string, units []string) string
- func Scripts(text string) string
- func Search(text string) string
- func Text(text string) string
- func Time(value string) string
- func Unit(unit string) string
- func Units(c formatv0.Check) []string
- func Word(text string) bool
- func WordNotation(c formatv0.Check) bool
- type Clock
- type Written
Constants ¶
const MaxNotation = 16
MaxNotation is the length of the longest text in notation. A text in notation is ASCII, so its length in bytes is its length in characters.
const UnicodeVersion = norm.Version
UnicodeVersion is the version of Unicode of the tables of NFKC that the package is built with.
Variables ¶
This section is empty.
Functions ¶
func Choice ¶
Choice gives what a choice compares: the text through steps 2 to 4, then in lowercase. Nothing more is dropped: a = or a . can be what the learner chose.
func ChoiceOf ¶ added in v0.3.0
ChoiceOf gives what a choice of the check compares: Choice of the text, and, with notation: word, every ., !, ? and space at its end dropped as well, so that Kim. is kim and ? is blank (R52). A choice by tapping has no notation, and is a choice of options.
func Compared ¶ added in v0.1.23
Compared gives what a check compares a value by, and whether it compares it at all: a choice, its normal form by its notation, ChoiceOf, always; a number, a fraction and a predicate, its value in the kind's notation, exactly, written in lowest terms; a time, its hours and its minutes, each as a number, when it is in the notation of a time read. units are the forms of a number's units, as Units gives them. The verdict and the comparison of the versions of a module compare by it alike (R36).
func Lower ¶
Lower maps each character to its simple lowercase mapping (UnicodeData.txt, field 13), as unicode.ToLower does, a character at a time: no context counts, as a final sigma's would, and no character becomes two.
func Number ¶
Number gives a value as number, fraction and predicate read it, steps 1 to 7, with units, the forms of a number's units that Unit gives: "" when it is blank.
func Scripts ¶
Scripts takes step 1: every superscript or subscript digit becomes U+FFFD, which no notation takes, and so does every vulgar fraction that a number, a character of the general category N, stands right before or right after in the text as it is, so that NFKC does not make 7² into 72 or 1½ into 11⁄2.
func Search ¶ added in v0.3.0
Search gives the normal form in which the leak check searches a text: step 1, then Choice (R30). The check of a module compares by it the text pieces of a line of a worked example with those of a task's line.
func Text ¶
Text takes steps 2 to 4, in their order, so that steps 3 and 4 take what NFKC gives too: NFKC; the hyphens and dashes and the minus sign become -, the fraction and division slashes /; and every run of White_Space becomes one space, with none at either end.
func Time ¶ added in v0.3.0
Time gives a value as a time reads it: steps 1 to 5 of a number, with the spaces at either end dropped, so that "07:30." is "07:30"; "" when it is blank (R52).
func Unit ¶
Unit gives what a unit compares by: steps 1 to 5, as the value goes through them, the spaces at either end dropped, and each character in lowercase (step 6).
func Units ¶ added in v0.1.23
Units gives the forms of the units of a number, Unit of each, those that are not empty: a check of another kind has none.
func Word ¶ added in v0.3.0
Word says whether a text is one word of letters: a letter, a character of the general category L, then letters and marks, M, as the vowel signs of a word in Devanagari, and nothing else. An empty text is none.
func WordNotation ¶ added in v0.3.0
WordNotation says whether a choice is of the notation word, which takes any one word of letters besides its options: notation is options unless given.
Types ¶
type Clock ¶ added in v0.3.0
type Clock struct {
Hours, Minutes int
}
Clock is a time in the notation of a time read, by its hours and its minutes, each as a number: 07:30 and 7:30 are one clock, and 5:60 is not 6:00, since the sum of minutes is never taken.
func TimeNotation ¶ added in v0.3.0
TimeNotation reads a text that Time normalized as a time, and says whether it is in the notation of a time read: 7:3, 007:30, 7.30, 7 : 30 and 7:30 pm are not.
type Written ¶
Written is a number in notation: its value, exactly, and whether it is written in lowest terms, as a simple fraction whose numerator and denominator have no common divisor but 1 is, and an integer or a decimal always is.