tokenize

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RU    = "RU"
	LAT   = "LAT"
	INT   = "INT"
	PUNCT = "PUNCT"
	OTHER = "OTHER"
)

Atom kinds mirror upstream razdel.segmenters.tokenize (RU, LAT, INT, PUNCT, OTHER).

View Source
const Brackets = openBracket + closeBracket

Brackets is OPEN + CLOSE (upstream BRACKETS).

View Source
const Dashes = dashes

Dashes is upstream DASHES.

View Source
const Endings = endings

Endings is upstream ENDINGS.

View Source
const PunctSet = "\\/!#$%&*+,.:;<=>?@^_`|~№…" + Dashes + Quotes + Brackets

PunctSet is the character class used in upstream ATOM's PUNCT alternative (PUNCTS in tokenize.py: ascii punct + № … + dashes + quotes + brackets).

View Source
const Quotes = openQuote + closeQuote + genericQuote

Quotes is OPEN + CLOSE + GENERIC (upstream QUOTES).

Variables

This section is empty.

Functions

func TokenSpans

func TokenSpans(text string) [][2]int

TokenSpans returns (start, end) byte offsets for each token, matching upstream find_substrings.

func TokenTexts

func TokenTexts(text string) []string

TokenTexts returns final token strings (upstream tokenize() without find_substrings offset pass).

Types

type Atom

type Atom struct {
	Start int
	Stop  int
	Type  string
	Text  string
}

Atom is one lexical atom from upstream Atom (start/stop as byte offsets, half-open).

func Atomize

func Atomize(text string) []Atom

Atomize scans text into atoms using the same classification order as upstream ATOM regex.

func (Atom) Normal

func (a Atom) Normal() string

Normal is lowercase text (upstream atom.normal).

Jump to

Keyboard shortcuts

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