EnParser module of the

First Working AGI Mind in JavaScript

MindForth for robots -- ghost.pl for webservers


1. Diagram of the EnParser Mind-Module


   /^^^^^^^^^\ EnParser Determines Parts Of Speech /^^^^^^^^^\
  /   EYE     \  MINDCORE               _____     /   EAR     \
 /             \ CONCEPTS              /New- \   /             \
|   _______     |   | | |      _____  (Concept)-|-------------\ |
|  /old    \    |   | | |     /Old- \  \_____/  |  Audition   | |
| / image   \---|-----+ |    (Concept)------|---|----------\  | |
| \ recog   /   |   | | |     \_____/-------|---|-------\  |  | |
|  \_______/    |  a| | |          |________V   |  c    |  |  | |
|               |  b|C| |         / EnParser \  |   a   |  |  | |
|   visual      |  s|O|f|         \__________/  |    t  |  |  | |
|               |  t|N|i|              |noun?   |     s-/  |  | |
|   memory      |  r|C|b|              |verb?   |          |  | |
|               |  a|E|e|              |adj.?   |  e       |  | |
|   channel     |  c|P|r|              |adverb? |   a      |  | |
|               |  t|T|s|              |prep.?  |    t-----/  | |
|   _______     |   | | |              |conj.?  |             | |
|  /new    \    |   |_|_|        ______V____    |  f          | |
| / percept \   |  /     \      /           \   |   i         | |
| \ engram  /---|--\ Psi /-----( InStantiate )  |    s        | |
|  \_______/    |   \___/       \___________/   |     h-------/ |


2. Purpose

EnParser serves the purpose of not only identifying a part of speech such as a noun, preposition or verb, but also of comprehending the part of speech in context by helping to assign associative tags among concepts in the Psy conceptual array. Thus EnParser and its Russian counterpart RuParser serve the purpose of Natural Language Understanding (NLU).

3. Function

To parse and comprehend an indirect object, EnParser tentatively fills the time-of-indirect-object $tio flag with the input-time of the first noun being input after a verb. The $tio flag is set only once by requiring that it be at zero for it to be set. Simultaneously, the time-of-direct-object flag $tdo is filled with the same value as the $tio flag for an indirect object, because it is not yet known whether one noun or two nouns are being entered subsequent to the input of a transitive verb. If and when a second noun comes in, the value for the time-of-direct-object $tdo flag, originally filled with the same value as the indirect-object $tio flag, is replaced or overwritten with the new time of the second post-verb noun in the input stream.

If only one noun comes in after the verb, the identifier of the direct object is set only once. If two post-verb nouns come in, the first noun becomes the indirect object and the second noun becomes the direct object.


4. Code of EnPerser() from ghost.pl First Working AGI in Perl

# 2017-09-03: Requirements of English Parser module:
# 2017-09-13: EnParser shall at first assume that a new word is a noun.
sub EnParser() {  # http://ai.neocities.org/EnParser.html 
  $act = 48;  # 2016apr27: an arbitrary activation for InStantiate()
  $bias = 5;  # 2015jun04: Expect a noun until overruled. 
  if ($fyi > 2) {  # 2016feb08: if mode is Diagnostic 
    # 2018-07-01: DIagnostic or tutorial message.
  }  # 2016feb07: end of test for Diagnostic or Tutorial mode.
  if ($pos == 5) { $bias = 8 }  # 2016feb10: after noun, expect verb.
  if ($pos == 7) { $bias = 8 }  # 2016feb10: after pronoun, expect verb.
  if ($pos == 8) { $bias = 5 }  # 2016feb10: after verb, expect noun
  if ($prepcon == 0) {  # 2017-09-13: if not handling a preposition...
    if ($pos == 5 || $pos == 7) {  # 2016mar21: expanding then-clause
      $tsj = ($t - 1);     # 2017-09-13: subject?
      if ($verbcon == 1) {  # 2017-09-13: if a verb has come in...
        if ($tio == 0) {$tdo = $tult}  # 2017-09-13: set once or twice
        if ($tio == 0) {$tio = $tult}  # 2017-09-13: set only once
        if ($tio > 0)  {  # 2017-09-13: if $tio previously set...
          $tdo = $tult;  # 2017-09-13: second noun sets time of dir.obj.
        }  # 2017-09-13: end of test to make 2nd noun the direct object.
        $tkb = $tdo;  # 2017-09-20: TEST
        my @k=split(',',$psy[$tvb]);  # 2017-09-13: expose flag-panel of verb
        $pre = $k[1];  # 2017-09-13: verb psi will be $pre of direct object
        @k=split(',',$psy[$tio]);  # 2017-09-13: expose flag-panel of indir.obj.
        $iob = $k[1];  # 2017-09-13: excerpt indirect-object concept for k[11]
        $psy[$tio]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6]," # 2017-09-13
        . "3,$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]";   # 2017-09-13: concatenate
        # 2017-09-13: Above lines insert k7 dba=3 for dative-case indirect object. 
        @k=split(',',$psy[$tdo]);  # 2017-09-13: expose flag-panel of dir.obj.
        $k[10] = $pre; # 2017-09-25: TEST
        $psy[$tdo]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"  # 2017-09-13
        . "4,$k[8],$k[9],$k[10],$k[11],0,$k[13],$k[14]"; # 2017-09-20: no $tkb for dir.obj.
        # 2017-09-13: Above lines insert verb-$psi as k10 $pre of direct object. 
        @k=split(',',$psy[$tvb]);  # 2017-09-13: expose flag-panel of main verb.
        $tdo = $t - 1;  # 2017-09-13: insert time-of-direct-object for nounlock; 
        $tkb = $tdo;  # 2017-09-13: TEST
        # 2017-09-13: Next two lines create psy-array row for a verb. 
        $psy[$tvb]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"  # 2017-09-13
        . "$k[7],$k[8],$k[9],$k[10],$iob,$psi,$tkb,$k[14]";      # 2017-09-13
#       . "$k[7],$k[8],$k[9],$k[10],$iob,$psi,$k[13],$k[14]";      # 2018-07-03: TEST
      }  # 2017-09-13: end of test for a condition following a verb.
    }  # 2017-09-13: end of test for noun not object of a preposition.
  }  # 2017-09-13: end of test for a non-prepositional condition.
  if ($pos == 6) { $prepcon = 1; $tpp = $tult }  # 2017-09-13: prepare for noun.
  if ($pos == 5 || $pos == 7) {  # 2017-09-13: 
    if ($prepcon == 1) {  # 2017-09-13: 
      my @k=split(',',$psy[$tpp]);  # 2017-09-13: expose flag-panel of preposition;
      $pre = $k[1];  # 2017-09-13: Let $pre briefly be the preposition.
      $psy[$tpp]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"  # 2017-09-13
      . "$k[7],$k[8],$k[9],$k[10],$k[11],$psi,$k[13],$k[14]";  # 2017-06-08
      @k=split(',',$psy[$tult]);  # 2017-09-13: expose flag-panel of obj of prep.
      $psy[$tult]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"  # 2017-09-13
      . "4,$k[8],$k[9],$pre,$k[11],0,$k[13],$k[14]";            # 2017-09-13
      $prepcon = 0;  # 2017-09-13: Reset to prevent carry-over. 
    }  # 2017-09-13: end of test for a positive $prepcon.
  }  # 2017-09-13: end of test for a noun or pronoun.
  if ($pos == 8 && $psi != 830) {  # 2017-09-13: if verb other than "DO"
    $tvb = ($t - 1);  # 2017-09-13: hold onto time-of-verb for flag-insertions.
    $verbcon = 1;  # 2017-09-13: verb-condition is "on" for ind. & dir. objects.
    my @k=split(',',$psy[$tsj]);  # 2017-09-13: expose flag-panel of subject noun
    $subjpre = $k[1];  # 2017-09-13: Hold onto $subjpre for the pos=8 verb
    $psy[$tsj]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"  # 2017-09-13
    . "1,$k[8],$k[9],$k[10],$k[11],$psi,$tvb,$k[14]";        # 2017-09-13
    @k=split(',',$psy[$tult]);  # 2017-09-13: expose flag-panel of verb.
    $psy[$tult]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"  # 2017-09-13
    . "$k[7],$k[8],$k[9],$subjpre,$k[11],0,$k[13],$k[14]";    # 2017-09-13
    $subjpre = 0;  # 2017-09-13: Reset for safety. 
  }  # 2017-09-13: end of test for a pos=8 verb.
  InStantiate(); # 2017-09-13: for creating @psi concept-nodes
}  # 2017-09-13: EnParser() returns to OldConcept() or NewConcept().


5. Troubleshooting and Robotic Psychosurgery

5.1.a. Symptom: (Something goes wrong.)
5.1.b. Solution: (AI Mind Maintainer devises solution.)

To debug the function of assigning indirect and direct objects, the AI Mind Maintainer enters a typical sentence such as "I give the boy a robot" that contains both an indirect object and a direct object, and presses Escape to halt the AI after the input. Then the Maintainer examines the display of the conceptual array to see if $iob and $seq have been properly assigned. The AI coder may also insert diagnostic "print" messages into InStantiate() and EnArticle() so as to observe the process of assigning a tag during the input and comprehension of a sentence.


6. Variables for First Working Artificial General Intelligence

$bias -- EnParser(); NewConcept(): expected part-of-speech POS


7. Future Development


8. Resources


9. AiTree of First Working AGI Mind-Modules


Return to top; or to
javascript subreddit for AI Mind discussion;
Forth subreddit for MindForth discussion;
Perl subreddit for ghost.pl AI Mind Maintainers.