text

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package text provides string, line, and edit-distance text manipulation functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLineFromOffset

func GetLineFromOffset(content string, offset int) int

GetLineFromOffset returns the 1-based line number for a given byte offset in content.

func GetLineOffsets

func GetLineOffsets(content string, startLine, endLine int) (int, int, error)

GetLineOffsets returns the start and end byte offsets for the given 1-based line range in content.

func GetSnippet

func GetSnippet(content string, lineNum int) string

GetSnippet returns a snippet centered around lineNum in content.

func IsWhitespace

func IsWhitespace(r rune) bool

IsWhitespace reports whether a rune is a standard space, tab, or newline character.

func Levenshtein

func Levenshtein(s1, s2 string) int

Levenshtein computes the Levenshtein edit distance between two strings. It operates on runes to correctly handle multi-byte characters.

func Normalize

func Normalize(s string) string

Normalize strips all whitespace characters from a string.

func Similarity

func Similarity(s1, s2 string) float64

Similarity calculates the normalized similarity score (0.0 to 1.0) between two strings.

Types

This section is empty.

Jump to

Keyboard shortcuts

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