Documentation
¶
Overview ¶
Package text provides string, line, and edit-distance text manipulation functions.
Index ¶
- func GetLineFromOffset(content string, offset int) int
- func GetLineOffsets(content string, startLine, endLine int) (int, int, error)
- func GetSnippet(content string, lineNum int) string
- func IsWhitespace(r rune) bool
- func Levenshtein(s1, s2 string) int
- func Normalize(s string) string
- func Similarity(s1, s2 string) float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLineFromOffset ¶
GetLineFromOffset returns the 1-based line number for a given byte offset in content.
func GetLineOffsets ¶
GetLineOffsets returns the start and end byte offsets for the given 1-based line range in content.
func GetSnippet ¶
GetSnippet returns a snippet centered around lineNum in content.
func IsWhitespace ¶
IsWhitespace reports whether a rune is a standard space, tab, or newline character.
func Levenshtein ¶
Levenshtein computes the Levenshtein edit distance between two strings. It operates on runes to correctly handle multi-byte characters.
func Similarity ¶
Similarity calculates the normalized similarity score (0.0 to 1.0) between two strings.
Types ¶
This section is empty.