normal

package
v0.3.19 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 10 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: 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.

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

func ChoiceOf(c formatv0.Check, text string) string

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. A choice by tapping has no notation, and is a choice of options.

func Compared added in v0.1.23

func Compared(c formatv0.Check, units []string, text string) (string, bool)

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.

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.

func Search(text string) string

Search gives the normal form in which the leak check searches a text: step 1, then Choice. 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

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

func Time(value string) string

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.

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

func Units added in v0.1.23

func Units(c formatv0.Check) []string

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

func Word(text string) bool

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

func WordNotation(c formatv0.Check) bool

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

func TimeNotation(text string) (Clock, bool)

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.

func (Clock) String added in v0.3.0

func (c Clock) String() string

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

Jump to

Keyboard shortcuts

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