normal

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 8 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 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 (format/README.md, sections 15 and 20): the steps 1 to 7 of a number and the units of step 6, the normal form of a choice, and a number in notation as an exact rational. The verdict reads the values read by it, and the leak check the texts it searches, the keys and the leak phrases; it came out of package verdict when the leak check came to need it too (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

View Source
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.

View Source
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

func Choice(text string) string

Choice gives what a choice compares: the text through NFKC, the dashes and slashes of step 3 and the white space of step 4, and then in lowercase. Nothing more is dropped: a = or a . can be what the learner chose.

func Lower

func Lower(text string) string

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

func Number(value string, units []string) string

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

func Scripts(text string) string

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. The leak check takes the same step (section 20).

func Text

func Text(text string) string

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 U+2010 and U+2012 to U+2015 and the minus sign U+2212 become -, the fraction slash U+2044 and the division slash U+2215 become /; and every run of white space, the characters with the property White_Space, becomes one space, with none at either end.

func Unit

func Unit(unit string) string

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).

Types

type Written

type Written struct {
	Value  *big.Rat
	Lowest bool
}

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.

func Notation

func Notation(text string, kind formatv0.CheckKind) (Written, bool)

Notation reads a text in the notation that a kind takes — number all three, fraction a simple fraction, predicate an integer — and says whether it is in it. big.Rat reduces a fraction, so whether it is in lowest terms is read off the numerator and the denominator as they are written.

Jump to

Keyboard shortcuts

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