That is great. This can be useful when interfacing with stored facts and performing queries. Facts about the main subject can be queried for instance and responses selected based on knowledge from facts from other sources.
I was able to get the following code to work:
u: FINDMAINSUBJECT( _~mainsubject ) ^keep() ^repeat() $$MAINSUBJECT = _0 ^RETRY(FINDMAINVERB)
u: FINDMAINVERB( _~mainverb ) ^keep() ^repeat() $$MAINVERB = _0 ^RETRY(FINDMAINDIRECTOBJECT)
u: FINDMAINDIRECTOBJECT( _~mainobject ) ^keep() ^repeat() $$MAINDIRECTOBJECT = _0 ^RETRY(FINDMAININDIRECTOBJECT)
u: FINDMAININDIRECTOBJECT( _~object2 ) ^keep() ^repeat() $$MAININDIRECTOBJECT = _0 ^RETRY(ANALYZESENTENCE)
u: ANALYZESENTENCE( _* ) ^keep() ^repeat()
@1 = ^burst(‘_0)
$sentencelength = ^length(@1)
This sentence has $sentencelength words. \n
if (%parsed = 1) {
Main subject: $$MAINSUBJECT \n
Main verb: $$MAINVERB \n
Main direct object: $$MAINDIRECTOBJECT \n
Main indirect object: $$MAININDIRECTOBJECT \n }
else
{Unable to parse sentence.}
Sample Output:
>I hit the nail with the hammer.
This sentence has 7 words.
Main subject: I
Main verb: hit
Main direct object: nail
Main indirect object: hammer
>The boy threw the ball.
This sentence has 5 words.
Main subject: boy
Main verb: throw
Main direct object: ball
Main indirect object:
>The horse jumped over the gate.
This sentence has 6 words.
Main subject: horse
Main verb: jump
Main direct object:
Main indirect object: gate
(I was able to use concepts ~mainobject and ~object2 but was not successful trying ~maindirect and ~mainindirect.)