Category : Files from Magazines
Archive   : AWKWARD.ZIP
Filename : AWKWARD.FIG

 
Output of file : AWKWARD.FIG contained in archive : AWKWARD.ZIP
AWK scripts and associated data files to accompany the article:
AWKWARD: Toward Database Reasoning
by Yuval Lirov and Swaminathan Ravikumar
Appearing in the October 1989 Issue of AI EXPERT
All Rights Reserved


\05/^IF.*/ {
\06gsub(/[ $bsl$t]*IF[ $bsl$t]*/, ""); # remove keyword "IF"
\07gsub(/[ $bsl$t]*IS[ $bsl$t]*/, ":"); # remove keyword "IS"
\08printf("%s:rule%d$bsl$n", $ DD$0, counter) >> "condtable";
\09}
10
11/^THEN.*/ {
12gsub(/[ $bsl$t]*THEN[ $bsl$t]*/, ""); # remove keyword "THEN"
13gsub(/[ $bsl$t],*IS[ $bsl$t]*/, ":"); # remove keyword "IS"
14printf("%s:rule%d$bsl$n", $ DD$0, counter++) >> "actiontable";
15}

Figure 1. Translation Script


\01IF IC1-10 IS -5v
\02THEN measure with voltmeter IS IC2-25
\03IF IC2-25 IS +5v
\04THEN replace`````IS IC6

Figure 2. Sample Rule Base in Rule Format


\01IC1-10:-5v:rule0
\02IC2-25:+5v:rule1

Figure 3a. Sample Rule Base Condition Table


\01measure with voltmeter:IC2-25:rule0
\02replace:IC6:rule1

Figure 3b. Sample Rule Base Action Table


\01BEGIN {
\02ARGV[1] $fat =$ "-";
\03printf("Enter initial condition : ");
\04getline;
\05subject $=$ $DD$1;
\06value $=$ $DD$2;
\07FS $=$ ":";
\08
\09for (;;) {
10if ((ruleid $=$ find_ruleid(subject, value)) !$=$ "") {
11if ((action $=$ find_action(ruleid)) !$=$ "") {
12split (action, ary) ;
13printf("%s %s : ", ary[1], ary[2]);
14getline value;
15subject $=$ ary[2];
16close("condtable");
17close("actiontable");
18}
19else
20break;
21}
22else
23break;
24}
25}
26
27function find_ruleid(subject, value)
28{
29while ((getline <"condtable") > 0) {
30if ($DD$1 $=$$=$ subject && $DD$2 $=$$=$ value)
31return $DD$3; ````````# return rule id
32}
33return "";
34}
35
36function find_action(ruleid)
37{
38while ((getline <"actiontable") > 0) {
39if ($DD$3 $=$$=$ ruleid)
40return $DD$1 ":" $DD$2;`````# return action and subject
41}
42return "";
43}

Figure 4. Inference Engine By Queries


\01BT 12-18-88 16:05:38
\02TS DAISY1
\03BC TN754 V12
\04SN 8DC379700
\05BR P
\06LC D02
\07OC SHIPPED FROM POS. 101, 16:05:38 SUN. DEC.18
\08TO 1
\09ET 12-18-88 16:05:38
\10BT 12-18-88 17:12:27
\11TS FR1
\12BC TN742 V10
\13SN 6D4316300
\14BR P
\15LC B04
\16OC SHIPPED FROM POS. 216, 17:12:27 SUN. DEC.18
\17TO 1
\18ET 12-18-88 17:12:27
\19BT 12-19-88 13:40:28
\20TS ABNER1
\21BC TN753 V8
\22SN 8DC379300
\23BR F
\24LC A10
\25LP 1
\26PN 4
\27ST 33
\28FS 25255
\29FT 3:34:00
\30TI RAS
\31TO 1
\32ET 12-19-88 13:40:28

Figure 6a. Data File


\01BEGIN {
\02RS = "";
\03FS = "$bsl$n";
\04}
\05
\06$DD$1 $wig$ /^BC/ {
\07filename $=$ $DD$2;# field two is pack code
\08for (i = 1; i <= NF; i++)
\09`````printf("%s$bsl$n", $DD$i) >> filename# append data to filename
10close(filename);# cannot have too many open files
11}

Figure 6b. Classifying the Circuit Packs


\01BT 01-03-89 09:47:41
\02TS DAISY2
\03BC TN742 V17
\04SN 8DC379800
\05BR P
\06LC C11
\07OC SHIPPED FROM POS. 201, 9:47:41 TUE. JAN. 3
\08TO 1
\09ET 01-03-89 09:47:41
\10
\11BT 01-03-89 13:08:35
\12TS FR1
\13BC TN742 V16
\14SN 7D7320600
\15BR P
\16LC C12
\17OC SHIPPED FROM POS. 216, 13:08:34 TUE. JAN. 3
\18TO 1
\19ET 01-03-89 13:08:35
\20
\21BT 01-03-89 10:04:31
\22TS FR1
\23BC TN742 V10
\24SN 5D9303300
\25BR P
\26LC C19
\27OC SHIPPED FROM POS. 109, 10:04:31 TUE. JAN. 3
\28TO 1
\29ET 01-03-89 10:04:31
\30

Figure 6c. Classified Data File


\01BEGIN {
\02FS $=$ " ";
\03OFS $=$ "$bsl$t"
\04teststep $=$ "default";
\05}
\06
\07$DD$1 $wig$ /^BT/ {
\08split($DD$2, time, "-")
\09yy $=$ time[3]
10(length(time[1]) $=$$=$ 2) ? mm $=$ time[1] : mm $=$ "0" time[1]
11(length(time[2]) $=$$=$ 2) ? dd $=$ time[2] : dd $=$ "0" time[2]
12mtime $=$ yy "-" mm "-" dd
13}
14$DD$1 $wig$ /^ST/ {
15teststep $=$ $DD$2
16}
17$DD$1 $wig$ /^AC/ {
18action $=$ $DD$2
19}
23$DD$1 $wig$ /^PI/ {
21part $=$ $DD$2
22}
23$DD$1 $wig$ /^SN/ {
24serial$=$ $DD$2
25}
26$DD$1 $wig$ /ET/ {
27printf("%s$bsl$t%s$bsl$t%s$bsl$t%s$bsl$t%s$bsl$n",
28serial, mtime, teststep, action, part) \(bv "sort";
29teststep $=$ "default";
30mtime $=$ "";
31action $=$ "";
32part $=$ "";
33serial $=$ "";
34}

Figure 7a. Creating the History of the Replacements on a Circuit Pack


\014DB19801088-12-02200
\024DB19801088-12-06defaultREPLACEDIC17.4
\034DC13780788-10-02200
\044DC13780788-10-04defaultREPLACEDC22.7
\055D333430988-12-1047
\065D333430988-12-13defaultREPLACEDIC16.7
\075D338870588-10-1551
\085D338870588-10-27defaultREPLACEDC32

Figure 7b.


\01# $DD$1 - serial; $DD$2 $=$ time; $DD$3 $=$ teststep, $DD$4 $=$ action; $DD$5 $=$ part
\02
\03BEGIN {
\04teststep$=$"";
\05serial$=$"";
\06}
\07
\08{
\09if ((NF $=$$=$ 5) && ($DD$1 $=$$=$ serial) && ($DD$4 !$=$ "NO") &&
10`````(teststep !$=$ "default"))
11printf("%s$bsl$t%s$bsl$t%s$bsl$t%s$bsl$n", teststep, $DD$4, $DD$5, $DD$1) \(bv "sort"
12else
13if ((NF $=$$=$ 3) && ($DD$3 !$=$ "default")) {
14`serial $=$ $DD$1;
15`teststep $=$ $DD$3;
16}
17}

Figure 8a. Building Failure-Replacement Relation from History Files


\01200REPLACEDC22.74DC148913
\02200REPLACEDIC17.44DC137811
\03200REPLACEDIC17.34DC148510
\04200REPLACEDIC17.35D6362208
\0547REPLACEDIC17D6311409
\0647REPLACEDIC18D9069509
\0747REPLACEDIC107D5383800
\0847REPLACEDIC116DC374112
\0947REPLACEDIC118DC375604
\1047REPLACEDIC118DC379805
\1147REPLACEDIC119D1375501
\1247REPLACEDIC127DC028512
\1347REPLACEDIC128D9313403
\1447REPLACEDIC128D9313403
\1547REPLACEDIC128DC379805
\1647REPLACEDIC129D1391710

Figure 8b.


\01# $DD$1 $=$ teststep; $DD$2 $=$ action; $DD$3 $=$ part; $DD$4 $=$ serial
\02
\03BEGIN {
\04teststep$=$"";
\05replacement$=$"";
\06counter$=$0;
\07}
\08
\09NF $=$$=$ 4 {
10if (teststep $=$$=$ $DD$1 && replacement $=$$=$ $DD$3)
11counter++;
12else {
13printf("%s$bsl$t%2d$bsl$d%s$bsl$n", teststep, counter,
14replacement) \(bv "sort -r"
15teststep $=$ $DD$1;
16replacement $=$ $DD$3;
17counter $=$ 1;
18}
19}

Figure 9. Constructing Advice Table from Failure-Replacement Relation


1 BEGIN {
2# read advicetable into an associative array whose index is test step
3while (getline < "advicetable" > 0)
4 rule[$dollar$1] = rule[$dollar$1] $dollar$3 ":";
5
6for (;;) {
7 printf("Enter serial number : ");
8 if (getline > 0) {
9 if ($dollar$1 != pvsno) # if entered serial no != previous serial no
10 ctsno = $dollar$1; # initialize current serial no
11 printf("Enter test step : ");
12 if (getline > 0) {
13 if ($dollar$1 in rule) {
14 if ($dollar$1 != pvtsp) # if entered test step != previous test step
15 cttsp = $dollar$1; # initialize current test step
16if (cttsp == pvtsp && ctsno == pvsno) {
17 # both serial no and test step are same as previous one
18 # and previous suggestion did'nt fix the problem
19 spcnt = split(rule[cttsp], ary, ":") - 1;
20 if (idxcnt < spcnt)
21 # give the next most probable suggestion
22 printf("$bsl$n$bsl$t$bsl$t**** Replace %s ****$bsl$n", ary[++idxcnt]);
23 else {
24 printf("$bsl$n$bsl$t$bsl$t**** Out of suggestions ****$bsl$n");
25 pvsno = "";
26 pvtsp = "";
27 }
28}
29else {
30 # either serial no is different from previous one
31 # or same serial no but different test step
32 # or both serial no and test step are different
33 idxcnt = 1;
34 pvsno = ctsno;
35 pvtsp = cttsp;
36 split(rule[cttsp], ary, ":");
37 printf("$bsl$n$bsl$t$bsl$t**** Replace %s ****$bsl$n", ary[idxcnt]);
38}
39 }
40 else {
41 printf("$bsl$n$bsl$t$bsl$t**** Missing Knowledge ****$bsl$n");
42 pvsno = "";
43 pvtsp = "";
44 }
45 }
46 }
47 }
49 }

Figure 11. Inference Script Using the Advice Tables




  3 Responses to “Category : Files from Magazines
Archive   : AWKWARD.ZIP
Filename : AWKWARD.FIG

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/