Nesting Clauses

July 2nd, 2020

A particularly nasty problem arises when you want to nest clauses inside sentences. The sentence model I have used relies on a verb with a defined set of objects. However, if you wish to include clauses within a sentence, this model fails, because the clauses themselves might include different numbers of objects. The only resolution to this problem is to introduce a new data structure that I’ll cleverly call a Clause. 

A Clause is really just a Sentence that is not an Event: it is never executed. Instead, it is pointed to indirectly by an Event. Here’s how it would appear in the HistoryBook:

Clause 237: Mary gives her bicycle to Fred.
Event 566: Fred requests of Mary Clause 237.

This isn’t difficult to process; the killer problem is the user interface. The user would first have to shift to “Clause Mode” in which the normal Role and Option restrictions on word selection are set aside. This in turn means that the inverse parser is almost useless, as the user would have to be able to specify almost any word at any position in the sentence. Let’s walk throught the process.

First, Fred would have to shift to Clause Mode. That could be managed automatically by the verb if we create a new WordSocket type called “Clause”. Thus, when Fred selects the verb “requests”, the inverse parser first demands a DirObject; after Fred specifies “Mary” as the DirObject, the inverse parser drops into “Clause Mode” and starts a new Sentence with Mary as the Subject. Here’s where we hit the brick wall: the inverse parser must permit ANY verb. This could generate a menu several hundred items long. That’s a problem. Perhaps it could be handled by presenting the verbs in alphabetical order. 

If we can get past the problem of handling the huge number of verbs, the rest of the specification of the clause follows directly from the specification of the verb using the inverse parser. I haven’t done this, but I suspect that the best way to handle this is with a recursive nesting system, like so:

FredRequests

Note that this system is recursive:

FredRequests2

In each of these cases the clause is stored in the history book as a clause with a unique ID number. The HistoryBook entry for this second case would read like this:

Clause 237: John gives his bicycle to Fred.
Clause 238: Mary demands John Clause 237.
Event 566: Fred requests of Mary Clause 238.


In the next lesson, I’ll show you one way to use clauses with deals.