pytext

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: BSD-2-Clause Imports: 12 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 pytext follows Python's rules for text where they differ from Go's: the string and rounding rules the tone models' inputs were written by, and the way Python writes a value out with str(), repr() and json.dumps(), which is what a model reads when a prompt quotes one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dumps added in v1.3.0

func Dumps(raw []byte) (string, error)

Dumps rewrites a JSON document as Python's json.dumps(json.loads(raw), ensure_ascii=False) writes it: keys in their order, ", " and ": " between items, a number with a fraction or an exponent as a float.

func Fields

func Fields(s string) []string

Fields is Python's str.split with no argument.

func Float added in v1.3.0

func Float(f float64) string

Float is Python's repr of a float: the shortest digits that read back as f, written plainly from 1e-4 up to 1e16 with at least one decimal, and in exponent form outside it.

func IsAlnum

func IsAlnum(r rune) bool

IsAlnum reports whether r is a letter or a number to Python's str.isalnum.

func IsSpace

func IsSpace(r rune) bool

IsSpace reports whether r is whitespace to Python's str.isspace: Unicode's White_Space, and the four separators U+001C to U+001F, which Go leaves out.

func Repr added in v1.3.0

func Repr(v any) string

Repr is Python's repr(v) for a JSON-like value: None, True and False, a float as Python writes it (2.0, 1e-07), a string quoted, a list in brackets and a dict in braces. An ordered.Object is a dict in its own order; a Go map is a dict in key order, having no order of its own. Anything else is written as fmt.Sprint writes it.

func Round

func Round(x float64, digits int) float64

Round is Python's round(x, digits): the decimal nearest x, with a tie, which only an exact binary value can be, going to the even digit.

func Str added in v1.3.0

func Str(v any) string

Str is Python's str(v) for a JSON-like value: a string as itself, anything else as Repr writes it.

func Strip

func Strip(s string) string

Strip is Python's str.strip with no argument.

Types

This section is empty.

Jump to

Keyboard shortcuts

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