Dumb people write code that only geniuses can understand. Smart people write code that dumb people can understand. mjb at nomlang.org
Executes the system command in the workspace and reads the result into the workspace.
clear; add "echo $PATH"; system; print; clear; quit;
This command can actually be used to implement interactive 'conversation'
scripts, where the script prompts the user for some information and the user
replies. The actual conversation loop would be implemented in some other
language (ruby: this is called /eg/nom-chat.rb ) but all of the
conversation logic is contained in the nom script.
A demonstration of this technique could be an implementation of the “Eliza” program (which is a simple jungian psychologist mimicker).
The script /eg/chat.timeline.pss shows a useful implementation of a chatbot
which is written with nom. It also uses a ruby script to provide the
loop to read input from the user. The chat.time.pss uses the script
/eg/timeline.tohtml.pss to compile the historical timeline into html.
But I will probably just use /eg/text.tohtml.pss instead and provide it with
a different style-sheet.
./nom-chat.rb chat.timeline.pss
The nom fragment below responds to a sentence
# fragment
# read the input word-by-word
while [:space:]; clear;
whilenot [:space:]; put;
"this","that","it" {
"that","it" { clear; add "this"; }
put; clear; add "this*"; push; .reparse
}
"print","type","show","delete","del","remove","rm" {
# make the actions canonical
"type","show" { clear; add "print"; }
"del","remove","rm" { clear; add "delete"; }
put; clear; add "action*"; push; .reparse
}
!"" {
clear; add "unknown word: "; get; add "\n"; print; quit;
# trigger the error/help system here.
}
parse>
pop; pop;
"action*this*" {
clear; get; "print" {
clear; add "sed -n '/^ *this:/{s/^ *this://;p}' state.txt";
system; put; clear;
add "cat "; get; put; clear;
}
clear; add "command*"; .reparse
}
(eof) {
"command*" {
}
}
push; push;
This command is very powerful, and I hesitated before adding it to the pep-nom system because I wanted to keep pep and nom as simple as possible, adhering to it’s core tenet of being a language parser. But I think this command does not deviate from nom's “core mission” because it only reads text into the machine. It also should allow nom to be used in my “Tiny Language” Model" experiments, which is to create scripts that accept simple plain English queries and actions and then execute them.