Documentation
¶
Overview ¶
Package cmd adlib.go
Sentences with the vocabulary chosen at random.
It is the party game: a sentence with its nouns and verbs left blank, and words dropped into the blanks by someone who has not read it. What makes that work here rather than reading as word salad is that the blanks are typed -- a verb slot gets a verb, and a transitive slot gets a verb that can take an object -- and dict already knows which words are which, because every entry it carries says so.
The sentence is built in layers. A frame is who is telling you about it -- someone said this, somebody else denies it, someone is asking whether it is true. A clause is the thing that happened, and it is a subject and a predicate, each drawn separately: a subject from a dozen shapes, a predicate from four sets that differ in tense, voice and polarity, so that the same event can have happened, be happening, have been done to something else, or be refusing to happen at all.
Nothing about that is enumerated. A list of whole sentences, however long, wears out faster than it looks: the vocabulary is 124,000 words deep and never repeats a word, so the only thing a reader can recognize twice on a page is the shape, and shapes written out by hand run to a few hundred. Composed instead -- every optional piece doubling the count, every choice multiplying it -- they stop being countable. Over 400 sentences, 399 have a distinct skeleton once the content words are blanked out, and no three-word opening accounts for more than one line in twenty.
Nothing here conjugates a verb by guesswork either. dictdb.Tag carries the forms the entry lists, so a clause can say {vt:past} and get "rent" for "rend", which is what lets the sentences be told in the past tense instead of hiding every verb behind "will".
The names come from the same place as everything else. A sixth of the word list is capitalized, and dict knows which of those are people and which are places, so a sentence can have a cast: Basil, Kowloon, that ocelot of Cheney's.
Package cmd host.go ¶
Where the command's output goes, and how wide it may be.
dict was written as a program with a process: it printed to os.Stdout, asked the tty how wide it was, and exited. A shell applet in a browser has none of those. It has a pair of pipes, a size the terminal reports, and a caller that must survive the command failing.
The three answers live here so the commands can stay one implementation rather than growing a second, browser-shaped copy that drifts from the first.
Package cmd rain.go ¶
The word list, falling.
It is the matrix code rain with the alphabet replaced by the words dict already carries, so each stream spells one and a column reads downward. The rain is termanim's; what dict supplies is the vocabulary.
Package cmd rainglow.go ¶
Words found reading ACROSS the rain.
The streams fall vertically and each spells a word downward. Now and then the letters that happen to sit side by side on one row spell a word too, by accident, and this finds those and holds them lit.
Three rules, and each one is what makes it read as a discovery rather than as noise:
A dark cell breaks a run. Only letters currently lit count, so a word cannot be completed by a letter that has already faded — the run has to be there, on the screen, at that moment.
A found word stops fading. The trail behind a stream dims as it falls; a held word does not, so it stays legible while the rain moves on around it.
A hold ends when new rain writes over it. That is the only thing that ends it: the word stays until a stream puts a different letter in one of its cells.
Package cmd holds the command line, built on cobra.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RootCmd = &cobra.Command{ Use: "dict [query]", Short: "look up how a word is spelled, and what it means", Long: "look up how a word is spelled, and what it means.\n" + "the word list and all eight dictionaries are built into this binary;\n" + "nothing needs to be installed.", Example: " dict recieve search interactively, starting from a misspelling\n" + " dict -d receive print the definition and exit\n" + " dict -R a random word and what it means\n" + " dict -f -n 5 acheive print the five best matches", Args: cobra.ArbitraryArgs, SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, DisableFlagsInUseLine: true, RunE: run, Version: Version, }
RootCmd is the root command
var Version = "dev"
Version is overridden at build time with -ldflags -X ...cmd.Version=...
Functions ¶
func RainStill ¶
RainStill returns one frame of the word rain, as text with escapes.
Nothing is written over it. The still exists to be looked at, and as the thing the help backdrop composites text onto.
Types ¶
type Host ¶
type Host struct {
Stdout io.Writer
Stderr io.Writer
// Stdin is what is piped in, which only :unicode reads: naming the
// characters in a stream is the one thing dict does with input rather
// than arguments. Nil means os.Stdin, which is what a process has and a
// browser applet does not.
Stdin io.Reader
// Width is the wrapping width. Zero means ask the terminal, which is
// what a process does and what a browser cannot.
Width int
// Height is the rows a full-screen still fills. Zero asks the terminal.
Height int
// Interactive reports whether the full-screen picker can run. A
// process decides this from isatty; a host that is not a process has
// to say.
Interactive bool
// TTY is the terminal the full-screen picker draws on and reads keys
// from. Nil means open /dev/tty, which is what a process does and
// what a browser cannot: there is no such file in js/wasm, and no
// termios behind it either.
TTY io.ReadWriter
// SetRaw puts TTY into raw mode — no echo, no newline translation —
// and back again. Nil means the process path, which asks termios
// directly. A browser terminal is told by its embedder instead, and
// for a host whose input is already raw this can stay nil.
SetRaw func(on bool)
// Fetch opens a dictionary this build does not embed. Nil means there
// is nowhere to fetch from, which is the answer for a process: it has
// the whole corpus already. The browser demo carries only the small
// dictionaries and fetches GCIDE and WordNet from the site it was
// served by, so that the page defines the same words this does.
Fetch data.Fetcher
}
Host supplies what the command cannot discover for itself.