home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d191 / ispell.lha / ISpell / unix.zoo / fixdict.x < prev    next >
Text File  |  1989-02-22  |  3KB  |  82 lines

  1. #!/bin/sh
  2. #
  3. #    Add capitalization information to an ispell dictionary
  4. #
  5. #    Usage:
  6. #
  7. #    fixdict dict-file
  8. #
  9. #    Requires availability of UNIX spell.  The new dictionary is
  10. #    rewritten in place.  A list of words that couldn't be
  11. #    resolved (because spell doesn't know them) is written to
  12. #    standard output.  This list appears in lowercase in the
  13. #    dictionary, and if there are any errors the must be edited
  14. #    by hand.
  15. #
  16. #    The final dictionary appears in expanded form and must be
  17. #    passed through munchlist to regenerate suffixes.
  18. #
  19. LIBDIR=!!LIBDIR!!
  20. EXPAND1=${LIBDIR}/isexp1.sed
  21. EXPAND2=${LIBDIR}/isexp2.sed
  22. EXPAND3=${LIBDIR}/isexp3.sed
  23. EXPAND4=${LIBDIR}/isexp4.sed
  24.  
  25. # TDIR=${TMPDIR:-/tmp}
  26. TDIR=/tmp
  27. TMP=${TDIR}/fix$$
  28.  
  29. trap "/bin/rm -f ${TMP}*; exit 1" 1 2 15
  30. sed -f ${EXPAND1} $1 | sed -f ${EXPAND2} \
  31.   | sed -f ${EXPAND3} | sed -f ${EXPAND4} \
  32.   | tr '[A-Z]' '[a-z]' \
  33.   | spell \
  34.   | sort > ${TMP}a
  35. #
  36. # ${TMP}a contains all the words that spell doesn't like.
  37. # Now figure out which of those are because spell doesn't know them at
  38. # all, and leave those in ${TMP}b.
  39. #
  40. tr '[a-z]' '[A-Z]' < ${TMP}a | spell | tr '[A-Z]' '[a-z]' > ${TMP}b
  41. #
  42. # The wrongly-capitalized words are those that spell didn't object to
  43. # in the last step.  Produce a list of them in, and capitalize the
  44. # first letter of each.  Save this list in ${TMP}c.
  45. #
  46. comm -23 ${TMP}a ${TMP}b \
  47.   | sed 's/^a/A/;s/^b/B/;s/^c/C/;s/^d/D/;s/^e/E/;s/^f/F/;s/^g/G/;s/^h/H/
  48.      s/^i/I/;s/^j/J/;s/^k/K/;s/^l/L/;s/^m/M/;s/^n/N/;s/^o/O/;s/^p/P/
  49.      s/^q/Q/;s/^r/R/;s/^s/S/;s/^t/T/;s/^u/U/;s/^v/V/;s/^w/W/;s/^x/X/
  50.      s/^y/Y/;s/^z/Z/' > ${TMP}c
  51. #
  52. # Find out which of those spell objects to, saving the failures in ${TMP}d.
  53. #
  54. spell ${TMP}c > ${TMP}d
  55. #
  56. # Extract the words which were correctly capitalized at the first letter,
  57. # combine them with an all-capitals version of the ones that weren't, and
  58. # put the result into ${TMP}e.
  59. #
  60. (comm -23 ${TMP}c ${TMP}d;  tr '[a-z]' '[A-Z]' < ${TMP}d) \
  61.   | sort -o ${TMP}e
  62. #
  63. # At this point, ${TMP}b contains the words that spell just plain doesn't
  64. # like, and ${TMP}e contains the words that are now capitalized correctly.
  65. #
  66. /bin/rm ${TMP}[cd]
  67. #
  68. # Put it all together, rewriting the dictionary in place.
  69. #
  70. sed -f ${EXPAND1} $1 | sed -f ${EXPAND2} \
  71.   | sed -f ${EXPAND3} | sed -f ${EXPAND4} \
  72.   | tr '[A-Z]' '[a-z]' \
  73.   | sort \
  74.   | comm -23 - ${TMP}a \
  75.   | sort -f -o $1 - ${TMP}b ${TMP}e
  76. #
  77. # Finally, write the list of words that have questionable capitalization
  78. # to the standard output.
  79. #
  80. cat ${TMP}b
  81. /bin/rm ${TMP}*
  82.