Skip to main content

Function: foldText()

foldText(text): FoldedText

Defined in: packages/agentos/src/cognition/library/tokens.ts:176

A text folded for matching, with the map back to the source: each code point decomposed (NFD), its combining marks dropped and a curly apostrophe (U+2019) made straight, then the text lower-cased whole, as a search lower-cases a whole word, so the folded text of a word is that word's fold. Lower case maps each code point alone but for a capital sigma, whose final form depends on its neighbours, and a sigma's two forms are one unit each, so each code point takes the piece of the whole text's lower case as long as its own lower case, and its units take the code point's interval. A code point that yields nothing, a combining mark, widens the interval of the character before it. The fold changes a text's length, so a match found in text is placed in the source through map, never by its offsets in text.

Parameters​

text​

string

Returns​

FoldedText