GizStack
View .mdOpen in ChatGPTOpen in Claude

gizmodel/sql/types/tsdict

gizlang
import * as Tsdict from "gizmodel/sql/types/tsdict";

Types

TsObject

gizlang
type TsObject = { name: string; text: string; }

A text search object CREATE TEXT SEARCH made, as the catalog keeps it.

  • name: string
  • text: string

TsObjects

gizlang
type TsObjects = { dictionaries: Vec<TsObject>; configurations: Vec<TsObject>; templates: Vec<TsObject>; parsers: Vec<TsObject>; }

The text search objects of one snapshot: this module reads them as data, the caller from the catalog.

  • dictionaries: Vec<M165.TsObject>
  • configurations: Vec<M165.TsObject>
  • templates: Vec<M165.TsObject>
  • parsers: Vec<M165.TsObject>

TsChange

gizlang
type TsChange = { text: string; made: bool; }

What CREATE or ALTER of a dictionary or configuration stores under its name; made when ALTER is complete with it.

  • text: string
  • made: bool

TsLex

gizlang
type TsLex = { word: string; nvariant: i64; flags: i64; }

A lexeme a dictionary gives: its text, its variant (the lexemes of one variant go together) and TSL_* flags.

  • word: string
  • nvariant: i64
  • flags: i64

TsDict

gizlang
type TsDict = { name: string; template: string; stop: string; accept: bool; syn: Map<string, i64>; synOut: Vec<TsLex>; caseSensitive: bool; sp: Ispell; th: Thesaurus; sub: i64; }

A dictionary: its template and the data it needs. STOP names its stop word list ("" for none).

  • name: string
  • template: string
  • stop: string
  • accept: bool
  • syn: _gizlang_sdk_collections.Map<string, i64>
  • synOut: Vec<M165.TsLex>
  • caseSensitive: bool
  • sp: M165.Ispell
  • th: M165.Thesaurus
  • sub: i64

TsConfig

gizlang
type TsConfig = { name: string; maps: Vec<Vec<i64>>; }

A configuration: the dictionaries of each token type, by type id (0 unused).

  • name: string
  • maps: Vec<Vec<i64>>

TsEnv

gizlang
type TsEnv = { configs: Vec<TsConfig>; dicts: Vec<TsDict>; }

The dictionaries and configurations a statement sees.

  • configs: Vec<M165.TsConfig>
  • dicts: Vec<M165.TsDict>

DictLexemes

gizlang
type DictLexemes = { dict: string; lexemes: Vec<string>; }

A dictionary and the lexemes it gave.

  • dict: string
  • lexemes: Vec<string>

TsToken

gizlang
type TsToken = { t: i64; text: string; }

A token: its type (0 ends the text) and text.

  • t: i64
  • text: string

Functions

tokenTypes

gizlang
function tokenTypes(): Vec<Vec<string>>

The default parser's token types: alias and description, by id from 1.

Effects: fail, alloc.

dictInitOption

gizlang
function dictInitOption(text: string): Option<string>

The options as dictinitoption shows them, the template left out; none when there are no others.

Effects: fail, alloc.

dictTemplate

gizlang
function dictTemplate(text: string): string

The template of a dictionary's stored options, schema left out.

Effects: fail, alloc.

builtinTsEnv

gizlang
function builtinTsEnv(): TsEnv

The built-in dictionaries (simple and english_stem) and configurations (simple and english).

Effects: fail, alloc.

findConfig

gizlang
function findConfig(env: TsEnv, name: string): i64 throws DbError

The configuration named NAME, 42704 when there is none.

Effects: fail, alloc.

tsLexize

gizlang
function tsLexize(env: TsEnv, dictionary: string, word: string): Option<Vec<string>> throws DbError

ts_lexize(dictionary, word); 42704 for an unknown dictionary.

Effects: fail, alloc.

tokenLexize

gizlang
function tokenLexize(env: TsEnv, cfg: i64, t: i64, word: string): Option<DictLexemes> throws DbError

The first dictionary of configuration CFG for token type T that knows WORD, and its lexemes (ts_debug); none when no dictionary knows it.

Effects: fail, alloc.

configDicts

gizlang
function configDicts(env: TsEnv, cfg: i64, t: i64): Vec<string>

The names of the dictionaries configuration CFG sends token type T to.

Effects: fail, alloc.

lexizeTokens

gizlang
function lexizeTokens(env: TsEnv, cfg: i64, tokens: Vec<TsToken>): Vec<Vec<TsLex>> throws DbError

The lexemes of a text's tokens through configuration CFG (parsetext): one list for each word or phrase a dictionary took, in order; a stop word gives an empty list.

Effects: fail, alloc.

textSearchEnv

gizlang
function textSearchEnv(objects: TsObjects): TsEnv

The dictionaries and configurations of OBJECTS: the built-in ones, then those CREATE TEXT SEARCH made (a thesaurus after the others, as it lexizes its words through another); one that no longer builds is left out.

Effects: fail, console, alloc.

hasTextSearchObjects

gizlang
function hasTextSearchObjects(objects: TsObjects): bool

Whether OBJECTS hold a dictionary or configuration CREATE TEXT SEARCH made.

textSearchChange

gizlang
function textSearchChange(objects: TsObjects, action: string, what: string, name: string, text: string, notices: mut Vec<string>): Option<TsChange> throws DbError

CREATE or ALTER TEXT SEARCH DICTIONARY or CONFIGURATION NAME with TEXT (what follows the name): the text to store for CREATE; for ALTER of a dictionary's options or a configuration's mapping, the change is made here and the result is "" . None for the other statements (RENAME, OWNER TO, SET SCHEMA, DROP), which the caller makes.

Effects: fail, console, alloc.

Constants

TSL_ADDPOS

gizlang
const TSL_ADDPOS: i64 = 1

TSLexeme flags: one position more before this lexeme, a prefix match, and a lexeme for the next dictionary.

TSL_PREFIX

gizlang
const TSL_PREFIX: i64 = 2

TSLexeme flag: a prefix match.

DICTIONARY

gizlang
const DICTIONARY = "pg text search dictionary"

The catalog kind of a text search dictionary.

CONFIGURATION

gizlang
const CONFIGURATION = "pg text search configuration"

The catalog kind of a text search configuration.

TEMPLATE

gizlang
const TEMPLATE = "pg text search template"

The catalog kind of a text search template.

PARSER

gizlang
const PARSER = "pg text search parser"

The catalog kind of a text search parser.