1 q = 0 100 ' LTblGen: A Program to generate a table from a source text file, 101 ' Which table consists of a 0-26 by 0-26 by 0-27 (X,Y,Z) grid, where 102 ' Z is the odds of any given letter a-z following the 2-letter sequence X,Y. 103 ' Index 0 is a non-letter, indicating the beginning or end of a word. 104 ' Index 27 is the sum of all the counts from 0-26, in vector X,Y 105 ' 110 print "Language Table Generator" 120 input "Source Text file for processing : ",i$ 130 input "Output Table-File : ",o$ 140 dim t(26,26,27) 141 for x = 0 to 26 : for y = 0 to 26 : for z = 0 to 17 142 t(x,y,z) = 0 143 next z : next y : next x 200 'open input file 201 open i$ for input as #1 210 'Process dataline 211 input #1,l$ 212 l$ = ">>"+l$+"<" 213 l = len(l$) 215 if eof(1) then goto 300 220 for p = 3 to l 230 c$ = mid$(l$,p-2,1) 231 c1 = 0 232 if c$ >= "A" and c$ <= "Z" then c1 = asc(c$)-64 233 if c$ >= "a" and c$ <= "z" then c1 = asc(c$)-96 234 ' character minus 2 235 ' 240 c$ = mid$(l$,p-1,1) 241 c2 = 0 242 if c$ >= "A" and c$ <= "Z" then c2 = asc(c$)-64 243 if c$ >= "a" and c$ <= "z" then c2 = asc(c$)-96 244 if c2 = 0 then c1 = 0 245 ' character minus 1 246 ' 250 c$ = mid$(l$,p,1) 251 c3 = 0 252 if c$ >= "A" and c$ <= "Z" then c3 = asc(c$)-64 253 if c$ >= "a" and c$ <= "z" then c3 = asc(c$)-96 254 ' current character 255 ' 260 'process letter-sequence 261 if c1 = 0 and c2 = 0 and c3 = 0 then goto 290 'not in a word 262 t(c1,c2,c3) = t(c1,c2,c3)+1 263 t(c1,c2,27) = t(c1,c2,27)+1 270 ' 271 ' 290 next p 291 q = q+1 292 if (q mod 50) = 0 then print "*"; 293 if (q mod 2500) = 0 then print ">" 294 if q >= 2500 then q = 0 295 goto 210 300 'can't process anymore datalines? 305 print 310 close #1 320 print "DUmping data table now:" 330 open o$ for output as #1 340 for x = 0 to 26 350 for y = 0 to 26 355 for z = 0 to 27 360 print #1,t(x,y,z) 365 next z 379 next y 380 next x 390 close #1 400 stop 900 'unexpected error conditions 910 print "could not open input file ";i$ 911 stop 920 print "Unexpected error inputing from datafile" 921 stop 999 end