/
ghost.pl
5823 lines (5355 loc) · 328 KB
/
ghost.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/perl
use strict; # PERL by Example (2015) p. 77
use warnings; # PERL by Example (2015) p. 85
# use Encode; # 2016feb16: http://perldoc.perl.org/perlunitut.html
# use utf8; # 2016feb16: for Cyrillic Russian characters
# use feature "unicode_strings"; # 2016feb16: Perl_Programming/Unicode_UTF-8
# binmode STDIN, ":encoding(UTF-8)"; # 2016feb16
# ghost175.pl being coded on Sun.10.JUL.2016 or later
# Please host the Ghost Perl AI and install it for other persons.
# http://doc.perl6.org/language/variables
# http://ai.neocities.org/var.html -- Table of Variables in Perl AI
our $. = 0; # 2016jan14: line counter variable; PbyX 299
our $_ = " "; # 2016jan10: hidden variable; P_by_Ex p. 301
our $abc = ""; # AudBuffer() transfer character;
our $act = 0; # 2016jan16: quasi-neuronal activation-level
our $actpsi = 0; # 2016apr11: psi from which activation is to be spread
our $age = 0; # 2015apr26: Temporary age for loop-counting.
our $aud = " "; # 2016jan28: explicit package from @ear array
our $audbase = 0; # 2016jan27: recall-vector for VerbGen()
our $audbeg = 0; # 2016jan17: auditory-beginning tag for start of word.
our $audjuste = 0; # 2016feb12: NounPhrase motjuste aud to Speech() module
our $audnew = 0; # 2016jan17: holds onset-tag while rest of word comes in.
our $audpsi = 0; # 2016feb12: concept number of word in @ear array
our $audrec = 0; # 2016jan23: auditory recognition concept-number
our $audrv = 0; # 2016feb12: auditory recall-vector for Speech()
our $audrun = 1; # 2016jan26: counter of loops through AudRecog()
our $auxverb = 0; # 2016jun16: such as 800=BE; 830=DO; or modal verb;
our $b01 = ""; # 2016apr02: for OutBuffer();
our $b02 = ""; # 2016apr02: for OutBuffer();
our $b03 = ""; # 2016apr02: for OutBuffer();
our $b04 = ""; # 2016apr02: for OutBuffer();
our $b05 = ""; # 2016apr02: for OutBuffer();
our $b06 = ""; # 2016apr02: for OutBuffer();
our $b07 = ""; # 2016apr02: for OutBuffer();
our $b08 = ""; # 2016apr02: for OutBuffer();
our $b09 = ""; # 2016apr02: for OutBuffer();
our $b10 = ""; # 2016apr02: for OutBuffer();
our $b11 = ""; # 2016apr02: for OutBuffer();
our $b12 = ""; # 2016apr02: for OutBuffer();
our $b13 = ""; # 2016apr02: for OutBuffer();
our $b14 = ""; # 2016apr02: for OutBuffer();
our $b15 = ""; # 2016apr02: for OutBuffer();
our $b16 = ""; # 2016may21: http://ai.neocities.org/var.html#b16
our $beep = 0; # 2016apr29: flag for Motorium() to create a beep.
our $bias = 5; # 2016feb10: EnParser; NewConcept: expected POS
our $birth = localtime($^T); #2016apr21: PERL Black Book p. 444
our $c01 = ""; # 2016may21: http://ai.neocities.org/var.html#c01
our $c02 = ""; # 2016apr02: for AudBuffer();
our $c03 = ""; # 2016apr02: for AudBuffer();
our $c04 = ""; # 2016apr02: for AudBuffer();
our $c05 = ""; # 2016apr02: for AudBuffer();
our $c06 = ""; # 2016apr02: for AudBuffer();
our $c07 = ""; # 2016apr02: for AudBuffer();
our $c08 = ""; # 2016apr02: for AudBuffer();
our $c09 = ""; # 2016apr02: for AudBuffer();
our $c10 = ""; # 2016apr02: for AudBuffer();
our $c11 = ""; # 2016apr02: for AudBuffer();
our $c12 = ""; # 2016apr02: for AudBuffer();
our $c13 = ""; # 2016apr02: for AudBuffer();
our $c14 = ""; # 2016apr02: for AudBuffer();
our $c15 = ""; # 2016apr02: for AudBuffer();
our $c16 = ""; # 2016apr02: for AudBuffer();
our $c17 = ""; # 2016apr03: for AudBuffer() space
our $chaincon = 0; # 2016apr15: chain-of-thought condition-flag
our $char = " "; # 2016jan12: For use with getc in FileInput()
our $cns = 4096; # 2016apr19: size of central nervous system
our $coda = 64; # 2016apr19: memory recycled in ReJuvenate()
our $dba = 0; # 2016jan16: doing-business-as noun-case or verb-person
our $defact = 0; # 2015apr06: default activation for NounPhrase()
our $defcon = 5; # 2016jan21: defense condition
our $dirobj = 0; # 2016mar29: flag indicates seeking for a direct object
our $eot = 0; # 2016feb01: end-of-transmission for end of input
our $eureka = " "; # 2016feb23: something "found" in the aud-recog modules
our $fyi = 2; # 2016feb08: 2 = Tutorial mode; 3 = Diagnostic mode
our $gencon = 0; # 2016apr02: status-con flag when calling VerbGen()
our $hlc = "en"; # 2016jan22: human-language code; 1=en; 2=de; 3=ru.
our $idea = " "; # 2016apr09: for re-entry of AI thought back into the AI.
our $inhibcon = 0; # 2016apr17: flag for neural inhibition
our $iob = 0; # 2016mar26: indirect-object tag for @psy concept array
our $jrt = 0; # 2016apr18: ReJuvenate() "junior time" for memories moved
our $jux = 0; # 2016jan20: jux(taposed) concept in @psy array.
our $k = 0; # 2016mar15: k(knowledge) element from @psy concept array
our $krt = 0; # 2015may10: knowledge representation time
our $len = 0; # 2016jan27: length, for avoiding input non-words
our $mfn = 0; # 2016jan16: masculine-feminine-neuter gender flag.
our $midway = 0; # 2016jan23: limit for searching backwards in memory
our $mjact = 0; # 2016jun18: motjuste-activation for defaulting to 701=I
our $monopsi = 0; # 2016jan27: For use in AudRecog() module
our $morphpsi = 0; # 2016jan27: "for audRecog recognition of morphemes"
our $motjuste = 0; # 2016feb12: "best word for inclusion in a thought"
our $msg = " "; # 2015may01: $msg is for "message" of input.
our $num = 0; # 2016jan16: number-flag for grammatical number.
our $node = 0; # 2016jan27: "split" @psy array row into nodes
our $nounlock = 0; # 2016apr07: for a verb to lock onto a seq-noun
our $nphrnum = 0; # 2016apr02: grammatical number of noun-phrase
our $nphrpos = 0; # 2016apr07: for testing during EnThink() process
our $nxr = " "; # 2016jan26: for AudRecog dealing with next memory row
our $nxt = 0; # 2016feb03: number incremented for each new concept
our $oldpsi = 0; # 2016jan30: used in OldConcept to de-globalize "psi"
our $onset = 0; # 2016jan16: onset-tag for use as recall-vector.
our $output = " "; # 2016feb17: output string as in JavaScript AiMind.html
our $pho = ""; # $pho is for a "phoneme" or character of input.
our $phodex = 0; # 2016apr02: pho-index for AudBuffer()
our $pos = "5"; # 1=adj 2=adv 3=conj 4=interj 5=noun 6=prep 7=pron 8=verb
our $pov = 1; # 2016mar27: point-of-view: 1=self; 2=dual; 3=alien.
our $prc = 0; # 2016jan26: provisional recognition in AudRecog()
our $prclen = 0; # 2016JUL01: lenth of stem when $prc is declared.
our $pre = 0; # 2016jan20: pre(vious) associated @psy concept.
our $prejux = 0; # 2016jun17: previous $jux to carry NOT to verb
our $prepcon = 0; # 2016mar19: prepositional condition-flag for parsing.
our $prepgen = 0; # 2016mar30: urgency to generate a prepositional phrase.
our $prevtag = 0; # 2016jun18: may need to be global for InStantiate()?
our $prsn = 0; # 2016apr02: 1st, 2nd, 3rd person of verb-forms.
our $psi = 1; # 2016jan19: variable for elements of @psy array
our $psibase = 0; # 2016jan27: "winning psibase with winning actbase"
our $quapsi = 0; # 2016jun19: last input concept by which call to SpreadAct()
our $recnum = 0; # 2016jan27: "recognized number of a recognized word"
our $rjc = 0; # 2016apr18: counter of rejuvenation cycles
our $rv = 0; # 2016jan22: recall-vector for auditory memory.
our $seq = 0; # 2016jan20: subSEQuent @psy concept in an idea.
our $seqneed = 0; # 2016mar03: noun/pronoun or verb needed as a "seq"; 2016mar03
our $seqpsi = 0; # 2016apr11: concept to which activation should be spread.
our $snu = 0; # 2016apr02: subject-number as parameter for verb-selection.
our $spt = 0; # 2016jan23: blank space time before start of a word
our $stemgap = 0; # 2016jan27: "for avoiding false audRecog stems"
our $subject = 0; # 2016mar18: subject for parser module
our $subjectflag = 0; # 2016mar29: initial default for NounPhrase
our $subjnum = 0; # 2016apr07: for agreement with predicate nominative;
our $subjpre = 0; # 2016mar19: subject-$pre to be held for verb in parsing.
our $subjpsi = 0; # 2016apr02: parameter to govern person of verb-forms
our $sublen = 0; # 2016jan27: "length of audRecog subpsi word-stem"
our $subpsi = 0; # 2016jan27: "for AudRecog of sub-component wordstems"
our $t = 0; # 2015may02: Lifetime experiential time "$t"
our $t2s = 0; # 2015apr26: auditory text-to-speech index
our $tai = 0; # 2016apr14: time of artificial intelligence diagnostics
our $tdo = 0; # 2016mar21: time-of-direct-object for a parser module.
our $tio = 0; # 2016mar21: time-of-indirect-object for parser module.
our $tkb = 0; # 2016jan20: time-in-knowledge-base of an idea.
our $topic = 0; # 2016apr07: @psy topic for a question to be asked
our $tpp = 0; # 2016mar19: time-of-preposition for parsing.
our $trigger = 0; # 2016apr29: a trigger for Volition() to call Motorium()
our $tsj = 0; # 2016mar18: time-of-subject for parsing.
our $tseln = 0; # 2016mar29: time of selection of noun.
our $tselv = 0; # 2016apr13: time of selection of verb (for neural inhibition)
our $tsn = 0; # 2016mar15: time of input as $seqneed time for InStantiate()
our $tult = 0; # 2016jan18: t penultimate, or time-minus-one
our $tvb = 0; # 2016mar21: time-of-verb for parsing
our $unk = " "; # 2016feb20: all-putpose $unk for troubeshooting
our $utf8char = " "; # 2016feb16: wiki/Perl_Programming/Unicode_UTF-8
our $vault = 2425; # 2016may23: size of MindBoot() sequence in time-points.
our $verbcon = 0; # 2016mar21: verb-condition for seeking (in)direct objects.
our $verblock = 0; # 2016apr07: for subject-noun to lock onto seq-verb;
our $verbpsi = 0; # 2016apr07: $psi concept-number of verb in the @psy array
our $vphraud = 0; # 2016apr02: holds aud-fetch of verb-form for Speech() module
our $vrsn="ghost175"; # 2016JUL10: version identifier for sake of minddata.txt log.
our @ear = " "; # 2016jan28: new name for auditory memory array.
our @psy = " "; # 2016jan19: conceptual array renamed as @psy
sub AudBuffer; # 2016mar26: for transfer of words to OutBuffer().
sub AudInput; # 2016mar26: auditory input module for keyboard input.
sub AudMem; # 2016mar26: auditory memory module for storing engrams.
sub AudRecog; # 2016jan23 auditory recognition module.
sub DeThink; # 2016jan24: Selected dynamically by $hlc flag.
sub Emotion; # 2016mar26: for stub of physiological emotion.
sub EnNounPhrase; # 2016feb18: for thinking with nouns and pronouns.
sub EnThink; # 2016jan24: Selected dynamically by $hlc flag.
sub EnVerbPhrase; # 2016feb17: for verbs to be used in a thought.
sub FileInput; # 2016jan10 PbEx5e p. 351: Forward declaration.
sub InStantiate; # 2016jan19 PbEx5e p. 351: Forward declaration.
sub KbLoad; # 2016jan22 PbEx5e p. 351: Forward declaration.
sub MindBoot; # 2016jan23 PbEx5e p. 351: Forward declaration.
sub motorium; # 2015apr25 PbEx5e p. 351: Forward declaration.
sub NewConcept; # 2015may28 PbEx5e p. 351: Forward declaration.
sub NounPhrase; # 2016feb11: for nouns and pronouns in a thought.
sub OldConcept; # 2016jan14 PbEx5e p. 351: Forward declaration.
sub RuThink; # 2016jan24: Selected dynamically by $hlc flag.
sub Sensorium; # 2016mar26: sensory input module
sub TabulaRasa; # 2016jan25: Called from MainLoop as in MindForth
sub VisRecog; # 2015apr26 PbEx5e p. 351: Forward declaration.
sub volition; # 2015apr24 PbEx5e p. 351: Forward declaration.
sub TabulaRasa() { # 2016jan25: Establish size and emptiness of CNS.
print "Size of AI memory is $cns human language code = $hlc \n"; #2016feb16
my $trc = 0; # 2015apr2015 $trc is "tabula rasa counter".
until ($trc == $cns) { # 2015apr26 PbEx5e p. 193 "Loops".
$psy[$trc] = "0,0,0,0,0,0,0,0,0,0,0,0,0"; # 2016mar26: adding $iob.
$ear[$trc] = " ,0,0"; # 2016jan28: initialize three columns.
$trc++; # 2015apr26: Increment tabula-rasa-counter $trc.
} # End of loop filling auditory memory with blank engrams.
} # 2016feb11: End of TabulaRasa "clean slate" sequence.
sub PsiDecay() { # 2016apr13: let conceptual activations dwindle
print " PsiDecay() moves conceptual activations towards zero. \n"; # 2016JUL04
for (my $i=$t; $i>$midway; $i--) { # 2016apr13: move backwards in time.
my @k=split(',',$psy[$i]); # 2016apr13: inspect @psy flag-panel
if ($k[1] > 2) { $k[1] = ($k[1] - 2) } # 2016may01: approach zero.
# if ($k[1] < 0) { $k[1] = ($k[1] + 1) } # 2016may02: reduce inhibition.
if ($k[1] < 0) { $k[1] = ($k[1] + 2) } # 2016JUL04: rapid recovery.
$psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],$k[7],$k[8],$k[9],$k[10],$k[11],$k[12]";
} # 2016apr13: End of (for loop) moving backwards in time
} # 2016apr13: PsiDecay() returns to EnThink()...
sub AudDamp() { # 2016feb03: "deactivate auditory engrams"
for (my $i=$midway; $i<$cns; $i++) { # 2016feb03:
my @aud=split(',',$ear[$i]); # 2016feb03: Examine the @ear array.
$ear[$i] = "$aud[0],0,$aud[2]"; # 2016feb03: Reset act to zero.
} # 2016feb03: end of forwards sweep through auditory memory.
} # 2016feb03: End of AudDamp(0; return to input module.
# $act 33-48 = consciousness tier where concepts win selection.
# $act 17-32 = subconscious where concepts remain available.
# $act 1-16 = noise tier below logical association threshold.
sub SpreadAct() { # 2016apr11: spread activation from concept to concept.
print "\nSpreadAct() has been called to spread conceptual activation.\n"; #2016apr29
print " SprA: krt= $krt quapsi= $quapsi actpsi= $actpsi \n"; #2016jun19
PsiDecay(); # 2016may01: reduce conceptual activation in general.
if ($actpsi > 0) { # 2016apr11: if there is an actpsi concept...
for (my $i=$t; $i>$midway; $i--) { # 2016apr12: search backwards in time.
my @k=split(',',$psy[$i]); # 2016apr11: inspect @psy flag-panel
if ($k[0] == $actpsi && $k[8] > 0) { $seqpsi = $k[8] } #2016apr12: if seq, seqpsi
if ($k[0] == $actpsi && $k[7] > 0) { # 2016apr29: require verblock.
print " i= $i actpsi= $actpsi seqpsi= $seqpsi \n"; #2016apr29
$k[1] = ($k[1] + 32); # 2016jun28: impose less than half of subj-inhibition.
print " SprAct-mid: for $k[0] setting $k[1] activation \n"; # 2016jun19
$psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],$k[7],$k[8],$k[9],$k[10],$k[11],$k[12]";
} # 2016apr12: end of diagnostic test
} # 2016apr11: end of (for loop) searching for actpsi concept.
} # 2016apr11: end of test for a positive $actpsi.
print " SpreadAct-end : t= $t actpsi= $actpsi seqpsi= $seqpsi \n"; # 2016apr29
$actpsi = 0; # 2016apr12: reset for safety.
} # 2016jun30: SpreadAct() returns to ReEntry().
sub KbLoad() { # 2016jan23: load MindBoot knowledge-base bootstrap.
if ($fyi > 2) { # 2016feb08: if mode is Diagnostic
print "KbLoad stores MindBoot knowledge-base, t= $t. \n"; # 2016jan23
} # 2016feb07: end of test for Diagnostic or Tutorial mode.
$psy[$t] = "$psi,$act,$hlc,$pos,$jux,$pre,$iob,$tkb,$seq,$num,$mfn,$dba,$rv";
} # 2016jan23: End of KbLoad; return to MindBoot knowledge bootstrap.
sub OutBuffer() { # 2016apr02: right-justifies a word in memory.
$b01=""; $b02=""; $b03=""; $b04=""; $b05=""; $b06=""; # 2016apr02
$b07=""; $b08=""; $b09=""; $b10=""; $b11=""; $b12=""; # 2016apr02
$b13=""; $b14=""; $b15=""; $b16=""; # 2016apr02: clear tabula rasa;
if ($c16 ne "") { # 2016apr03: if the AudBuffer is full;
$b16=$c16; $b15=$c15; $b14=$c14; $b13=$c13; # 2016apr02
$b12=$c12; $b11=$c11; $b10=$c10; $b09=$c09; # 2016apr02
$b08=$c08; $b07=$c07; $b06=$c06; $b05=$c05; # 2016apr02
$b04=$c04; $b03=$c03; $b02=$c02; $b01=$c01; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 16-character word;
if ($c15 ne "") { # 2016apr03: if the word is only 15 characters
$b16=$c15; $b15=$c14; $b14=$c13; $b13=$c12; $b12=$c11; $b11=$c10;
$b10=$c09; $b09=$c08; $b08=$c07; $b07=$c06; $b06=$c05; $b05=$c04;
$b04=$c03; $b03=$c02; $b02=$c01; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 15-character word;
if ($c14 ne "") { # 2016apr03: if the word is only 14 characters
$b16=$c14; $b15=$c13; $b14=$c12; $b13=$c11; $b12=$c10; $b11=$c09;
$b10=$c08; $b09=$c07; $b08=$c06; $b07=$c05; $b06=$c04; $b05=$c03;
$b04=$c02; $b03=$c01; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 14-character word;
if ($c13 ne "") { # 2016apr03: if the word is only 13 characters
$b16=$c13; $b15=$c12; $b14=$c11; $b13=$c10; $b12=$c09; $b11=$c08;
$b10=$c07; $b09=$c06; $b08=$c05; $b07=$c04; $b06=$c03; $b05=$c02;
$b04=$c01; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 13-character word;
if ($c12 ne "") { # 2016apr03: if the word is only 12 characters
$b16=$c12; $b15=$c11; $b14=$c10; $b13=$c09; $b12=$c08; $b11=$c07;
$b10=$c06; $b09=$c05; $b08=$c04; $b07=$c03; $b06=$c02; $b05=$c01;
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 12-character word;
if ($c11 ne "") { # 2016apr03: if the word is only 11 characters
$b16=$c11; $b15=$c10; $b14=$c09; $b13=$c08; $b12=$c07; $b11=$c06;
$b10=$c05; $b09=$c04; $b08=$c03; $b07=$c02; $b06=$c01; $b05="";
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of an 11-character word;
if ($c10 ne "") { # 2016apr03: if the word is only 10 characters
$b16=$c10; $b15=$c09; $b14=$c08; $b13=$c07; $b12=$c06; $b11=$c05;
$b10=$c04; $b09=$c03; $b08=$c02; $b07=$c01; $b06=""; $b05="";
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 10-character word;
if ($c09 ne "") { # 2016apr03: if the word is only 9 characters
$b16=$c09; $b15=$c08; $b14=$c07; $b13=$c06; $b12=$c05; $b11=$c04;
$b10=$c03; $b09=$c02; $b08=$c01; $b07=""; $b06=""; $b05="";
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 9-character word;
if ($c08 ne "") { # 2016apr03: if the word is only 8 characters
$b16=$c08; $b15=$c07; $b14=$c06; $b13=$c05; $b12=$c04; $b11=$c03;
$b10=$c02; $b09=$c01; $b08=""; $b07=""; $b06=""; $b05="";
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of an 8-character word;
if ($c07 ne "") { # 2016apr03: if the word is only 7 characters
$b16=$c07; $b15=$c06; $b14=$c05; $b13=$c04; $b12=$c03; $b11=$c02;
$b10=$c01; $b09=""; $b08=""; $b07=""; $b06=""; $b05="";
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 7-character word;
if ($c06 ne "") { # 2016apr03: if the word is only 6 characters
$b16=$c06; $b15=$c05; $b14=$c04; $b13=$c03; $b12=$c02; $b11=$c01;
$b10=""; $b09=""; $b08=""; $b07=""; $b06=""; $b05="";
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 6-character word;
if ($c05 ne "") { # 2016apr03: if the word is only 5 characters
$b16=$c05; $b15=$c04; $b14=$c03; $b13=$c02; $b12=$c01; $b11="";
$b10=""; $b09=""; $b08=""; $b07=""; $b06=""; $b05="";
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 5-character word;
if ($c04 ne "") { # 2016apr03: if the word is only 4 characters
$b16=$c04; $b15=$c03; $b14=$c02; $b13=$c01; $b12=""; $b11="";
$b10=""; $b09=""; $b08=""; $b07=""; $b06=""; $b05="";
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 4-character word;
if ($c03 ne "") { # 2016apr03: if the word is only 3 characters
$b16=$c03; $b15=$c02; $b14=$c01; $b13=""; $b12=""; $b11="";
$b10=""; $b09=""; $b08=""; $b07=""; $b06=""; $b05="";
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 3-character word;
if ($c02 ne "") { # 2016apr03: if the word is only 2 characters
$b16=$c02; $b15=$c01; $b14=""; $b13=""; $b12=""; $b11="";
$b10=""; $b09=""; $b08=""; $b07=""; $b06=""; $b05="";
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 2-character word;
if ($c01 ne "") { # 2016apr03: if the word is only 1 character
$b16=$c01; $b15=""; $b14=""; $b13=""; $b12=""; $b11="";
$b10=""; $b09=""; $b08=""; $b07=""; $b06=""; $b05="";
$b04=""; $b03=""; $b02=""; $b01=""; # 2016apr02
return; # 2016apr02: abandon remainder of function;
} # 2016apr02: end of transfer of a 1-character word;
} # 2016apr02: OutBuffer() returns to AudBuffer or VerbGen()
sub AudBuffer() { # 2016apr02: for transfer of words to OutBuffer()
if ($abc ne "") { $phodex++ } # 2016apr03: avoid blank space.
if ($phodex == 1) { # 2016apr02: Erase any left-over old data;
$c01 = $abc; $c02=""; $c03 = ""; $c04 =""; # 2016apr02
$c05 = ""; $c06 = ""; $c07 = ""; $c08 = ""; # 2016apr02
$c09 = ""; $c10 = ""; $c11 = ""; $c12 = ""; # 2016apr02
$c13 = ""; $c14 = ""; $c15 = ""; $c16 = ""; # 2016apr02
} # 2016apr02: end of using $phodex=1 to blank out the AudBuffer()
if ($phodex == 2) { $c02 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 3) { $c03 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 4) { $c04 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 5) { $c05 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 6) { $c06 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 7) { $c07 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 8) { $c08 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 9) { $c09 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 10) { $c10 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 11) { $c11 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 12) { $c12 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 13) { $c13 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 14) { $c14 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 15) { $c15 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 16) { $c16 = $abc } # 2016apr02: AudBuffer Character
if ($phodex == 17) { $c17 = $abc } # 2016apr03: AudBuffer space
} # End of AudBuffer; return to AudInput or FileInput or VerbGen.
sub Parser() { # 2016mar17: enlarging the parser function.
# 2016mar17: OldConcept() shall have provided flag-panel data.
if ($prepcon == 0) { # 2016mar19: if not handling a preposition...
if ($pos == 5 || $pos == 7) { # 2016mar21: expanding then-clause
$tsj = $tult; # 2016mar19: subject?
if ($verbcon == 1) { # 2016mar21: if a verb has come in...
if ($tio > 0) { # 2016mar21: if $tio previously set...
$tdo = $tult; # 2016mar21: second noun sets time of dir.obj.
} # 2016mar21: end of test to make 2nd noun the direct object.
if ($tio == 0) {$tio = $tult} # 2016mar21: set only once
if ($tdo == 0) {$tdo = $tult} # 2016mar21: initial d.o. setting
my @k=split(',',$psy[$tvb]); # 2016mar21: expose flag-panel of verb
$pre = $k[0]; # 2016mar21: verb psi will be $pre of direct object
@k=split(',',$psy[$tio]); # 2016mar26: expose flag-panel of indir.obj.
$iob = $k[0]; # 2016mar27: excerpt indirect-object concept for k[6]
$psy[$tio]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],$k[7],$k[8],$k[9],$k[10],3,$k[12]";
# 2016mar23: Above line inserts dba=3 for dative-case indirect object.
@k=split(',',$psy[$tdo]); # 2016mar26: expose flag-panel of dir.obj.
$psy[$tdo]="$k[0],$k[1],$k[2],$k[3],$k[4],$pre,$k[6],$k[7],0,$k[9],$k[10],4,$k[12]";
# 2016mar21: Above line inserts verb-$psi as $pre of direct object.
@k=split(',',$psy[$tvb]); # 2016mar26: expose flag-panel of main verb.
$tdo = $tult; # 2016jun26: insert time-of-direct-object for nounlock;
$psy[$tvb]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$iob,$tdo,$psi,$k[9],$k[10],$k[11],$k[12]";
$iob = 0; # 2016mar27: reset indirect-object identifier for safety.
} # 2016mar21: end of test for a condition following a verb.
} # 2016mar21: end of test for noun not object of a preposition.
} # 2016mar21: end of test for a non-prepositional condition.
if ($pos == 6) { $prepcon = 1; $tpp = $tult } # 2016mar19: prepare for noun.
if ($pos == 5 || $pos == 7) { # 2016mar19:
print "\n PrsrSbj: tsj= $tsj tvb= $tvb tio= $tio iob= $iob tdo= $tdo \n"; #2016jun26
if ($prepcon == 1) { # 2016mar19:
my @k=split(',',$psy[$tpp]); # 2016mar19: expose flag-panel of preposition;
$pre = $k[0]; # 2016mar19: Let $pre briefly be the preposition.
$psy[$tpp]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],$k[7]$psi,$k[9],$k[10],$k[11],$k[12]";
print "ParserA: tult $tult psi= $psi pos= $pos tpp= $tpp prepcon= $prepcon \n"; # 2016mar
@k=split(',',$psy[$tult]); # 2016mar21: expose flag-panel of obj of prep.
$psy[$tult]="$k[0],$k[1],$k[2],$k[3],$k[4],$pre,$k[6],$k[7],0,$k[9],$k[10],4,$k[12]";
# 2016mar19: Line above for object sets prep as $pre; $seq as 0; $dba as 4.
print "ParserB: tult $tult psi= $psi pos= $pos tpp= $tpp prepcon= $prepcon \n"; # 2016mar19
print "ParserB: tult $tult psi= $psi tpp= $tpp verbcon= $verbcon \n"; # 2016mar21
$prepcon = 0; # 2016mar19: Reset to prevent carry-over.
} # 2016mar19: end of test for a positive $prepcon.
} # 2016mar19: end of test for a noun or pronoun.
# if ($pos == 8) { # 2016mar19: assign flags to both subject and verb.
if ($pos == 8 && $psi != 830) { # 2016jun17: if verb other than "DO"
$tvb = $tult; # 2016mar21: hold onto time-of-verb for flag-insertions.
$verbcon = 1; # 2016mar21: verb-condition is "on" for ind. & dir. objects.
print " Parser: t= $t tsj= $tsj psi= $psi pos= $pos prepcon= $prepcon \n"; # 2016mar19
my @k=split(',',$psy[$tsj]); # 2016mar19: expose flag-panel of subject noun
$subjpre = $k[0]; # 2016mar19: Hold onto $subjpre for the pos=8 verb
$psy[$tsj]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],$tvb,$psi,$k[9],$k[10],1,$k[12]";
$tsj = 0; # 2016mar23: Reset to zero after deployment for setting flags.
@k=split(',',$psy[$tult]); # 2016mar21: expose flag-panel of verb.
$psy[$tult]="$k[0],$k[1],$k[2],$k[3],$k[4],$subjpre,$k[6],$k[7],0,$k[9],$k[10],$k[11],$k[12]";
$subjpre = 0; # 2016mar19: Reset for safety.
} # 2016mar19: end of test for a pos=8 verb.
} # 2016mar17: End of Parser; return to InStantiate()
sub InStantiate() { # http://mind.sourceforge.net/instiate.html
$pre = $prevtag; # 2016jun18: re-globalize?
$prevtag = 0; # 2016mar12: Reset for safety.
if ($oldpsi == 701) { $pos = 7 } # 2016jun19: 7 = pronoun.
if ($fyi > 0) { # 2016feb10: TEST MODE
print "\nInStantiate() has been called by a parser module \n"; # 2016feb24
print " InSt: psi= $psi,act= $act,hlc= $hlc,pos= $pos,"; # 2016jun30: flags
print "jux= $jux,pre= $pre,\n"; # 2016jun30: @psy associative-tag flag-panel
print " InSt: iob=$iob,tkb=$tkb,seq=$seq,num=$num,mfn=$mfn,dba=$dba,rv=$rv\n";
} # 2016feb07: end of test for Diagnostic or Tutorial mode.
$act = 0; # 2016jun26: preparing to activate only older nodes of concepts.
print "InStantiate: pov= $pov pos= $pos psi= $psi \n"; # 2016jun26: TEST; REMOVE
if ($pov > 0) { # 2016JUL03: if the point-of-view does not matter; TEST
for (my $i=$t; $i>$midway; $i--) { # 2016jun26: search backwards in time.
my @k=split(',',$psy[$i]); # 2016jun26: inspect @psy flag-panel
if ($k[0] == $psi) { $k[1] = ($k[1] + 32) } #2016JUL04: impart activation.
if ($k[0] == $psi) { print "$k[1] @ $i " } #2016JUL03:
$psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],$k[7],$k[8],$k[9],$k[10],$k[11],$k[12]";
} # 2016jun26: end of (for loop) searching backwards in time.
} # 2016jun26: end of test for an external source of inputs.
$tult = $t - 1; # 2016feb10: penultimate time
$act = -48; # 2016JUL06: for a "trough" of recent-most inhibition.
# 2016mar26: $k[0]$k[1]$k[2]$k[3]$k[4]$k[5]$k[6]$k[7]$k[8]$k[9]$k[10]$k[11]$k[12]
$psy[$tult] = "$psi,$act,$hlc,$pos,$jux,$pre,$iob,$tkb,$seq,$num,$mfn,$dba,$rv";
if ($jux == 250) { $jux = 0 } # 2016jun17: Reset after use.
if ($prejux == 250) { # 2016jun17: 250=NOT from OldConcept()
$jux = 250; # 2016jun17: set $jux for next instantiand;
$prejux = 0; # 2016jun17: Reset for safety.
} # 2016jun17: end of post-instantiation test;
Parser(); # 2016mar17: building up the parser function.
if ($pos == 5 || $pos == 7) { $prevtag = $psi }; # 2016mar12: after subject
if ($pos == 8) { $prevtag = $psi }; # 2016mar12: after a verb.
if ($pos == 8 && $seqneed == 0) { $seq = $psi }; # 2016mar15: for the $seq of a subject
if ($pos == 5 || $pos == 7) { # 2016mar15: if noun or pronoun...
$seq = 0; # 2016mar15: until set by the $seqneed mechanism...
if ($seqneed == 0) { $seqneed = 8 } # 2016mar15: if start of input sentence...
if ($seqneed == 5) { $seqneed = 0 } # 2016mar15: for subject only
} # 2016mar15:
if ($pos == 5 || $pos == 7) { $actpsi = $psi } # 2016JUL10: for ReEntry() & SpreadAct()
if ($pos == 8) { $seqneed = 5 }; # 2016mar15: if verb, need direct object.
$pre = 0; # 2016mar12: Reset to prevent carry-over.
$act = 0; # 2016apr27: reset to prevent carry-over.
print " InSta-end: actpsi= $actpsi quapsi= $quapsi \n \n"; # 2016JUL10: TEST
} # http://code.google.com/p/mindforth/wiki/InStantiate
# 2015jun04 Requirements of EnParser English Parser module:
# EnParser shall at first assume that a new word is a noun.
# EnParser shall call InStantiate to complete the parsing process.
sub EnParser() { # http://mind.sourceforge.net/parser.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
print " EnParser has been called by NewConcept \n"; # 2016jan14
} # 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
InStantiate(); # 2016jan19: for creating @psi concept-nodes
} # 2016feb10: EnParser() returns to OldConcept() or NewConcept().
sub RuParser() { # http://mind.sourceforge.net/parser.html
$act = 48; # 2016apr28: an arbitrary activation for InStantiate()
$bias = 5; # 2016feb24: Expect a noun until overruled.
if ($fyi > 2) { # 2016feb24: if mode is Diagnostic
print " RuParser has been called by NewConcept \n"; # 2016jfeb24
} # 2016feb24: end of test for Diagnostic or Tutorial mode.
if ($pos == 5) { $bias = 8 } # 2016feb24: after noun, expect verb.
if ($pos == 7) { $bias = 8 } # 2016feb24: after pronoun, expect verb.
if ($pos == 8) { $bias = 5 } # 2016feb24: after verb, expect noun
print "RuParser: pos= $pos bias= $bias hlc= $hlc psi= $psi \n"; #2016feb24
InStantiate(); # 2016feb24: for creating @psi concept-nodes
} # 2016feb24: RuParser() returns to OldConcept() or NewConcept().
sub OldConcept() { # http://mind.sourceforge.net/oldcept.html
if ($fyi > 2) { # 2016feb08: if mode is Diagnostic
print "\nOldConcept() called by an input module.\n"; # 2016jan30
} # 2016feb07: end of test for Diagnostic or Tutorial mode.
for (my $i=$t; $i>$midway; $i--) { # 2016feb10: search backwards in time.
my @k=split(',',$psy[$i]); # 2016mar15: inspect @psy knowledge nodes
if ($k[0] == $oldpsi) { # 2016mar15: find most recent oldpsi engram
if ($k[2] ne 0) { $hlc = $k[2] } # 2016apr07: human-language code;
if ($k[3] > 0) { $pos = $k[3] } # 2016apr06: pos = part of speech;
if ($k[9] > 0) { $num = $k[9] } # 2016apr06: grammatical num(ber);
if ($k[10] > 0) { $mfn = $k[10] } # 2016apr06: m/f/n gender 1/2/3;
} # 2016feb10: end of test for $oldpsi match in @psy array
} # 2016mar13: End of (for loop) searching through @psy conceptual array.
if ($hlc eq "en") { # 2016feb10: test for governing human-language-code
if ($oldpsi == 250) { $prejux = 250 } # 2016jun17: a flag for negation.
$psi = $oldpsi; # 2016feb10: from MindForth.
if ($pov == 2) { # 2016mar27: during a pov "dual" conversation...
if ($oldpsi == 245) { $prepgen = 8 } # 2016mar30: if "Where?" call EnPrep()
if ($oldpsi == 707) { $psi = 701; $rv = 0 } # 2016mar27: interpret "YOU" as "I";
if ($oldpsi == 701) { $psi = 707; $rv = 0 } # 2016mar27: interpret "I" as "YOU".
if ($oldpsi == 731) { $psi=737; $num=2; $dba=1; $rv=0 } # 2016mar30: we --> you.
print "\nOldConcept: oldpsi= $oldpsi real psi= $psi \n"; # 2016apr30: TEST
} # 2016mar27: end of test for other person communicating with the AI.
EnParser(); # 2016feb10: In preparation to call InStantiate().
} # 2016feb10: end of test for English human-language-code
if ($hlc eq "ru") { # 2016feb24: test for governing human-language-code
$psi = $oldpsi; # 2016feb24: from MindForth.
if ($pov == 2) { # 2016apr01: during a pov "dual" conversation...
if ($oldpsi == 245) { $prepgen = 8 } # 2016apr01: if "Where?" call RuPrep()
if ($oldpsi == 707) { $psi = 701; $rv = 0 } # 2016apr01: interpret "YOU" as "I";
if ($oldpsi == 701) { $psi = 707; $rv = 0 } # 2016apr01: interpret "I" as "YOU".
if ($oldpsi == 731) { $psi=737; $num=2; $dba=1; $rv=0 } # 2016apr01: we --> you.
if ($oldpsi == 1707) { $psi=1701; $num=1; $dba=1; $rv = 0 } #2016apr01: ТЫ --> Я
if ($oldpsi == 1701) { $psi=1707; $num=1; $dba=1; $rv = 0 } #2016apr01: Я --> ТЫ
if ($oldpsi == 1731) { $psi=1737; $num=2; $dba=1; $rv=0 } #2016apr01: МЫ --> ВЫ
print "\nOldConcept: oldpsi= $oldpsi real psi= $psi \n"; # 2016apr30
} # 2016mar27: end of test for other person communicating with the AI.
RuParser(); # 2016feb24: In preparation to call InStantiate().
} # 2016feb24: end of test for Russian human-language-code
$audnew = 0; # 2016feb09: Reset for sake of $rv of next input word.
$oldpsi = 0; # 2016jan30: reset for safety.
} # http://code.google.com/p/mindforth/wiki/OldConcept
# 2015may28 Requirements of NewConcept mind-module:
# NewConcept shall create a concept in @psy for each new word encountered.
# A flag-panel shall lodge associative tags with each new @psy concept.
sub NewConcept() { # http://mind.sourceforge.net/newcept.html
print "\nNewConcept: nxt= $nxt len= $len \n"; # 2016mar08
$psi = $nxt; # 2016jan22: For xfer to InStantiate().
if ($fyi > 2) { # 2016feb08: if mode is Diagnostic
print " NewC hlc= $hlc calls InStantiate for psi $psi len $len \n"; # 2016feb12
} # 2016feb07: end of test for Diagnostic or Tutorial mode.
$pos = $bias; # 2016feb10: InStantiate() stores value from EnParser().
# if ($hlc eq "de") { # 2016jan22: test for governing human-language-code
# DeParser(); # 2016jan22: In preparation to call InStantiate().
# } # 2016feb19: http://de.perl6intro.com
if ($hlc eq "en") { # 2016jan22: test for governing human-language-code
EnParser(); # 2015jun04: In preparation to call InStantiate().
} # 2016jan22: end of test for English human-language-code
if ($hlc eq "ru") { # 2016feb24: test for governing human-language-code
RuParser(); # 2016feb24: In preparation to call InStantiate().
} # 2016feb24: end of test for Russian human-language-code.
if ($fyi > 2) { # 2016feb08: if mode is Diagnostic
print "NewConcept-late: nxt= $nxt len= $len \n"; # 2016feb03:
} # 2016feb07: end of test for Diagnostic or Tutorial mode.
if ($len > 0) { # 2016jan30: do not count spurious new concepts
$nxt++; # 2016jan22: Increment for each new human word/concept.
if ($fyi > 2) { # 2016feb08: if mode is Diagnostic
print "NewConcept increments nxt counter to $nxt \n"; # 2016feb02
} # 2016feb07: end of test for Diagnostic or Tutorial mode.
} # 2016jan30: end of test for new concepts with positive length.
$audnew = 0; # 2016feb09: Reset for sake of $rv of next input word.
$audpsi = 0; # 2016feb03: reset to prevent carry-overs.
} # 2016feb10: NewConcept() returns to AudInput() or FileInput().
sub AudRecog() { # http://code.google.com/p/mindforth/wiki/AudRecog
$audrec = 0; # 2016jan23: prevent carry-over of previous value.
$psi = 0; # 2016jan23: prevent carry-over of previous value.
$act = 8; # 2016jan30: as in Mindforth, start with a hefty value.
my $actbase = 0; # 2016may22: trying to de-globalize the variable.
for (my $i=$spt; $i>$midway; $i--) { # 2016feb07: search backwards in time.
my @aud=split(',',$ear[$i]); # 2016jan28: @ear is new array-name
if ($pho ne $aud[0]) { $ear[$i] = "$aud[0],0,$aud[2]" } #2016apr22: de-activate
if ($pho eq $aud[0]) { # 2016jan29: If incoming pho matches stored aud0;
if ($aud[1]==0) { # 2016jan28: if matching engram has no activation;
my @prv=split(',',$ear[$i-1]); # 2016mar14: "@prv" for "previous" row.
if ($prv[0] !~ /[A-Z]/) { # 2016feb3: "if beg=1 on matching no-act aud engram"
if ($audrun < 2) { # 2016jan27: "if comparing start of a word"
my @nxr=split(',',$ear[($i+1)]); # 2016jan28: for next-in-line char
if ($nxr[0] =~ /[A-Z]/) { # 2016jan27: pattern binding operator
$ear[$i+1] = "$nxr[0],8,$nxr[2]"; # 2016feb3: "activate N-I-L character"
$audrec = 0; # 2016jan27: from MindForth AI
} # 2016jan27: "end of test for continuation of beg-aud"
my @aud=split(',',$ear[($i)]); # 2016jan31: for current char
if ($aud[2] > 0) { # 2016jan31: if concept number present
$monopsi = $aud[2]; # 2016feb06: hold onto potential monopsi
$prc = $aud[2]; # 2016mar08: provisional recognition; TEST
if (($len - $prclen) > 2) { $prc = 0 } # 2016JUL01: word too long
} # 2016feb06: end of test for potential monopsi ultimate-tag
} # 2016jan27: Mindforth "end of test for audrun=1 start of word"
} # 2016jan24: "end of test for a beg(inning) non-active aud0"
} # 2016jan27: "end of test for matching aud0 with no activation"
my @aud=split(',',$ear[$i]); # 2016JUL01: break apart @ear auditory array.
if ($aud[1] > 0) { # 2016jan28: "If matching aud0 has activation"
if ($aud[2] > 0) { # 2016mar08: check for an audpsi tag
$prc = $aud[2]; # 2016mar08: provisional recognition of a stem
$prclen = $len; # 2016JUL01: length at time of provisional recognition
} # 2016mar08: end of test for available audpsi
$audrec = 0; # 2016jan27: "Zero out any previous audrec."
my @nxr=split(',',$ear[($i+1)]); # 2016jan27: for next-in-line char
if ($nxr[0] =~ /[A-Z]/) { # 2016jan27: pattern binding operator
$act = ($act + 2); # 2016jan27: Increment $act for discrimination.
$audrec = 0; # 2016jan27: "because match-up is not complete"
$ear[$i+1] = "$nxr[0],$act,$nxr[2]"; # "Increment for discrimination."
} # 2016jan27: "end of test for active-match aud0 continuation"
@nxr=split(',',$ear[($i+1)]); # 2016jan28: for next-in-line char
if ($nxr[0] !~ /[A-Z]/) { # 2016jan27: If ctu=0 indicates end of word
if ($len == 2) { # 2016jan27: "If len(gth) is only two characters."
my @aud=split(',',$ear[$i]); # Expose values of @ear row #i
if ($aud[1] > 7) { # 2016jan28: "testing for eight (8)"
$psibase = $aud[2]; # 2016jan28 MindForth: "Assume a match."
} # 2016jan27 MindForth: "End of test for act=8 or positive."
} # 2016jan27 MindForth: "End of test for two-letter words."
} # 2016jan27 MindForth: "End of test in AudRecog for end of word."
my @aud=split(',',$ear[$i]); # Expose values of @ear row #i
if ($aud[1] > 8) { # 2016jan28: "If activation higher than initial
$actbase = 8; # 2016jan27 Mindforth: "Since act is > 8 anyway;"
my @nxr=split(',',$ear[($i+1)]); # 2016jan27: for next-in-line char
if ($nxr[0] !~ /[A-Z]/) { # 2016jan27: If matching word-engram ends
if ($aud[1] > $actbase) { # 2016feb03: "Testing for high act."
$audrec = $aud[2]; # 2016jan28: "Fetch the potential tag"
$subpsi = $aud[2]; # 2016jan28: "Seize a potential stem."
$sublen = $len; # 2016jan27: "Hold length of word-stem."
$psibase = $aud[2]; # 2016jan28: "Hold onto winner."
my @k=split(',',$psy[$i]); # 2016mar15: "k" for knowledge
$recnum = $k[9]; # 2016mar26: recognized grammatical number
if ($k[11] > 0) { $dba = $k[11] } # 2016jun24
$actbase = $aud[1]; # 2016jan28: "Winner is new actbase."
} else { # 2016jan27: "End of test for act higher than actbase."
$audrec = 0; # 2016jan27: no word has been recognized
} # 2016jan27: End of else-clause
} # 2016jan27: "End of test for final char that has a psi-tag."
} # 2016jan27: "End of test for engram-activation above eight."
} # 2016jan27: "End of test for matching aud0 with activation."
@aud=split(',',$ear[$i]); # 2016jun30:
} # 2016jan27: "End of test for a character matching 'pho'."
} # 2016feb07: End of backwards search through auditory memory.
if (($len - $prclen) > 2) { $prc = 0 } # 2016JUL01: abandon prc if word too long
$audrun++; # 2016jan27: audrun is only a counter, not a factor.
$act = 0; # 2016jan27:
$actbase = 0; # 2016jan27:
if ($psibase > 0) { $audrec = $psibase } # 2016jan27:
if ($audrec == 0) { # 2016feb06: correction, to what MindForth does here.
if ($monopsi > 0) { # 2016jan27:
if ($len < 2) { # 2016jan27:
$audrec = $monopsi; # 2016jan27: recognize one-letter word.
print " AudRec: t= $t finding one-letter audrec= $audrec \n"; #2016feb24
} # 2016jan27: end of test for word-length less than two
} # 2016jan27: end of test for presence of a found monopsi
} # 2016jan27: end of test for a found auditory recognition.
if ($audrec == 0 && $prc > 0) { # 2016jan27
$audrec = $prc; # 2016jan27: from Dushka RuAi; prov. recog;
} # 2016jan27
if ($audrec == 0) { # 2016jan27:
$audrec = $morphpsi; # 2016jan27:
if ($sublen > 0) { # 2016jan27:
$stemgap = ($len - $sublen); # 2016jan27
} # 2016jan27:
if ($stemgap < 0) { $stemgap = 0 } # 2016jan27
if ($stemgap > 1) { $subpsi = 0 } # 2016jan27
if ($stemgap > 1) { $morphpsi = 0 } # 2016jan27
if ($stemgap > 1) { $audrec = 0 } # 2016jan27
} # 2016jan27:
$psibase = 0; # 2016jan27
$subpsi = 0; # 2016jan27
if ($audrec > 0) { # 2016jan27
if ($stemgap > 2) { # 2016jan27
$audrec = 0; # 2016jan27
} # 2016jan27
} # 2016jan27
$audpsi = $audrec; # 2016jan27
$audrec = 0; # 2016jan27: temporary safety precaution after xfer.
$stemgap = 0; # 2016jan27: safety measure
} # End of AudRecog(); return to AudMem(); 2016jan26
sub RuAudRecog() { # http://code.google.com/p/mindforth/wiki/AudRecog
$audrec = 0; # 2016feb20: prevent carry-over of previous value.
$psi = 0; # 2016feb20: prevent carry-over of previous value.
$act = 8; # 2016feb20: as in Mindforth, start with a hefty value.
my $actbase = 0; # 2016may22: de-globalize here and in English AudRecog().
for (my $i=$spt; $i>$midway; $i--) { # 2016feb20: search backwards in time.
my @aud=split(',',$ear[$i]); # 2016feb20: @ear is the auditory array
if ($pho ne $aud[0]) { $ear[$i] = "$aud[0],0,$aud[2]" } #2016apr05: de-activate
if ($pho eq $aud[0]) { # 2016feb20: If incoming pho matches stored aud0;
if ($audrun == 1) { # 2016apr05: at start of an input word...
my @prv=split(',',$ear[$i-1]); # 2016apr05: "@prv" for "previous" row.
# 2016apr05: if previous space is blank...
if ($prv[0] eq "" || $prv[0] eq " " || $prv[0] eq "\N{U+0}" ) { # 2016apr05:
if ($aud[2] > 0) { $monopsi = $aud[2] } # 2016apr05: a throw-away monopsi
if ($aud[2] > 0) { print " i= $i arun = $audrun monopsi= $monopsi" } # 2016apr05:
my @nxr=split(',',$ear[($i+1)]); # 2016apr05: for next-in-line char
$ear[$i+1] = "$nxr[0],8,$nxr[2]"; # 2016apr05: "activate N-I-L character"
} # 2016apr05: end of test for matching pho as start of a word
} # 2016apr05: end of test for initial audrun, meaning start of word.
my @aud=split(',',$ear[$i]); # 2016feb20: row in @ear auditory array
if ($aud[1] > 0) { # 2016feb20: "If matching aud0 has activation"
if ($aud[2] > 0) { # 2016mar04: check for an audpsi tag
$prc = $aud[2]; # 2016mar04: provisional recognition of a stem
} # 2016mar04: end of test for available audpsi
$audrec = 0; # 2016feb20: "Zero out any previous audrec."
my @nxr=split(',',$ear[($i+1)]); # 2016feb20: for next-in-line char
$act = ($act + 2); # 2016feb20: Increment $act for discrimination.
$audrec = 0; # 2016feb20: "because match-up is not complete"
$ear[$i+1] = "$nxr[0],$act,$nxr[2]"; # "Increment for discrimination."
@nxr=split(',',$ear[($i+1)]); # 2016feb20: for next-in-line char
if ($nxr[0] eq " ") { # 2016feb28: if blank space after end of word...
if ($len == 2) { # 2016feb20: "If len(gth) is only two characters."
my @aud=split(',',$ear[$i]); # Expose values of @ear row #i
if ($aud[1] > 7) { # 2016feb20: "testing for eight (8)"
$psibase = $aud[2]; # 2016jan28 MindForth: "Assume a match."
print " RuAudRec: i= $i match $aud[0] len= $len psibase= $psibase \n"; # 2016feb28
$prc = $aud[2]; # 2016mar04: provisional recognition
print " RuAudRec: i= $i match $aud[0] len= $len prc= $prc \n"; # 2016mar04
} # 2016feb20: MindForth: "End of test for act=8 or positive."
} # 2016feb20: MindForth: "End of test for two-letter words."
} # 2016feb20: MindForth: "End of test in AudRecog for end of word."
my @aud=split(',',$ear[$i]); # 2016feb20: Expose values of @ear row #i
if ($aud[1] > 8) { # 2016feb20: "If activation higher than initial"
$actbase = 8; # 2016feb20: Mindforth: "Since act is > 8 anyway;"
my @nxr=split(',',$ear[($i+1)]); # 2016feb20: for next-in-line char
if ($nxr[0] eq " ") { # 2016feb23 English or German: !~ /[A-Z]/)
print " RuAR: i= $i no activation \n"; # 2016feb23 TEST
if ($aud[1] > $actbase) { # 2016feb20: "Testing for high act."
if ($audrec == 0) { # 2016feb28: TEST; REMOVE
$audrec = $aud[2]; # 2016feb20: "Fetch the potential tag"
} # 2016feb28: TEST
$prc = $aud[2]; # 2016ymar04: provisional recognition for stems
print " RuAudRec general: i= $i finding prc= $prc pho= $pho \n"; #2016mar04
$subpsi = $aud[2]; # 2016feb20: "Seize a potential stem."
$sublen = $len; # 2016feb20: "Hold length of word-stem."
if ($psibase == 0) { # 2016feb28: protect earlier $psibase
$psibase = $aud[2]; # 2016feb20: "Hold onto winner."
} # 2016feb28: end of TEST
my @k=split(',',$psy[$i]); # 2016mar15: "k" for knowledge
$recnum = $k[9]; # 2016mar26: recognized grammatical number
if ($k[11] > 0) { # 2016mar26: if there is a $dba value
$dba = $k[11]; # 2016mar26: for verb-recognition, etc.
} # 2016feb20: "end of test for dba"
$actbase = $aud[1]; # 2016feb20: "Winner is new actbase."
} else { # 2016feb20: "End of test for act higher than actbase."
$audrec = 0; # 2016feb20: no word has been recognized
} # 2016feb20: End of else-clause
my @aud=split(',',$ear[$i]); # 2016feb23: Expose values of @ear
$audrec = $aud[2]; # 2016feb23: capture audpsi of current engram
print " RuAudRec: at word-end $aud[0] recognizing $audrec \n"; #2016feb23
} # 2016feb20: "End of test for final char that has a psi-tag."
} # 2016feb20: "End of test for engram-activation above eight."
} # 2016feb20: "End of test for matching aud0 with activation."
} # 2016feb20: "End of test for a character matching 'pho'."
} # 2016feb20: End of backwards search through auditory memory.
$audrun++; # 2016feb20: audrun is only a counter, not a factor.
$act = 0; # 2016feb20:
$actbase = 0; # 2016feb20:
if ($psibase > 0) { $audrec = $psibase } # 2016feb20:
if ($audrec == 0) { # 2016feb20: correction, to what MindForth does here.
if ($monopsi > 0) { # 2016feb20:
if ($len < 2) { # 2016jan20:
$audrec = $monopsi; # 2016feb20: recognize one-letter word.
} # 2016feb20: end of test for word-length less than two
} # 2016feb20: end of test for presence of a found monopsi
} # 2016feb20: end of test for a found auditory recognition.
if ($audrec == 0 && $prc > 0) { # 2016feb20
$audrec = $prc; # 2016feb20: from Dushka RuAi; prov. recog;
print " RuAudR: t= $t audrec= $audrec prc= $prc pho= $pho \n"; #2016mar03
} # 2016feb20
if ($audrec == 0) { # 2016feb20:
$audrec = $morphpsi; # 2016feb20:
if ($sublen > 0) { # 2016feb20:
$stemgap = ($len - $sublen); # 2016feb20
} # 2016feb20:
if ($stemgap < 0) { $stemgap = 0 } # 2016feb20
if ($stemgap > 1) { $subpsi = 0 } # 2016feb20
if ($stemgap > 1) { $morphpsi = 0 } # 2016feb20
if ($stemgap > 1) { $audrec = 0 } # 2016feb20
} # 2016feb20:
$psibase = 0; # 2016feb20
$subpsi = 0; # 2016feb20
if ($audrec > 0) { # 2016feb20
if ($stemgap > 2) { # 2016feb20
$audrec = 0; # 2016feb20
} # 2016feb20
} # 2016feb20
$audpsi = $audrec; # 2016feb20
$audrec = 0; # 2016feb20: temporary safety precaution after xfer.
$stemgap = 0; # 2016feb20: safety measure
} # End of RuAudRecog(); return to RuAudMem(); 2016feb22
sub AudMem() { # 2016feb21: Re-instated from ghost075.pl of 13feb2016
print " AudMem-START: t= $t len= $len hlc= $hlc pho = $pho \n"; # 2016apr30
if ($pho =~ /[A-Z]/) { # 2016jan30: Only try to recognize pho(nemes)
AudRecog(); # 2016jan23: Recognize old words $char by $char.
} # 2016jan30: End of test for a letter of the alphabet.
if ($audpsi == 0) { # 2016feb05: if no news from AudRecog() early in the word
$ear[$t] = "$pho,$act,0"; # 2016feb05: no ultimate-tag
} # 2016feb05: end of test for storing pre-audpsi pho(nemes)
if ($len > 0) { # 2016feb05: assign tags to words, not empty rows
my @aud=split(',',$ear[($t)]); # 2016feb05: look at current row
if ($aud[0] !~ /[A-Z]/) { # 2016feb05: if aud0 is not a letter
if ($audpsi == 0) { # 2016feb05: if word unrecognized, nxt new concept
my @prv=split(',',$ear[($t-1)]); # 2016feb05: assuming post-word blank
$ear[$t-1] = "$prv[0],$prv[1],$nxt"; # 2016feb05: retroactive audpsi
if ($prv[0] eq "S") { # 2016mar08: if potentially "S" inflection...
@prv=split(',',$ear[($t-2)]); # 2016mar08: go back on more char
$ear[$t-2] = "$prv[0],$prv[1],$nxt"; # 2016mar08: possible end of stem
} # 2016mar08: end of test for word ending in "S"
} # 2016feb05: end of test to declare new concept for lack of old.
} # 2016feb05: end of check to see if space is reached after a word.
} # 2016feb05: end of test for a positive word-length
if ($audpsi > 0) { # 2016feb05: if there is an audpsi
$ear[$t] = "$pho,$act,0"; # 2016feb05: at first store no audpsi
my @aud=split(',',$ear[($t)]); # 2016feb05: look at current row
if ($aud[0] !~ /[A-Z]/) { # 2016feb05: if aud0 is not a letter
my @prv=split(',',$ear[($t-1)]); # 2016feb05: assuming post-word blank
$ear[$t-1] = "$prv[0],$prv[1],$audpsi"; # 2016feb05: retroactive audpsi
} # 2016feb06: end of waiting until just after a word to identify it.
} # 2016feb05: end of test for an audpsi from AudRecog()
if ($pho !~ /[A-Z]/) { # 2016feb03
$ear[$t] = "$pho,0,0"; # 2016jan28: initialize @ear panel-flags.
} # 2016jan23: Establish end of word.
} # 2016feb22: AudMem() returns to AudInput().
sub RuAudMem() { # 2016feb21: necessary for Cyrillic and not Roman
print "\nRuAudMem-START: t= $t len= $len hlc= $hlc pho = $pho \n"; # 2016apr05
# if ($pho =~ /[A-Z]/) { # 2016jan30: Only try to recognize pho(nemes)
if ($pho ne " ") { # 2016feb19: for this Russian experimental AI
if ($hlc eq "ru") { # 2016yfeb20: human-language-code
RuAudRecog(); # 2016feb20: Recognize old words $char by $char.
if ($audpsi == 0) { # 2016mar04: from JavaScript Russian Dushka AI
if ($prc > 0) { $audpsi = $prc } # 2016mar04: prov. recog; 2016mar04
} # 2016mar04: end of test for not yet an audpsi
} # 2016feb20: end of test for human-language-code "ru"
} # 2016jan30: End of test for a letter of the alphabet.
if ($audpsi == 0) { # 2016feb05: if no news from AudRecog() early in the word
if ($prc > 0) { $audpsi = $prc } # 2016mar04: for word-stems
$ear[$t] = "$pho,$act,0"; # 2016feb05: no ultimate-tag
if ($len > 4) { # 2016mar05: if long enough to include a verb-stem
$ear[$t] = "$pho,$act,$audpsi"; # 2016mar05: audpsi for verb-stems
} # 2016mar05: end of test for length long enough to be a verb
} # 2016feb05: end of test for storing pre-audpsi pho(nemes)
if ($hlc eq "ru") { # 2016feb20: special handling for Russian
if ($len > 0) { # 2016feb20: assign tags to words, not empty rows
my @aud=split(',',$ear[($t)]); # 2016feb20: look at current row
if ($aud[0] eq " " || $aud[0] eq "\n") { # 2016feb24: if aud0 is not a letter
if ($audpsi == 0) { # 2016feb20: if word unrecognized, nxt new concept
my @prv=split(',',$ear[($t-1)]); # 2016feb20: assuming post-word blank
$ear[$t-1] = "$prv[0],$prv[1],$nxt"; # 2016feb20: retroactive audpsi
if ($len > 4) { # 2016mar05: long enough to include a verb-stem
@prv=split(',',$ear[($t-2)]); # 2016mar05: penultimate character
$ear[$t-2] = "$prv[0],$prv[1],$nxt"; # 2016mar05: retroactive audpsi
@prv=split(',',$ear[($t-3)]); # 2016mar05: pre-penultimate char
$ear[$t-3] = "$prv[0],$prv[1],$nxt"; # 2016mar05: retroactive audpsi
@prv=split(',',$ear[($t-4)]); # 2016apr04: back one more character
$ear[$t-4] = "$prv[0],$prv[1],$nxt"; # 2016apr04: retroactive audpsi
} # 2016mar05: end of length-test adapted from Dushka Russian AI
} # 2016feb20: end of test to declare new concept for lack of old.
} # 2016feb20: end of check to see if space is reached after a word.
} # 2016feb20: end of test for a positive word-length
} # 2016feb20: end of special handling for Russian
if ($audpsi > 0) { # 2016feb05: if there is an audpsi
if ($hlc eq "ru") { # 2016feb20: special handling for Russian "ru"
$ear[$t] = "$pho,$act,$audpsi"; # 2016feb20: TEST
my @aud=split(',',$ear[($t)]); # 2016feb05: look at current row
# if ($aud[0] !~ /[A-Z]/) { # 2016feb05: if aud0 is not a letter
if ($aud[0] eq " ") { # 2016feb20: if post-character blank-space
# print " RuAudM: storing retroactive audpsi $audpsi \n"; # 2016feb22
my @prv=split(',',$ear[($t-1)]); # 2016feb05: assuming post-word blank
$ear[$t-1] = "$prv[0],$prv[1],$audpsi"; # 2016feb05: retroactive audpsi
} # 2016feb06: end of waiting until just after a word to identify it.
} # 2016feb20: end of test for Russian human-language-code $hlc
} # 2016feb05: end of test for an audpsi from AudRecog()
if ($pho eq " ") { # 2016feb20
$ear[$t] = "$pho,0,0"; # 2016jan28: initialize @ear panel-flags.
my @aud=split(',',$ear[$t]); # 2016feb19: Examine the @ear array.
} # 2016jan23: Establish end of word.
} # 2016feb22: RuAudMem() returns to AudInput()
sub AudInput() { # 2016feb21: reinstated from ghost075 as TEST; modified
$spt = $t; # 2016jan28: as in FileInput() module.
$bias = 5; # 2016fev11: Expect a noun until overruled.
$krt = $t; # 2016feb08: for Tutorial display of @ear array
$tsn = $t; # 2016mar13: current input is time-of-seqneed $tsn
$_ = " "; # 2016FEB03: PERL by Example (2015), p. 301
if ($pov == 2) { # 2016apr09: use STDIN only for external input...
print "\nEnter English or Russian words as Subject-Verb-Object: \n \n"; #2016apr21
$msg = <STDIN>; # 2015may01: PERL by Example (2015), p. 50
if ($hlc eq "en" || $hlc eq "de") { # 2016feb21: English or German
print "Changing to uppercase \n"; # 2016apr05
print "You entered: \n"; # 2016mar04
$msg = uc $msg; # 2016jan29: from Perl Black Book, p. 341.
} # 2016feb21: end of test for non-Cyrillic English or German
print "\nHuman: $msg \n"; # 2016jan29: newline is now _outside_ $msg.
} # 2016apr09: End of test to decide between STDIN and re-entry.
my $reversed = reverse $msg; # 2016jan29: PbyEx p. 125
# if ($reversed =~ /[Q]/) { # 2016jun21: enlarging quit-sequence
# my $fh = new IO::File; # 2016jun21: Perl_Black_Book p. 561
# print "Opening diagnostic minddata.txt file...\n"; # 2016jun21
# $fh->open(">minddata.txt") or die "Can't open: $!\n"; #2016jun21
# $tai = $vault; # 2016jun21: skip the MindBoot() sequence.
# $fh->printf ("Log-file of $vrsn AI born on $birth\n"); # 2016jun26
# $fh->printf ("time psi act hlc pos jux pre iob tkb "); # 2016jun26
# $fh->printf ("seq num mfn dba rv pho act audpsi \n"); # 2016jun26
# do { # 2016jun21: make a loop
# print "t=$tai. psi=$psy[$tai], "; # 2016jun21: show @psy concept array
# print " aud= $ear[$tai], \n"; # 2016jun21: show @ear auditory array
# $fh->printf ("t=$tai. psi=$psy[$tai], aud= $ear[$tai], \n"); # 2016jun21: PBB p. 535
# $tai++; # 2016jun21: increment $tai up until current time $t.
# } while ($tai < $t); # 2016jun21: show @psi and @ear array at recent time-points
# print "Closing minddata.txt file...\n"; # 2016jun21
# $fh->close; # 2016jun21: Perl_Black_Book p. 561
# die "TERMINATE: Q means quit. \n"; # 2016jun21
# } # 2016jun21: end of quit-sequence commented out prior to Web release.
# if ($reversed =~ /[Q]/) { # 2016jun21: enlarging quit-sequence
# my $fh = new IO::File; # 2016jun21: Perl_Black_Book p. 561
# print "Opening diagnostic minddata.txt file...\n"; # 2016jun21
# $fh->open(">minddata.txt") or die "Can't open: $!\n"; #2016jun21
# $tai = $midway; # 2016jun28: include the MindBoot() sequence.
# $fh->printf ("Log-file of $vrsn AI born on $birth\n"); # 2016jun26
# $fh->printf ("time psi act hlc pos jux pre iob tkb "); # 2016jun26
# $fh->printf ("seq num mfn dba rv pho act audpsi \n"); # 2016jun26
# do { # 2016jun21: make a loop
# print "t=$tai. psi=$psy[$tai], "; # 2016jun21: show @psy concept array
# print " aud= $ear[$tai], \n"; # 2016jun21: show @ear auditory array
# $fh->printf ("t=$tai. psi=$psy[$tai], aud= $ear[$tai], \n"); # 2016jun21: PBB p. 535
# $tai++; # 2016jun21: increment $tai up until current time $t.
# } while ($tai < $t); # 2016jun21: show @psi and @ear array at recent time-points
# print "Closing minddata.txt file...\n"; # 2016jun21
# $fh->close; # 2016jun21: Perl_Black_Book p. 561
# die "TERMINATE: Q means quit. \n"; # 2016jun21
# } # 2016jun21: end of quit-sequence commented out prior to Web release.
if ($reversed =~ /[Q]/) { die "TERMINATE: Q for quit. \n"; } # 2016apr29
if ($fyi == 2) { print "Tutorial shows workings of the AI Mind. \n"; }
do { # 2016feb02: outer loop receives input of an entire sentence.
do { # 2016feb02: inner loop treats each word character by character.
$pho = chop($reversed); # 2016jan29 returns chopped character as $pho.
if ($pho eq "\n") { $eot = 1 } # 2016feb01: for escape from outer loop.
if ($pho eq "\n" && $msg eq "") { $trigger++ } # 2016apr29
if ($pho eq "\n") { # 2016jun19: TEST
print "AudInput: psi= $psi oldpsi= $oldpsi actpsi= $actpsi \n"; # 2016jun19: TEST
} # 2016jun19
# 2016feb21: Following 33 tests convert to uppercase and $hlc to "ru":
if ($pho eq "\xA0"||$pho eq "\x80") {$pho="\x80"; $hlc="ru"} # 2016feb20
if ($pho eq "\xA1"||$pho eq "\x81") {$pho="\x81"; $hlc="ru"} # 2016feb20
if ($pho eq "\xA2"||$pho eq "\x82") {$pho="\x82"; $hlc="ru"} # 2016feb20
if ($pho eq "\xA3"||$pho eq "\x83") {$pho="\x83"; $hlc="ru"} # 2016feb20
if ($pho eq "\xA4"||$pho eq "\x84") {$pho="\x84"; $hlc="ru"} # 2016feb20
if ($pho eq "\xA5"||$pho eq "\x85") {$pho="\x85"; $hlc="ru"} # 2016feb20
if ($pho eq "\xF1"||$pho eq "\xF0") {$pho="\xF0"; $hlc="ru"} # 2016feb20
if ($pho eq "\xA6"||$pho eq "\x86") {$pho="\x86"; $hlc="ru"} # 2016feb20
if ($pho eq "\xA7"||$pho eq "\x87") {$pho="\x87"; $hlc="ru"} # 2016feb20
if ($pho eq "\xA8"||$pho eq "\x88") {$pho="\x88"; $hlc="ru"} # 2016feb20
if ($pho eq "\xA9"||$pho eq "\x89") {$pho="\x89"; $hlc="ru"} # 2016feb20
if ($pho eq "\xAA"||$pho eq "\x8A") {$pho="\x8A"; $hlc="ru"} # 2016feb20
if ($pho eq "\xAB"||$pho eq "\x8B") {$pho="\x8B"; $hlc="ru"} # 2016feb20
if ($pho eq "\xAC"||$pho eq "\x8C") {$pho="\x8C"; $hlc="ru"} # 2016feb20
if ($pho eq "\xAD"||$pho eq "\x8D") {$pho="\x8D"; $hlc="ru"} # 2016feb20
if ($pho eq "\xAE"||$pho eq "\x8E") {$pho="\x8E"; $hlc="ru"} # 2016feb20
if ($pho eq "\xAF"||$pho eq "\x8F") {$pho="\x8F"; $hlc="ru"} # 2016feb20
if ($pho eq "\xE0"||$pho eq "\x90") {$pho="\x90"; $hlc="ru"} # 2016feb20
if ($pho eq "\xE1"||$pho eq "\x91") {$pho="\x91"; $hlc="ru"} # 2016feb20
if ($pho eq "\xE2"||$pho eq "\x92") {$pho="\x92"; $hlc="ru"} # 2016feb20
if ($pho eq "\xE3"||$pho eq "\x93") {$pho="\x93"; $hlc="ru"} # 2016feb20
if ($pho eq "\xE4"||$pho eq "\x94") {$pho="\x94"; $hlc="ru"} # 2016feb20
if ($pho eq "\xE5"||$pho eq "\x95") {$pho="\x95"; $hlc="ru"} # 2016feb20
if ($pho eq "\xE6"||$pho eq "\x96") {$pho="\x96"; $hlc="ru"} # 2016feb20
if ($pho eq "\xE7"||$pho eq "\x97") {$pho="\x97"; $hlc="ru"} # 2016feb20
if ($pho eq "\xE8"||$pho eq "\x98") {$pho="\x98"; $hlc="ru"} # 2016feb20
if ($pho eq "\xE9"||$pho eq "\x99") {$pho="\x99"; $hlc="ru"} # 2016feb20
if ($pho eq "\xEA"||$pho eq "\x9A") {$pho="\x9A"; $hlc="ru"} # 2016feb20
if ($pho eq "\xEB"||$pho eq "\x9B") {$pho="\x9B"; $hlc="ru"} # 2016feb20
if ($pho eq "\xEC"||$pho eq "\x9C") {$pho="\x9C"; $hlc="ru"} # 2016feb20
if ($pho eq "\xED"||$pho eq "\x9D") {$pho="\x9D"; $hlc="ru"} # 2016feb20