GizStack
View .mdOpen in ChatGPTOpen in Claude

gizai/written/english

a small English for a Reader (./reader.giz): people, cities, countries, foods and jobs, five relations between them, and the sentences that state and ask them. It gives the Reader's form, the worlds a Reader is trained on (drawn at random; no text of anyone), and the reading of a typed line: its words as the Reader's tokens, with each new name bound to a free entity of its kind.

A name is a label of an entity. The binding of names to entities is a table (Names), not weights: what the Reader learns from a sentence is the fact between the entities.

gizlang
import * as English from "gizai/written/english";

Types

World

gizlang
type World = { to: Vec<Vec<i64>>; known: Vec<bool>; }

A world: for each relation, the object (an index of its kind) of each subject, and whether each fact is written (the facts in facts' order).

  • to: Vec<Vec<i64>>
  • known: Vec<bool>

Names

gizlang
type Names = { bound: Vec<Vec<string>>; }

The names bound to the entities of each kind, in the order they were first read.

  • bound: Vec<Vec<string>>

Line

gizlang
type Line = { kind: "told" | "asked" | "unread"; ask: Ask; told: Told; why: string; }

What a line is: a sentence to write (told), a question (ask), or neither, with the reason in why.

  • kind: string
  • ask: M52.Ask
  • told: M52.Told
  • why: string

Functions

form

gizlang
function form(): Form

The form of a Reader of this English.

Effects: fail, alloc.

world

gizlang
function world(seed: u64): World

The world that seed draws: each relation's objects, and which facts the reader is told.

Effects: fail, alloc.

partly

gizlang
function partly(w: World, seed: u64, percent: u64): World

w with percent of its facts not written, drawn by seed.

Effects: fail, alloc.

facts

gizlang
function facts(): Vec<Vec<i64>>

Each fact's (entity, relation), for Reader.keys.

Effects: fail, alloc.

objects

gizlang
function objects(w: World): Vec<i64>

Each fact's object entity in w, for Reader.written.

Effects: fail, alloc.

asks

gizlang
function asks(w: World): Vec<Vec<Ask>>

Every question of w, and every sentence start (what the Reader asks before a sentence's last word): one set a form, over its subjects.

Effects: fail, read, write, console, io, alloc.

basics

gizlang
function basics(w: World): Vec<Vec<Ask>>

The one-fact questions of w (one set a relation), in facts' order: what a Reader asks itself to study.

Effects: fail, read, write, console, io, alloc.

told

gizlang
function told(w: World): Vec<Vec<Told>>

Every sentence of w, written or not: one set a relation, in facts' order.

Effects: fail, read, write, console, io, alloc.

names

gizlang
function names(): Names

No names bound yet.

Effects: fail, alloc.

namesOf

gizlang
function namesOf(text: string): Names

The names that Names.encode wrote.

Effects: fail, alloc.

line

gizlang
function line(n: mut Names, text: string): Line

Reads a typed line. A sentence binds its new names; a question binds none.

Effects: fail, read, write, console, io, alloc.

Methods

Names.encode

gizlang
function Names.encode(self: Names): string

The names as text: a line of names for each kind.

Effects: fail, alloc.

Names.say

gizlang
function Names.say(self: Names, token: i64, unknown: i64): string

The Reader's word token as text: the name of its entity, or that it does not know.

Effects: fail, alloc.