home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD5.iso / workbench / tools / czesc_4 / tclass / docs / ai.doc next >
Encoding:
Text File  |  1992-12-18  |  3.3 KB  |  91 lines

  1.                                 DOCUMENT: AI
  2.  
  3. This is the artificial intelligence document for TClass.  Other documents in
  4. this directory:
  5.  
  6. TClass.doc
  7. Programmer.doc
  8. Installation.doc
  9. showbytes.doc
  10.  
  11.                                   Contents
  12.  
  13.           1.A - AI used in TClass?
  14.           1.B - How does it work?
  15.  
  16. ================================================================================
  17.  
  18. 1.A - AI used in TClass?
  19.  
  20. Yes, a minor form of AI.  When I started thinking about how I was going to go
  21. about the 'learn' option in TClass, I thought I'd go by a simple algorithm
  22. that humans might use to compare file types.
  23.  
  24. 1.B - How does it work?
  25.  
  26. It works like this:
  27.  
  28. Fig1.1  TClass learn lc.lib lcm.lib lcs.lib lcmffp.lib
  29.  
  30. Ok, lc.lib is referred to as the "base file" because that's the first file
  31. that's payed attention to.  What TClass does is, it loads in lc.lib, reads
  32. the first twenty bytes, and stores them in some array.  Let's say the bytes
  33. are:
  34.  
  35.               5 0 3 9 -13 7 92 25 -5 1 20 7 11 92 0 0 0 -2 0 -2
  36.  
  37. Ok, so we have some sort of basis here.  These bytes are stored in a stable
  38. array, one that isn't going to be overwritten--yet.  Next, lcm.lib is opened,
  39. the first 20 bytes are read into a temporary array.
  40.  
  41. lc.lib:       5 0 3 9 -13 7 92 25 -5 1 20 7 11 92 0 0 0 -2 0 -2
  42. lcm.lib:      5 0 3 9 -13 2 92 25 -5 1 20 7 11 92 0 0 3 -2 0 -2
  43.                           ^                           ^
  44. As you see, lcm.lib has two bytes that conflict with the original's.  When a
  45. human sees this, they may think "Ok, those bytes obviously have nothing to do
  46. with identifying the filetype, so I'll ignore those in the future since I
  47. KNOW lc.lib and lcm.lib are of the same type."  And this is exactly what
  48. TClass does.  It stamps an "ignore" byte in that position.  Now lc.lib, the
  49. base file, looks like this:
  50.  
  51. lc.lib:       5 0 3 9 -13 i 92 25 -5 1 20 7 11 92 0 0 i -2 0 -2
  52.  
  53. And the next file is read, and the next, and the next, until it's done, and
  54. at the end, lc.lib might look like:
  55.  
  56. lc.lib:       5 i 3 9 -13 i 92 25 -5 i 20 i i i 0 0 i -2 0 -2
  57.  
  58. So we have 7 ignored bytes out of a possible 20.  That's 35% ignored, or 65%
  59. KNOWN bytes.  Thus,
  60.  
  61. Filetype learned!  65% accuracy.
  62.  
  63. So whether you give TClass 2 files to learn, or 100, accuracy percentages can
  64. vary.  So, let's say you goof up:
  65.  
  66.   TClass learn ignore fido.font eclipse.font newfonts/#?.font oops.medmod
  67.  
  68. Let's say after all the fonts are done, we have this:
  69.  
  70.               9 1 -20 0 i i 0 -5 22 71 30 -5 2 7 91 i -2 0 0 1
  71.  
  72. Well, next file is oops.medmod, a MED module.  Well, that has a TOTALLY
  73. different file structure.  So let's say that the MED mod might have a COUPLE
  74. bytes that resemble a font:
  75.  
  76. fonts:        9 1 -20 0 i i 0 -5 22 71 30 -5 2 7 91 i -2 0 0 1
  77. oops.medmod:  5 1 32 2 45 3 -1 9 82 -2 34 97 5 0 0 0 0 6 0 2
  78.  
  79. Well, after this comparison, we have this as the bytelist:
  80.  
  81. i 1 i i i i i i i i i i i i i i i i 0 i
  82.  
  83. Not very productive. :)  That's 18/20 ignores, 90% ignored bytes, or 10%
  84. KNOWN bytes. :)  So when this faulty thing called a "font" is recorded into
  85. TClass.brain, you could do "TClass i_goofed.library" and it might be called a
  86. font, just because it has a 1 in position 2 and a 0 in position 19. :)  So
  87. watch the accuracy reponse at the end of a learning session.  Or, even more
  88. effective, you could view S:TClass.brain and check out the number of i's.
  89. See Programmer.doc for the format of the brain file.
  90.  
  91.