home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / spell / spell21.lbr / SPELL21.DQC / SPELL21.DOC
Text File  |  1985-02-16  |  19KB  |  432 lines

  1.  
  2.  
  3.  
  4.                     SPELL V2.0 DOCUMENTATION
  5.                         Michael C. Adler
  6.                        December 22, 1982
  7.  
  8.     (C)  1982 Michael C.  Adler
  9.  
  10.     This  program  has been released into the public domain by
  11.     the author.   It  may  neither  be  sold  for  profit  nor
  12.     included  in a sold software package without permission of
  13.     the author.
  14.  
  15.     The first SPELL using this dictionary was probably written
  16.     by  Ralph Gorin at Stanford.  It was transported to MIT by
  17.     Wayne Mattson.  Both the program at MIT and the dictionary
  18.     were most recently revised by  William  Ackerman  at  MIT.
  19.     Section 5 of this document was copied from portions of Mr.
  20.     Ackerman's documentation.
  21.  
  22.           Thanks to all for the effort spent designing the
  23.           dictionary!
  24.  
  25.      Spell  is  a  program, written for Z80 processors running
  26.     CP/M,  designed to detect misspellings in a document.
  27.  
  28. 1.  USING SPELL
  29.  
  30.      The  minimum  configuration  of  SPELL  requires  the files
  31. SPELL.COM and DICT.DIC (the main dictionary).  At  the  time  of
  32. execution, DICT.DIC must be on either the default drive or drive
  33. A:.
  34.  
  35.      The  name  of  the file to be corrected must be included on
  36. the command line that is used to invoke spell.  If a drive  name
  37. is  specified  as  a second file name, output is directed to the
  38. specified drive.  Thus,
  39.  
  40.                SPELL useless.doc
  41.  
  42. will  check  the  file  "useless.doc"  and  direct output to the
  43. default drive and
  44.  
  45.                SPELL b:useless.doc c:
  46.  
  47. will check the file "b:useless.doc" and direct output to disk c.
  48.  
  49.      Spell  will  check  the  input file for errors by comparing
  50. each  word in the file to the dictionary.   If  a  word  is  not
  51. found,  a   null (ascii 0) is placed before the word.  To change
  52. this marking  character, see section 4, PATCHING  SPELL.   If  a
  53. backup  version   (.BAK  file type) of the input file exists, it
  54. will be deleted.   The input file will be renamed  to  a  backup
  55. file and the checked  file will replace the input file.
  56.  
  57. 2.  USER DICTIONARIES
  58.  
  59.      A  user  dictionary is a list of correct words that  can  be
  60.  
  61.  
  62.                                 1
  63.  
  64.  
  65.  
  66. loaded  by  SPELL to augment the main dictionary.  Words such as
  67. proper nouns can be placed in user dictionaries to inhibit error
  68. marking.  User dictionary files may be formatted in any way that
  69. the user desires, as long as words are delimited by non-alphabe-
  70. tic characters.
  71.  
  72.      SPELL  will  automatically  search  for the user dictionary
  73. SPELL.DIC on the default drive and on drive A: if it is  not  on
  74. the  default one.  It's contents are then loaded and temporarily
  75. added to the dictionary.  It must be loaded again to be included
  76. in subsequent executions of SPELL.
  77.  
  78.      SPELL  will also automatically search for d:file.UDC, where
  79. file is the name of the file being corrected and d: is the drive
  80. on which file is found.  If found, it is also loaded and  tempo-
  81. rarily augments the dictionary.  Thus, users may create separate
  82. dictionaries for each text file being corrected.  After locating
  83. d:file.UDC,  SPELL  will  search  file d:file.ADD.  This file is
  84. created by WordStar's ^QL command (see section 3) and is not  an
  85. ASCII  file.  d:file.ADD contains commands generated by WordStar
  86. to include specific words in the user dictionary associated with
  87. d:file.  SPELL will temporarily place all of the words in it  in
  88. the dictionary and will also save the words by copying them into
  89. d:file.UDC.
  90.  
  91.      It  is  possible  to  load  additional user dictionaries by
  92. specifying them on the SPELL command line.  A list of user  dic-
  93. tionaries  must  be  preceded by a dollar sign.  A dictionary is
  94. specified by a file name and an  optional  drive  name.   If  no
  95. drive   is  specified,  the  default  drive is searched and then
  96. drive A: is  checked.  Extensions are  ignored  and  default  to
  97. .DIC.  Hence, the  the command line:
  98.  
  99.      SPELL useless.doc b: $dict1 c:dict2 dict3.fun
  100.  
  101. would  correct  useless.doc and direct output to drive B:.  User
  102. dictionary DICT1.DIC would be loaded from the default  drive  or
  103. drive  A:,  dictionary  DICT2.DIC would be loaded from drive C:,
  104. and DICT3.DIC would be loaded from the default  drive  or  drive
  105. A:.   Notice that the extension .fun was ignored.
  106.  
  107. 3.  WordStar's ^QL COMMAND
  108.  
  109.      Files checked by SPELL can be corrected using WordStar.  In
  110. response  to  ^QL,  the user is asked which portions of the file
  111. should be searched.  WordStar will then position the  cursor  on
  112. the  first marked word and print a menu offering F (Fix word), B
  113. (Bypass word), I (Ignore word), D (Add  to  dictionary),  and  S
  114. (Add   to  supplemental  dictionary).   The F option deletes the
  115. error  marker and returns to the WordStar  main  menu,  allowing
  116. the user  to correct the word.  B will leave the word marker and
  117. will    search   for   the   next   misspelled  word.   In  this
  118. implementation of  SPELL, the I, D and S options all perform the
  119. same function  (although I is easier to use because no  question
  120. is  asked  by   WordStar).  If either of these options (I, D, S)
  121. are chosen, the 
  122.  
  123.  
  124.                                 2
  125.  
  126.  
  127.  
  128. mark  will  be  removed  and the word will be added to file.ADD.
  129. Thus, choosing these options informs SPELL that the word is cor-
  130. rect and should not be marked again.  The D and S options do not
  131. add the word to SPELL's main dictionary because the  compression
  132. method  used to store the dictionary is too complicated to allow
  133. such  modification  efficiently.   After  choosing  all  of  the
  134. options   except  F,  WordStar will automatically search for the
  135. next marked  word.
  136.  
  137. 4.  PATCHING SPELL
  138.  
  139.      It  is  not  necessary  to  recompile  SPELL  to change the
  140. character that  marks  misspelled  words.   The  byte  at  0103H
  141. contains   the  marking  character.   Byte  0104H  contains  the
  142. "default disk" [1 for A: , 2 for B: etc].  In  the  distribution
  143. version of SPELL, the bytes are 0 and 1 [default is NULL and A:]
  144. .   EDFILE,  PATCH  or  DDT  or  another debugger can be used to
  145. change the bytes at 0103H, 0104H.  Octal 23 - '#' is a tolerable
  146. marking character for FinalWord.
  147.  
  148. 5.  PROGRAM AND DICTIONARY CHARACTERISTICS
  149.  
  150. 5.1 Word identification algorithm
  151.  
  152.      A  word  is  any  uninterrupted  sequence  of  letters  and
  153. apostrophes, which does not begin or  end  with  an  apostrophe.
  154. Any  punctuation,  digit,  or control character separates words.
  155. Any word consisting of a single letter, or any  word  more  than
  156. 40 letters long, is considered to be correctly spelled.
  157.  
  158. 5.2  Dictionary policy
  159.  
  160.      It  is  the  policy  of  this  program  to contain only one
  161. spelling of a word, even if ordinary dictionaries show  two   or
  162. more  "acceptable"  spellings.   Hence, the dictionary  contains
  163. LABELED and LABELING,  but  not  LABELLED  or  LABELLING,   even
  164. though  all  four are actually acceptable.  The intention  is to
  165. enforce uniformity within each document.  The author  apologizes
  166. for the restriction  on  creativity  and  diversity   that  this
  167. necessitates,  but believes that it is the best policy  for this
  168. program.
  169.  
  170.      The  dictionary  contains many technical and computer terms
  171. such as MICROPROGRAM and DEBUGGER, but does not contain  extreme
  172. jargon  words  such  as  CONTROLIFY  or  VALRET.  The dictionary
  173. contains no proper names  other  than  names  of  countries  and
  174. states  of  the  United  States.  The reason is that it would be
  175. virtually impossible to contain all of  the  proper  names  that
  176. commonly  arise  in  normal use.  Users should keep proper names
  177. (and other correctly spelled words) that arise in their own work
  178. in private dictionaries to avoid having to repeatedly tell SPELL
  179. to accept them.
  180.  
  181.      The dictionary is significantly smaller than that found  in
  182. other  spelling checkers, such as the DEC TOPS-20 program.   The
  183. author believes that the larger dictionary would not reduce  the
  184. number of false misspelling indications by very much.
  185.  
  186.  
  187.  
  188.                                 3
  189.  
  190.  
  191.  
  192. [Note:  I  believe  that this dictionary is actually MUCH larger
  193. than any dictionaries currently  available  for  microcomputers.
  194. -Michael]
  195.  
  196. 5.3  Dictionary flags
  197.  
  198.      Words in SPELL's main dictionary (but not the other dictio-
  199. naries)  may  have  flags  associated  with them to indicate the
  200. legality of suffixes without the need to keep the full  suffixed
  201. words  in  the dictionary.  The flags have "names" consisting of
  202. single letters.  Their meaning is as follows:
  203.  
  204. Let  #  and  @  be  "variables"  that  can stand for any letter.
  205. Upper case letters are constants.  "..."  stands for any  string
  206. of zero or more letters, but note that no word may  exist in the
  207. dictionary which is not  at  least  2  letters  long,  so,   for
  208. example,  FLY  may  not  be produced by placing the "Y" flag  on
  209. "F".  Also, no  flag  is  effective  unless  the  word  that  it
  210. creates  is  at  least 4 letters long, so, for example, WED  may
  211. not be produced by placing the "D" flag on "WE".
  212.  
  213. "V" flag:
  214.         ...E --> ...IVE  as in CREATE --> CREATIVE
  215.         if # .ne. E, ...# --> ...#IVE  as in PREVENT --> PREVENTIVE
  216.  
  217. "N" flag:
  218.         ...E --> ...ION  as in CREATE --> CREATION
  219.         ...Y --> ...ICATION  as in MULTIPLY --> MULTIPLICATION
  220.         if # .ne. E or Y, ...# --> ...#EN  as in FALL --> FALLEN
  221.  
  222. "X" flag:
  223.         ...E --> ...IONS  as in CREATE --> CREATIONS
  224.         ...Y --> ...ICATIONS  as in MULTIPLY --> MULTIPLICATIONS
  225.         if # .ne. E or Y, ...# --> ...#ENS  as in WEAK --> WEAKENS
  226.  
  227. "H" flag:
  228.         ...Y --> ...IETH  as in TWENTY --> TWENTIETH
  229.         if # .ne. Y, ...# --> ...#TH  as in HUNDRED --> HUNDREDTH
  230.  
  231. "Y" FLAG:
  232.         ... --> ...LY  as in QUICK --> QUICKLY
  233.  
  234. "G" FLAG:
  235.         ...E --> ...ING  as in FILE --> FILING
  236.         if # .ne. E, ...# --> ...#ING  as in CROSS --> CROSSING
  237.  
  238. "J" FLAG"
  239.         ...E --> ...INGS  as in FILE --> FILINGS
  240.         if # .ne. E, ...# --> ...#INGS  as in CROSS --> CROSSINGS
  241.  
  242. "D" FLAG:
  243.         ...E --> ...ED  as in CREATE --> CREATED
  244.         if @ .ne. A, E, I, O, or U,
  245.                 ...@Y --> ...@IED  as in IMPLY --> IMPLIED
  246.         if # .ne. E or Y, or (# = Y and @ = A, E, I, O, or U)
  247.  
  248.  
  249.                                 4
  250.  
  251.  
  252.  
  253.                 ...@# --> ...@#ED  as in CROSS --> CROSSED
  254.                                 or CONVEY --> CONVEYED
  255.  
  256. "T" FLAG:
  257.         ...E --> ...EST  as in LATE --> LATEST
  258.         if @ .ne. A, E, I, O, or U,
  259.                 ...@Y --> ...@IEST  as in DIRTY --> DIRTIEST
  260.         if # .ne. E or Y, or (# = Y and @ = A, E, I, O, or U)
  261.                 ...@# --> ...@#EST  as in SMALL --> SMALLEST
  262.                                 or GRAY --> GRAYEST
  263.  
  264. "R" FLAG:
  265.         ...E --> ...ER  as in SKATE --> SKATER
  266.         if @ .ne. A, E, I, O, or U,
  267.                 ...@Y --> ...@IER  as in MULTIPLY --> MULTIPLIER
  268.         if # .ne. E or Y, or (# = Y and @ = A, E, I, O, or U)
  269.                 ...@# --> ...@#ER  as in BUILD --> BUILDER
  270.                                 or CONVEY --> CONVEYER
  271.  
  272. "Z FLAG:
  273.         ...E --> ...ERS  as in SKATE --> SKATERS
  274.         if @ .ne. A, E, I, O, or U,
  275.                 ...@Y --> ...@IERS  as in MULTIPLY --> MULTIPLIERS
  276.         if # .ne. E or Y, or (# = Y and @ = A, E, I, O, or U)
  277.                 ...@# --> ...@#ERS  as in BUILD --> BUILDERS
  278.                                 or SLAY --> SLAYERS
  279.  
  280. "S" FLAG:
  281.         if @ .ne. A, E, I, O, or U,
  282.                 ...@Y --> ...@IES  as in IMPLY --> IMPLIES
  283.         if # .eq. S, X, Z, or H,
  284.                 ...# --> ...#ES  as in FIX --> FIXES
  285.         if # .ne. S, X, Z, H, or Y, or (# = Y and @ = A, E, I, O, or U)
  286.                 ...# --> ...#S  as in BAT --> BATS
  287.                                 or CONVEY --> CONVEYS
  288.  
  289. "P" FLAG:
  290.         if @ .ne. A, E, I, O, or U,
  291.                 ...@Y --> ...@INESS  as in CLOUDY --> CLOUDINESS
  292.         if # .ne. Y, or @ = A, E, I, O, or U,
  293.                 ...@# --> ...@#NESS  as in LATE --> LATENESS
  294.                                 or GRAY --> GRAYNESS
  295.  
  296. "M" FLAG:
  297.         ... --> ...'S  as in DOG --> DOG'S
  298.  
  299. Note:  The  existence  of a flag on a root word in the directory
  300. is not by itself sufficient to  cause  SPELL  to  recognize  the
  301. indicated  word  ending.   If  there  is  more than one root for
  302. which a flag will indicate a given word, only one of  the  roots
  303. is the correct one for which the flag is effective; generally it
  304. is  the  longest  root.   For example, the "D" rule implies that
  305. either PASS or PASSE, with a "D" flag, will yield  PASSED.   The
  306. flag must be on PASSE; it will be ineffective on PASS.  This  is
  307. because, when SPELL encounters the word PASSED and fails to
  308.  
  309.  
  310.                                 5
  311.  
  312.  
  313.  
  314. find  it  in its dictionary, it strips off the "D" and looks  up
  315. PASSE.  Upon finding PASSE, it then accepts PASSED if and   only
  316. if  PASSE  has  the  "D" flag.  Only if the word PASSE is not in
  317. the main dictionary at all does the program strip  off  the  "E"
  318. and  search  for  PASS.  Furthermore, some combinations of flags
  319. are forbidden to allow for dense flag encoding  to  save  space.
  320. For example, only one of the "P", "J", or "V" flags may be on in
  321. any one word.
  322.  
  323. 6.  SPELL INTERNALS
  324.  
  325.      SPELL  uses  a  number of temporary files during execution.
  326. The file file.D$$ is the union of file.UDC and file.ADD.  At the
  327. end of execution, file.UDC and file.ADD are deleted and file.D$$
  328. is renamed to file.UDC.  The file file.$$$ is the  output  file.
  329. At  the end of execution, file.BAK is deleted, the input file is
  330. renamed to file.BAK, and file.$$$ is renamed to the  input  file
  331. name.   Warning:  if  you  do  not  have  room  on your disk for
  332. file.BAK, file.DOC and file.$$$ at the same time, either use two
  333. drives or delete file.BAK before you start.
  334.  
  335.      SPELL corrects files with two passes of the input file.  On
  336. the  first pass, the words in the file are sorted alphabetically
  337. and duplicate words are eliminated.  An attempt is then made  to
  338. search  for  the  words in the dictionary.  Words that are found
  339. are marked.  On  the  second  pass  of  the  input  file,  SPELL
  340. determines  whether  each  word  was  found  by locating them in
  341. memory.  This method makes the operation of SPELL more efficient
  342. because common words must be looked up only once and because the
  343. dictionary can be searched sequentially,  minimizing  disk  head
  344. travel.   If all of the file does not fit in memory on the first
  345. pass, the input file is partitioned into sections  small  enough
  346. to fit into memory and is then corrected in a series of two pass
  347. operations  until  the  entire  file  has  been  checked.  It is
  348. unlikely that memory will be filled in  large  systems  by  even
  349. large text files as 3000 individual words should fit easily.
  350.  
  351. 7.  DICTIONARY INTERNALS
  352.  
  353.      The dictionary has been compressed, significantly, in order
  354. to  save  space.   Dictionary records are all 256 bytes long and
  355. each record contains as many  words  as  will  fit.   Individual
  356. words  are stored in the following code:
  357.  
  358.      4 bits -- Number  of  characters to copy from  the  previous 
  359.                word.    Because  the  dictionary  is  stored   in 
  360.                alphabetical  order,  this saves a large number of 
  361.                characters.   This field is 0 at the beginning  of 
  362.                each record.
  363.  
  364.  x * 5 bits -- Characters are stored in 5 bit code.  There may be 
  365.                any  number  of  5 bit  characters.   A  character 
  366.                string is terminated by the following field.
  367.  
  368.      3 bits -- Set to 111 binary to indicate the end of the word.  
  369.  
  370.  
  371.                                 6
  372.  
  373.  
  374.  
  375.                Since  11100  binary  is  greater  than  26,   all 
  376.                alphabetic characters can be stored without  using 
  377.                this combination.
  378.  
  379.      4 bits -- Number  of  bits of flag data following the  word.  
  380.                The bit position of the flags has been ordered  so 
  381.                that  the flags most frequently used are earliest.  
  382.                Flags not stored are assumed to be off.
  383.  
  384.      x bits -- Flag data.  x is determined by the previous field.  
  385.                Each bit represents one of the 14 suffix flags.
  386.  
  387. 8.  MODIFYING THE MAIN DICTIONARY
  388.  
  389.      The  source  for the main dictionary can currently be found
  390. in the file "[MIT-XX]SRC:<WBA>SPELL.DCT".  In order to  make  it
  391. compatible  with  SPELL,  all of the "/" characters that delimit
  392. flags must be converted to "%" characters so that flags will  be
  393. considered earlier in the alphabet than hyphens (DOG%S should be
  394. before DOG'S).  The file must then be sorted alphabetically.  No
  395. utilities  are provided with SPELL to accomplish either of these
  396. tasks.  Without high capacity  disk  drives,  you  may  find  it
  397. necessary to perform the above steps on a larger computer.
  398.  
  399.      Once  a  copy of the main dictionary has been placed on the
  400. microcomputer, use the program DICCRE to  create  a  dictionary.
  401. Include  the name of the source file on the DICCRE command line.
  402. DICCRE will create the files  DICT.DIC  (compressed  dictionary)
  403. and  SPELL0.MAC (pointer file to dictionary) ON THE DEFAULT DISK
  404. DRIVE.   When  it  has finished converting the input file to the
  405. dictionary file, it will execute a warm boot if the output  file
  406. is  on the same drive as the input file.  However, if the output
  407. file is not on the same disk, it will ask whether another  input
  408. file  exists.   This  feature  allows the user to put the source
  409. file  on two disks in case it does not fit on one.  DICCRE  will
  410. combine  them into one dictionary file.  If no more files exist,
  411. answer  N  to the question.  If another file does exist, put the
  412. disk with  the new file in the input drive and type Y.
  413.  
  414.      After the dictionary file has been created, it is necessary
  415. to  recompile  SPELL  with the new pointer file, SPELL0.MAC.  If
  416. your assembler does not support the INCLUDE statement, you  will
  417. have  to  replace  the  line  INCLUDE  SPELL0.MAC  in  the  file
  418. SPELL.MAC  with the contents  of  SPELL0.MAC.   After  SPELL  is
  419. recompiled, be  sure to use the correct copy of DICT.DIC with it
  420. or you will  obtain unpredictable results.
  421.  
  422.      For more information about dictionaries, see the file:
  423.           [MIT-XX]SS:<WBA>DICT.LETTER
  424.  
  425. Good luck and happy hacking!
  426.  
  427. Michael Adler       (MADLER@MIT-ML)
  428. 3 Sunny Knoll Terrace
  429. Lexington, MA  02173
  430. will  obtain unpredictable results.
  431.  
  432.      For more information about dictionaries, see the fi