home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume23 / quranref / part07 < prev    next >
Encoding:
Text File  |  1991-10-19  |  32.2 KB  |  829 lines

  1. Newsgroups: comp.sources.misc
  2. From: goer@midway.uchicago.edu (Richard L. Goerwitz)
  3. Subject:  v23i073:  quranref - Holy Qur'an word and passage based retrievals, Part07/08
  4. Message-ID: <1991Oct19.022351.13129@sparky.imd.sterling.com>
  5. X-Md4-Signature: 89c73d8d8777b3e215c99bf7a5c5a2d6
  6. Date: Sat, 19 Oct 1991 02:23:51 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: goer@midway.uchicago.edu (Richard L. Goerwitz)
  10. Posting-number: Volume 23, Issue 73
  11. Archive-name: quranref/part07
  12. Environment: Icon
  13.  
  14. ---- Cut Here and feed the following to sh ----
  15. #!/bin/sh
  16. # this is quranref.07 (part 7 of a multipart archive)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file makeind.icn continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 7; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test ! -f _shar_wnt_.tmp; then
  33.     echo 'x - still skipping makeind.icn'
  34. else
  35. echo 'x - continuing file makeind.icn'
  36. sed 's/^X//' << 'SHAR_EOF' >> 'makeind.icn' &&
  37. X        how_many_bitmaps :=    ior(*inverse_set, inverse_signal)
  38. X        write_int(outbitmaps, how_many_bitmaps, bits_needed)
  39. X        every write_int(outbitmaps, !inverse_set, bitmap_length)
  40. X    } else {
  41. X        # ...otherwise (if we have a reasonable number of keys), store
  42. X        # the locations "straight" and don't set the inverse_signal bit.
  43. X        write_int(outbitmaps, how_many_bitmaps, bits_needed)
  44. X        # Having written the bitmap count, now write the bitmaps proper
  45. X        # to the bitmap file.
  46. X        if index_lst[i] == ""
  47. X        then
  48. X          # Bitmaps for "" are guaranteed to be sorted.
  49. X          every write_int(outbitmaps, !sort(index_lst[i+1]),bitmap_length)
  50. X        else
  51. X          every write_int(outbitmaps, !index_lst[i+1], bitmap_length)
  52. X    }
  53. X    }
  54. X
  55. X    # Close files.  Return number of keys processed (any better ideas??)
  56. X    every close(outtokens | outbitmaps)
  57. X    return *index_lst / 2    # return number of keys in index file
  58. X
  59. Xend
  60. X
  61. X
  62. X#
  63. X# store_bitmaps_and_offsets
  64. X#
  65. X# Open the original text file (backup_file).  Read in bitmaps and
  66. X# write out compressed texts to fname.  Write out bitmaps and the
  67. X# offsets of the text they go with in fname to the .UNT file.  Store
  68. X# locations of bitmaps in the UNT file to the .OFS file.  Note that
  69. X# the full bitmap is not stored.  Rather only the first upto_field
  70. X# fields are stored.  Normally upto_field = IS.no - 1.  The scheme is
  71. X# thus as follows: bitmap -> .OFS file -> .UNT file -> main text file.
  72. X# The OFS file is read into memory at run-time, and stores only the
  73. X# locations of major blocks in the .UNT file.  The .UNT file has a
  74. X# full list of pointers into the main text file, and once a bitmap
  75. X# is located there, the exact location for it in the main file can
  76. X# be retrieved.
  77. X#
  78. Xprocedure store_bitmaps_and_offsets(fname, unt_fname, backup_fname,
  79. X      upto_field, huffman_table)
  80. X
  81. X    local last_major_division, major_division, bitmap_offset_table,
  82. X    out_compress, in_main_text, out_locations, location, firstline,
  83. X    line, value
  84. X
  85. X    out_compress := open(fname, "w")
  86. X    out_locations := open(unt_fname, "w")
  87. X    in_main_text := open(backup_fname) |
  88. X    abort("store_bitmaps_and_offsets","can't open "||backup_fname,5)
  89. X    bitmap_offset_table := table()
  90. X
  91. X    last_major_division := -1    # initialize to an impossible value
  92. X    until match("::", firstline := read(in_main_text))
  93. X    every line := (firstline | !in_main_text) do {
  94. X    line ? {
  95. X        if not ="::" then
  96. X        value ||:= line || "\n"
  97. X        else {
  98. X        location := tab(0)
  99. X        major_division :=
  100. X            ishift(digits_2_bitmap(location),
  101. X               -((IS.no - upto_field) * IS.len))
  102. X        if last_major_division ~= major_division
  103. X        then {
  104. X            # Write to the bitmap offset table the major division,
  105. X            # and then our position in the UNT file (which records
  106. X            # the locations for all bitmaps).
  107. X            insert(bitmap_offset_table, major_division,
  108. X               where(out_locations))
  109. X            last_major_division := major_division
  110. X        }
  111. X        # Write compressed text to original filename; then write
  112. X        # the current location marker to the UNT file, followed by
  113. X        # our position in out_compress (i.e. the place where the
  114. X        # next block of compressed text will begin).
  115. X        \value & writes(out_compress,
  116. X            block_encode(trim(value,"\n"), huffman_table)) |
  117. X                # We should abort with an I/O error if there is no
  118. X                # on the device.  I ran into a problem, though, in
  119. X                # which writes were repeatedly attempted to a full
  120. X            # filesystem.
  121. X                abort("store_bitmaps...", "can't write to "|| fname, 6)
  122. X        write(out_locations, location, "\t", where(out_compress))
  123. X        value := ""
  124. X        }
  125. X    }
  126. X    }
  127. X
  128. X    \value & writes(out_compress,
  129. X    block_encode(trim(value,"\n"), huffman_table)) |
  130. X        abort("store_bitmaps...", "can't write to "|| fname, 6)
  131. X    writes(out_compress, block_encode(trim(\value,"\n"), huffman_table))
  132. X    every close(in_main_text | out_compress | out_locations)
  133. X    return bitmap_offset_table
  134. X
  135. Xend
  136. X
  137. X
  138. X#
  139. X# write_bitmaps_and_offsets
  140. X#
  141. X# Does the actual writing of bitmaps and offsets to a file.  Receives
  142. X# a table of bitmaps cut down to upto_field fields.  Shinking the
  143. X# bitmaps lessens the size of the resulting file, but requires a bit
  144. X# more I/O when it comes time to look something up.
  145. X#
  146. Xprocedure write_bitmaps_and_offsets(ofs_filename, t, upto_field)
  147. X
  148. X    local outtext, tmp_list, i, offset_length,
  149. X    block_size, stored_bitmap_length
  150. X
  151. X    outtext := open(ofs_filename, "w") |
  152. X    abort("write_bitmaps_and_offsets","can't open "||ofs_filename,5)
  153. X    stored_bitmap_length := ((IS.len * upto_field) <= seq(0,8))
  154. X    tmp_list := sort(t, 3)
  155. X
  156. X    every i := 1 to *tmp_list-1 by 2 do {
  157. X
  158. X    # Number of bits needed to hold offset.
  159. X    offset_length := (*exbase10(tmp_list[i+1], 2) <= seq(0,8))
  160. X    # Number of bytes needed to hold bitmap and offset (both).
  161. X    block_size := (stored_bitmap_length + offset_length) / 8
  162. X
  163. X    # We could just code the length of the offset, since the bitmap's
  164. X    # length is fixed (and known).  Seems better to code the block's
  165. X    # total length just in case something gets screwed up.  An 8-bit
  166. X    # limit means the bitmap+offset length cannot exceed 2^9-1 (255)
  167. X    # characters.
  168. X    if block_size > 255 then
  169. X        abort("write_bitmaps_and_offsets","bitmap+offset too big",15)
  170. X    write_int(outtext, block_size, 8)
  171. X    write_int(outtext, tmp_list[i], stored_bitmap_length)
  172. X    write_int(outtext, tmp_list[i+1], offset_length)
  173. X
  174. X    }
  175. X
  176. X    return
  177. X
  178. Xend
  179. X
  180. X
  181. X#
  182. X# write_limits
  183. X#
  184. X# Writes out the bitmaps that will be needed in order for expandrf()
  185. X# to be able to know when the rollover field rolls over.
  186. X#
  187. Xprocedure  write_limits(out_fname, in_fname, r_field)
  188. X
  189. X    local in, out, shift_bits_out, bitmap_length, bitmaps_read,
  190. X     line, bitmap, short_bitmap, old_bitmap
  191. X
  192. X    in := open(in_fname) |
  193. X    abort("write_limits","can't open "||in_fname,5)
  194. X    out := open(out_fname, "w") |
  195. X    abort("write_limits","can't open "||out_fname,5)
  196. X    r_field <= IS.no |
  197. X    abort("write_limits","-l value should not exceed that of -n",50)
  198. X    shift_bits_out := -(((IS.no-r_field)+ 1) * IS.len)
  199. X    bitmap_length := ((IS.len * IS.no) <= seq(0,8))
  200. X    bitmaps_read := 0
  201. X
  202. X    while line := read(in) do {
  203. X    line ? {
  204. X        bitmaps_read +:= 1
  205. X        bitmap := digits_2_bitmap(tab(find("\t"))) # in indexutl.icn
  206. X        short_bitmap := ishift(bitmap, shift_bits_out)
  207. X        if ishift(\old_bitmap, shift_bits_out) ~== short_bitmap
  208. X        then write_int(out, old_bitmap, bitmap_length)
  209. X        old_bitmap := bitmap
  210. X    }
  211. X    }
  212. X
  213. X    write_int(out, \old_bitmap, bitmap_length)
  214. X    every close(in | out)
  215. X    return bitmaps_read
  216. X            
  217. Xend
  218. SHAR_EOF
  219. echo 'File makeind.icn is complete' &&
  220. true || echo 'restore of makeind.icn failed'
  221. rm -f _shar_wnt_.tmp
  222. fi
  223. # ============= gettokens.icn ==============
  224. if test -f 'gettokens.icn' -a X"$1" != X"-c"; then
  225.     echo 'x - skipping gettokens.icn (File already exists)'
  226.     rm -f _shar_wnt_.tmp
  227. else
  228. > _shar_wnt_.tmp
  229. echo 'x - extracting gettokens.icn (Text)'
  230. sed 's/^X//' << 'SHAR_EOF' > 'gettokens.icn' &&
  231. X############################################################################
  232. X#
  233. X#    Name:     gettokens.icn
  234. X#
  235. X#    Title:     get tokens from text-base file
  236. X#
  237. X#    Author:     Richard L. Goerwitz
  238. X#
  239. X#    Version: 1.2
  240. X#
  241. X############################################################################
  242. X#
  243. X#  Tokenizing routine used by makeind.icn to create index.
  244. X#
  245. X############################################################################
  246. X#
  247. X#  See also: ./makeind.icn
  248. X#
  249. X#############################################################################
  250. X
  251. X# declared in ./indexutl.icn (q.v.)
  252. X# global IS
  253. X#
  254. X# One idea for gettokens, good for small indices.  Uses field separator
  255. X# (IS.FS).  Also uses (slow) findre.  Farther below is a less flexible
  256. X# version of gettokens which runs faster.
  257. X#
  258. X#procedure gettokens(is_case_sensitive)
  259. X#
  260. X#    # Used within a scanning expression.  Returns tokens in
  261. X#    # &subject[&pos:0] (&pos normally = 1).  Tokens are stretches of
  262. X#    # text separated by the IS.FS field separator.  This
  263. X#    # field separator is a nawk style FS regular expression.  If null,
  264. X#    # it gets defined as ~(&digits++&letters).
  265. X#
  266. X#    local token
  267. X#    static non_alphanums
  268. X#    initial non_alphanums := ~(&digits ++ &letters ++ '-')
  269. X#
  270. X#    /IS.FS := non_alphanums
  271. X#    
  272. X#    while token := tab(findre(IS.FS)) do {
  273. X#    tab(__endpoint)
  274. X#    tab(many('\''))        # unfortunate by-product of findre's weakness
  275. X#    if \is_case_sensitive
  276. X#    then suspend "" ~== trim(token,'\t ')
  277. X#    else suspend map("" ~== trim(token,'\t '))
  278. X#    }
  279. X#
  280. X#    # Return the rest of &subject.  Even though we're not tabbing
  281. X#    # upto FS, this is normally what the user intends.
  282. X#    if \is_case_sensitive
  283. X#    then return "" ~== trim(tab(0),'\t ')
  284. X#    else return map("" ~== trim(tab(0),'\t '))
  285. X#
  286. X#end
  287. X
  288. Xprocedure gettokens(is_case_sensitive)
  289. X
  290. X    # Used within a scanning expression.  Returns tokens in
  291. X    # &subject[&pos:0] (&pos normally = 1).  Tokens are stretches of
  292. X    # text separated by an optional apostrophe or dash, then any
  293. X    # stretch of non-alphanumeric characters, then an optional apos-
  294. X    # trophe.
  295. X
  296. X    local token
  297. X    static alphanums, wordchars
  298. X    initial {
  299. X    alphanums := &digits ++ &letters ++ '-'
  300. X    wordchars := alphanums ++ '\''
  301. X    }
  302. X
  303. X    tab(upto(alphanums))
  304. X    while token := tab(many(wordchars)) do {
  305. X    if \is_case_sensitive
  306. X    then suspend "" ~== trim(token,'\t \'-')
  307. X    else suspend map("" ~== trim(token,'\t \'-'))
  308. X    tab(upto(alphanums))
  309. X    }
  310. X
  311. Xend
  312. SHAR_EOF
  313. true || echo 'restore of gettokens.icn failed'
  314. rm -f _shar_wnt_.tmp
  315. fi
  316. # ============= Makefile.dist ==============
  317. if test -f 'Makefile.dist' -a X"$1" != X"-c"; then
  318.     echo 'x - skipping Makefile.dist (File already exists)'
  319.     rm -f _shar_wnt_.tmp
  320. else
  321. > _shar_wnt_.tmp
  322. echo 'x - extracting Makefile.dist (Text)'
  323. sed 's/^X//' << 'SHAR_EOF' > 'Makefile.dist' &&
  324. X##########################################################################
  325. X#
  326. X   PROGNAME = quranref
  327. X#
  328. X##########################################################################
  329. X#
  330. X#  User-modifiable section.  Read carefully!  You will almost
  331. X#  certainly have to change some settings here.
  332. X#
  333. X
  334. X#
  335. X# Destination directory for binaries; library directory for auxiliary
  336. X# files.  Owner and group for public executables.  Leave the trailing
  337. X# slash off of directory names.
  338. X#
  339. XDESTDIR = /usr/local/bin
  340. X# DESTDIR = $(HOME)/bin
  341. XLIBDIR = /usr/local/lib/$(PROGNAME)
  342. X# LIBDIR = $(HOME)/$(PROGNAME)
  343. X# LIBDIR = /usr/local/share/lib/$(PROGNAME)
  344. XOWNER = root #bin
  345. XGROUP = root #bin
  346. X
  347. X#
  348. X# Name of your icon compiler and compiler flags.
  349. X#
  350. XICONC = /usr/icon/v8/bin/icont
  351. X
  352. X# Flags for $(ICONC) (these may vary for different versions and/or
  353. X# implementations).  If you get messages like "out of X table space,"
  354. X# then you will need to adjust these.  Note that they apply only to
  355. X# the interpreter.  Comment everything out but the -u for the
  356. X# compiler.
  357. XIFLAGS = -u -Sc 400 -Sg 400 -Si 2000 -Sn 4000 -SF 40
  358. X
  359. X#
  360. X# Names of Quran files should all be sorted, consisting of a three-
  361. X# digit prefix, followed by a period, and a title.  Cat-ing them is
  362. X# sufficient, since the shell automatically takes them in order.  Use
  363. X# zcat if your files are compressed.  Note that I assume the original
  364. X# distribution and form, as announced in soc.religion.islam by Cary
  365. X# Maguire), and as archived at princeton.edu (pub/Quran.tar.Z).
  366. X#
  367. XCAT = cat [0-9][0-9][0-9].*
  368. X# CAT = zcat [0-9][0-9][0-9].*
  369. X
  370. X#
  371. X# Change these only if you're sure of what you're doing
  372. X#
  373. XSHELL = /bin/sh
  374. XMAKE = make
  375. XSHAR = shar
  376. X
  377. X#
  378. X# Maximum number that any database location field will have to
  379. X# contain.  For a standard Quran, this figure is 286 (the Cow).
  380. X#
  381. XMAXFIELDS = 286
  382. X
  383. X
  384. X###########################################################################
  385. X#
  386. X#  Don't change anything below this line.
  387. X#
  388. X
  389. XRTVFILE = qur.rtv
  390. XCONVERTER = qur2rtv
  391. X
  392. XCONVERTSRC = $(CONVERTER).icn
  393. X
  394. XINDEXER = makeind
  395. XINDEXSRC = $(INDEXER).icn gettokens.icn indexutl.icn huffcode.icn \
  396. X    outbits.icn
  397. X
  398. XDUMMY_FILE = index.done
  399. XMAINFILE = bibleref
  400. X
  401. XSEARCHSRC = $(MAINFILE).icn ref2bmap.icn name2num.icn convertb.icn \
  402. X    listutil.icn passutil.icn readfile.icn srchutil.icn complete.icn \
  403. X    ipause.icn rewrap.icn binsrch.icn bmp2text.icn initfile.icn \
  404. X    retrieve.icn indexutl.icn retrops.icn whatnext.icn iolib.icn \
  405. X    iscreen.icn findre.icn version.icn huffcode.icn inbits.icn
  406. X
  407. Xall: $(DUMMY_FILE) $(PROGNAME)
  408. X
  409. X$(DUMMY_FILE):
  410. X    @echo ""
  411. X    @echo "This may take a while (about 1 minute/MB on a Sun4)."
  412. X    @echo ""
  413. X    @sleep 3
  414. X    $(ICONC) $(IFLAGS) -o $(CONVERTER) $(CONVERTSRC)
  415. X    $(CAT) $(RAWFILES) | $(CONVERTER) > $(RTVFILE)
  416. X    @echo ""
  417. X    @echo "This will take a long time (c. 1 hour/MB on a Sun4)."
  418. X    @echo "Kids, don't even *think* of trying this at home."
  419. X    @echo ""
  420. X    @sleep 3
  421. X    $(ICONC) $(IFLAGS) -o $(INDEXER) $(INDEXSRC)
  422. X    $(INDEXER) -f $(RTVFILE) -m $(MAXFIELDS) -n 2 -l 2
  423. X    @rm -f *.BAK
  424. X    @echo ""
  425. X    @echo "I'm creating a $(DUMMY_FILE) file, indicating that the"
  426. X    @echo "indexing process is done.  Once the data files are moved,"
  427. X    @echo "this file remains, preventing an accidental remake of the"
  428. X    @echo "data files.  If, poor soul, you *want* a total remake, you"
  429. X    @echo 'will need to remove this file (see "clobber" below).'
  430. X    @echo ""
  431. X    @sleep 4
  432. X    touch $(DUMMY_FILE)
  433. X
  434. X$(PROGNAME): $(SEARCHSRC)
  435. X    @echo ""
  436. X    @echo "Compiling main executable, $(PROGNAME)."
  437. X    @echo ""
  438. X    @sleep 2
  439. X    $(ICONC) $(IFLAGS) -o $(PROGNAME) $(SEARCHSRC)
  440. X
  441. X$(MAINFILE).icn: $(MAINFILE).src
  442. X    @echo ""
  443. X    @echo "Hardcoding default datafile path ($(LIBDIR))."
  444. X    @echo ""
  445. X    @sleep 2
  446. X    sed "s|/usr/local/lib/bibleref/kjv.rtv|$(LIBDIR)/$(RTVFILE)|; s|Bible|Quran|g" $(MAINFILE).src > $(MAINFILE).icn
  447. X
  448. X$(CONVERTER): $(CONVERTSRC)
  449. X    $(ICONC) $(IFLAGS) -o $(CONVERTER) $(CONVERTSRC)
  450. X
  451. X$(INDEXER): $(INDEXSRC)
  452. X    $(ICONC) $(IFLAGS) -o $(INDEXER) $(INDEXSRC)
  453. X
  454. X
  455. X##########################################################################
  456. X#
  457. X#  Pseudo-target names (install, clean, clobber)
  458. X#
  459. X#
  460. X
  461. X# Pessimistic assumptions regarding the environment (in particular,
  462. X# I don't assume you have the BSD "install" shell script).
  463. Xinstall: all
  464. X    @echo ""
  465. X    @echo "Creating (if need be) necessary directories, and moving"
  466. X    @echo "executables/data files to their correct locations, with"
  467. X    @echo "the permissions and the ownership you specified in the"
  468. X    @echo "makefile (i.e. $(OWNER))."
  469. X    @echo ""
  470. X    -test -d $(DESTDIR) || mkdir $(DESTDIR) && chmod 755 $(DESTDIR)
  471. X    cp $(PROGNAME) $(DESTDIR)/$(PROGNAME)
  472. X    -chgrp $(GROUP) $(DESTDIR)/$(PROGNAME)
  473. X    -chown $(OWNER) $(DESTDIR)/$(PROGNAME)
  474. X    -test -d $(LIBDIR) || mkdir $(LIBDIR) && chmod 755 $(LIBDIR)
  475. X    mv xxx* $(RTVFILE) $(LIBDIR)/
  476. X    -chgrp $(GROUP) $(LIBDIR)
  477. X    -chown $(OWNER) $(LIBDIR)
  478. X    -chgrp $(GROUP) $(LIBDIR)/xxx* $(LIBDIR)/$(RTVFILE)
  479. X    -chown $(OWNER) $(LIBDIR)/xxx* $(LIBDIR)/$(RTVFILE)
  480. X    @echo ""
  481. X    @echo "Done installing."
  482. X    @echo ""
  483. X
  484. X#
  485. X# Cleanup
  486. X#
  487. Xclean:
  488. X    @echo ""
  489. X    @echo "Minor cleanup underway (major = make clobber)."
  490. X    @echo ""
  491. X    rm -f $(CONVERTER) $(INDEXER) $(PROGNAME)
  492. X
  493. X# Be careful; use this target, and you'll be back to square one.
  494. Xclobber: clean
  495. X    @echo ""
  496. X    @echo "You're in for a complete remake if you do this.  Here"
  497. X    @echo "are the files that will get clobbered (note especially"
  498. X    @echo "the raw Qur'an files):"
  499. X    @echo ""
  500. X    @echo $(RAWFILES) xxx*.??? $(RTVFILE) $(DUMMY_FILE) $(MAINFILE).icn
  501. X    @echo ""
  502. X    @echo 'If you really want a total remake, then make "honestly."'
  503. X    @echo ""
  504. X
  505. Xhonestly:
  506. X    @echo ""
  507. X    @echo "Okay, you asked for it."
  508. X    @echo ""
  509. X    @sleep 4
  510. X    rm -f $(RAWFILES) xxx*.??? $(RTVFILE) $(DUMMY_FILE) $(MAINFILE).icn
  511. SHAR_EOF
  512. true || echo 'restore of Makefile.dist failed'
  513. rm -f _shar_wnt_.tmp
  514. fi
  515. # ============= README ==============
  516. if test -f 'README' -a X"$1" != X"-c"; then
  517.     echo 'x - skipping README (File already exists)'
  518.     rm -f _shar_wnt_.tmp
  519. else
  520. > _shar_wnt_.tmp
  521. echo 'x - extracting README (Text)'
  522. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  523. X--------
  524. X
  525. X
  526. XProgram:  Quranref (built on top of Bibleref, a Bible concordance
  527. X      program archived on cs.arizona.edu [icon/contrib/bible-
  528. X      ref-2.1.tar.Z])
  529. X
  530. XPurpose:  Perform word and passage-based retrievals on the M. H.
  531. X      Shakir's translation of the Holy Qur'an.
  532. X
  533. XLanguage: Icon (ftp-able from cs.arizona.edu [icon/interpreter])
  534. X
  535. XFiles:    qur2rtv.icn bibleref.src convertb.icn listutil.icn
  536. X          name2num.icn passutil.icn readfile.icn ref2bmap.icn
  537. X          srchutil.icn
  538. X
  539. XRequires: Icon version 8, a working, up-to-date Icon Program Library
  540. X      (see below on IPATH), and M. H. Shakir's translation of the
  541. X      Holy Qur'an, as archived by Cary Maguire on princeton.edu
  542. X      (pub/Quran.tar.Z).
  543. X
  544. X
  545. X--------
  546. X
  547. X
  548. XOverview:
  549. X
  550. X    This package, Quranref, offers simple tools for word and
  551. Xpassage-based access to M. H. Shakir's translation of the Holy Qur'an.
  552. XQuranref is quick, and fairly easy to install (assuming you possess
  553. Xthe machine readable text, a sufficiently powerful machine, and know a
  554. Xlittle about Icon).  It will also run with stock terminals - even
  555. Xnasty old ones that leave magic cookies on your screen.  Quranref
  556. Xwill, however, put a bit of a dent in your mass storage resources.
  557. XYour 900k or so Qur'an text will get block Huffman encoded, which will
  558. Xbring it down to about 500k.  The freed space, however, will be
  559. Xgobbled up immediately by some 500k of auxiliary files, and by the
  560. X180k executable (more if you compile, rather than interpret).  In-core
  561. Xrequirements for the executable start at about 300k, and go up from
  562. Xthere (if your searches are complex enough, you could easily eat up a
  563. Xmegabyte or two).  In brief: Quranref enjoys dining on your memory
  564. Xresources.  Once set up, though, it can operate with fairly minimal
  565. Ximpact on the CPU.
  566. X    With Quranref, you can perform most of the more basic,
  567. Xlow-level functions commercial browsing packages offer (and perhaps a
  568. Xfew not found in some of the commercial Qur'an study packages).  You
  569. Xcan, for example,
  570. X
  571. X    -  retrieve any passage by section:verse number
  572. X    -  move forward or backward relative to the retrieved passage
  573. X    -  search the entire Qur'an for words and/or word-patterns
  574. X    -  search for word co-occurrences (or the absence thereof)
  575. X    -  save passages and/or passage-lists for use with an editor
  576. X
  577. XAlthough this program is hardly the product of any major research
  578. Xeffort :-), it should prove sophisticated enough for casual use.  Its
  579. Xmain fault right now is that it relies on a newly scanned text which
  580. Xis positively rife with errors.  The high number of errors is nothing
  581. Xunusual for a text put into machine readable form by current OCR
  582. Xtechnology, so no insult is intended to the people who rendered us
  583. Xthis great service.  It is merely a fact about the current
  584. Xdistribution that should be noted before attempting any serious
  585. Xresearch.
  586. X
  587. X
  588. X--------
  589. X
  590. X
  591. XInstallation:
  592. X
  593. X    The following set-up and installation instructions tacitly
  594. Xassume that you received Quranref as a shell archive, with no prebuilt
  595. Xdata files.  If you snarfed the distribution from an ftp site with the
  596. Xdata files already built, you can skip all the instructions about
  597. Xobtaining and indexing the Princeton scan of M. H. Shakir's Qur'an
  598. Xtext.  If there's any doubt over whether your data files are prebuilt,
  599. Xcheck to see if the file "index.done" exists in your Quranref source
  600. Xdirectory.  If it does, then your data files have already been built.
  601. XOtherwise, you'll need to do a "from scratch" installation.
  602. X    In brief, the setup process consists of the following steps
  603. X(those with prebuilt data files only need to do the starred ones):
  604. X
  605. X    *  make sure Icon is installed & your IPATH variable is set
  606. X    -  ftp the Qur'an from princeton.edu, and unarchive it
  607. X    -  link the Qur'an files to the dir where you unpacked Quranref
  608. X    *  modify the makefile to suit your machine
  609. X    *  make
  610. X
  611. XAlthough I will discuss it below briefly, installation of the Icon
  612. Xprogramming language falls outside the scope of this manual.  I will
  613. Xtherefore begin setup instructions with directions on how to get the
  614. Xnecessary machine-readable text, and on how to set this text up for
  615. Xindexing.
  616. X    In order to obtain the Qur'an text, you must ftp the necessary
  617. Xfiles from princeton.edu.  If you have direct internet connections,
  618. Xjust type "ftp princeton.edu," and when you are asked for a password,
  619. Xtype "anonymous."  Type your e-mail address as your password, and you
  620. Xwill be logged in.  Change to the "pub" directory by typing "cd pub."
  621. XTo retrieve the Qur'an package, type "binary" or "type binary," and
  622. Xthen request a transfer by typing "get Quran.tar.Z".  When the server
  623. Xlets you know the transfer is done, type "bye."  Back at your local
  624. XUNIX machine, unpack the Qur'an files by typing "zcat Quran.tar.Z |
  625. Xtar -xf -" (this will set up a "Quran" directory, and fill it with the
  626. Xappropriate files).  Once you've unpacked the Qur'an files, change
  627. Xyour current directory to the one you unpacked this Quranref
  628. Xdistribution in, and then link or copy the Qur'an files you just
  629. Xunpacked to the current directory (i.e. you must type "ln [-S]
  630. XQuran-directory/* ."; in place of "ln" or "ln -S" you can also use
  631. X"cp").
  632. X    At this point, UNIX novices will probably need some technical
  633. Xhelp, since installing Quranref requires modifying the set-up files,
  634. Xand assumes you know at least something about the UNIX file structure,
  635. Xmakefiles, and operating environment.
  636. X    When finished linking your files to the Quranref source
  637. Xdirectory, locate the Makefile.dist file included with this package
  638. Xand read it.  Copy it to "Makefile."  If you find you must modify any
  639. Xof the user-configurable sections, then edit them as you see fit.  Pay
  640. Xspecial attention to the RAWFILES variable.  Also, be sure to change
  641. XDESTDIR, LIBDIR, USER and GROUP variables to appropriate values for
  642. Xyour machine.  If you are doing a "from scratch" installation, check
  643. Xto be sure that the variable CAT is set to either "cat" or "zcat,"
  644. Xdepending on whether you have compressed the 114 basic text files, or
  645. Xnot.
  646. X    Assuming you've modified the makefile correctly, you can then
  647. Xsimply type "make."  If you are installing from scratch, then you
  648. Xmight as well have lunch.  The entire reformatting, collating, coding,
  649. Xcompressing, end indexing process takes as much as a full three hours
  650. Xon a medium-range workstation.  Don't even *think* of indexing on a
  651. Xsystem with less than 5 meg of core memory and/or a lot of swap space.
  652. XIf you are really savvy about Icon storage management, you can try
  653. Xsetting your regions to have larger values than the defaults.  This
  654. Xwon't cause the indexing program to take up any less RAM.  It may,
  655. Xhowever, decrease the amount of time it takes to index.
  656. X    If you find you get messages like "out of space in X region"
  657. Xor "system stack overflow," then you are probably using an Icon
  658. Ximplementation that doesn't know how to make its own special block and
  659. Xstring regions bigger (e.g. on the NeXT it can't, because Mach doesn't
  660. Xknow about sbrk()).  If the make aborts with such a message, you will
  661. Xneed to set the sizes manually.  Try starting a new shell, and then
  662. Xtyping (assuming [ba|k]sh):
  663. X
  664. X    HEAPSIZE=5000000
  665. X    STRSIZE=1000000
  666. X    export HEAPSIZE STRSIZE
  667. X
  668. XIf you are using (t)csh, then type
  669. X
  670. X    setenv HEAPSIZE=5000000
  671. X    setenv STRSIZE=1000000
  672. X
  673. XYou may need to increase STRSIZE.  Can't hurt, if you have the memory,
  674. Xto set it to some rediculous amount like 5000000.  Otherwise, start
  675. Xlow, and creep up to whatever minimum amount seems needed.  When done,
  676. Xback out of the current shell, or unsetenv these variables.
  677. X    Once you've gotten past the indexing "hump" (which is quite a
  678. Xhump for people starting from scratch), you are free to install.  Su
  679. Xroot first, if you plan on making the executables public, then "make
  680. Xinstall."  Again, be sure the directories and ownership conventions
  681. Xare set correctly in the makefile.
  682. X    Let me emphasize here that Quranref assumes the existence on
  683. Xyour system, not only of Icon interpreter or compiler, but also of an
  684. Xup-to-date Icon Program Library.  There are several routines included
  685. Xin the IPL which Quranref uses.  Make sure the system administrators
  686. X(if "they" are not you :-)) have put the IPL online, and have
  687. Xtranslated the appropriate object modules.  Set your IPATH (or, for
  688. Xthe compiler, LPATH) environment variable to point to the place where
  689. Xthose modules reside, and you should be in business.  Note that I've
  690. Xheard of people having problems with old IPL routines silently
  691. Xfailing, resulting in a truncated .IS file.  Suspect you have fallen
  692. Xvictim to this problem if you get through the installation process
  693. Xfine, and then start Quranref up, only to have it terminate with an
  694. Xerror message and a trace reporting that a null expression was
  695. Xreceived in place of a record.
  696. X    Any IPL material that I've written myself has been packed with
  697. XQuranref, by the way.  I'm constantly tweaking these programs, and I
  698. Xjust want to be sure everyone has the latest version.  IPL programs
  699. Xwritten by other people, though, have not been built into the Quranref
  700. Xdistribution.  If you don't have the IPL, ftp it from cs.arizona.edu
  701. Xalong with the full Icon distribution, and get the updates as well
  702. X(~ftp/icon/library).  If all else fails, write to me and I'll package
  703. Xup the necessary routines for you :-(.  In general, the best solution
  704. Xis simply to keep your Icon run-time and support systems in sync with
  705. Xthe latest revisions from the U. of Arizona.  They are public domain,
  706. Xafter all, and the installation is pretty simple.
  707. X
  708. X
  709. X--------
  710. X
  711. X
  712. XRunning Quranref:
  713. X
  714. X    There is precious little in the way of documentation on
  715. Xrunning Quranref.  This is it.  I wrote the program originally as a
  716. Xtest wrapper to put around some software I'm using for personal
  717. Xresearch purposes.  In this incarnation it functioned as a Bible
  718. Xresearch program for Christians and Jews.  This package was tried out
  719. Xhere at home by my wife and 5 year-old.  The 5 year-old likes to break
  720. Xprograms I write.  Thanks to him, the visual interface had all of the
  721. Xobvious bugs worked out.  Others have checked other features, and have
  722. Xcompared retrieval lists to the listings in paper concordances, and
  723. Xhave found them to be complete.  This program - Quranref - is much
  724. Xless well-tested.  It's a younger program, and the text it's based on
  725. Xhas not been put through a rigorous editing process yet.  Expect the
  726. Xusual growing pains.
  727. X    When it is first invoked, Quranref will print a little message
  728. Xabout initializing one or another of its auxiliary files.  After
  729. Xseveral seconds, this message will disappear - replaced by a prompt
  730. Xwhich asks for a passage reference or "f" (to find a word or
  731. Xword-pattern).
  732. X    If you are interested in looking at a specific passage in the
  733. XQur'an, type it in.  Use the section or chapter number, followed by
  734. Xthe passage or verse number (as in "1:3" or "2:201").  If the passage
  735. Xdoesn't exist, then you'll get an error message (note that some
  736. Xpassages appear to be missing due to scan errors and missing newlines
  737. Xin the scanned text).
  738. X    If want to use Quranref in order to locate a word-pattern,
  739. Xrather than a passage, type "f" and press return at the main command
  740. Xloop.  Just about every command in Quranref is invoked by typing a
  741. Xsingle letter + a carriage return.  It's simple and consistent, and
  742. Xlets me keep the terminal in its normal mode.  If at any time you must
  743. Xtype in additional input, Quranref will ask you for that input.  The
  744. X"f" (find) command is one such case.
  745. X    After you press f+return, Quranref will ask you to input a
  746. Xword.  This "word" can be a simple string.  It can also be an
  747. Xegrep-style pattern:
  748. X
  749. X    (dis|un)?believers?
  750. X    dr[iau]nk.*
  751. X    parable.*
  752. X    etc.
  753. X
  754. XNote that the pattern you specify must match words in their entirety.
  755. XFor instance
  756. X
  757. X    sacrifice
  758. X
  759. Xwill only match "sacrifice."  That is, it will cause Quranref to
  760. Xretrieve only those passages which contain the word "sacrifice."  To
  761. Xcatch "sacrifices," "sacrificed," etc. you need to input a regular
  762. Xexpression which will match this string in full as well (e.g.
  763. X"sacrifice.*").
  764. X    When you are done typing in a word or word-pattern, Quranref
  765. Xwill ask you if you are finished.  If you are, then press the
  766. Xappropriate key ("f"), then hit a carriage return.  In a couple of
  767. Xseconds, you should see a list of passages which contain the word or
  768. Xpattern which you specified (if in fact any such passages were found).
  769. XAlong with this list comes a new set of options, including ! (escape
  770. Xto a shell), a (append the current list to a file), b (back up), c
  771. X(clear and redraw screen), m (view next screen), and several others.
  772. XTry the various options out and see what they do.  Two commands not
  773. Xlisted in the prompt string (which has to be of finite length!) are
  774. X"?" and "/."  With some differences, these do pretty much what UNIX
  775. Xusers expect.  If, say, you have a passage list containing 2000 hits,
  776. Xand you want to find the section where references from the chapter
  777. X"Women" begin, then type in "/4:" (traditionally, this chapter is
  778. Xnumber 4; "4:" will match everything from 4:1 on).
  779. X    While viewing a passage here, or at the top level, you may
  780. Xjump to an arbitrary location by typing in a reference (e.g. "4:5").
  781. XYou may also move to the next passage in the text (+), or move to the
  782. Xprevious one (-).  Finally, you may also either write (w) or append
  783. X(a) the current passage to a file.  Again, try out the various
  784. Xoptions.  When you are done, type "q" and press return.  You will be
  785. Xbrought back to the previous menu, where you can *v*iew another
  786. Xpassage, or quit.
  787. X    At the main menu, you can invoke several additional functions
  788. Xbeyond retrieving specific passages or passage lists.  Quranref keeps
  789. Xa resume of all passage lists you have retrieved, storing it in a
  790. Xglobally accessible structure.  You can look at this structure by
  791. Xtyping "l" (for "list") at the main menu prompt.  From the resulting
  792. Xdisplay menu, you can then *v*iew any of your previous passage lists
  793. X(i.e. "hit lists" resulting from invocation of the *f*ind function).
  794. XWhen you are done, you can once again press "q"+return, and go back to
  795. Xthe top-level command loop.
  796. X    From most of the display menus you can write or append
  797. Xpassages or passage lists to files.  If at any time you wish to reread
  798. Xsuch files back into Quranref, type "r" at the main command prompt.
  799. XYou will then be prompted for a filename.  If the file you name has
  800. Xnot been corrupted somehow, and is in the right format, Quranref will
  801. Xread it in and display it just the way it would the results of a
  802. X*f*ind operation.
  803. X    A final basic function I'd like to mention here is Quranref's
  804. Xfacility for manual display of passage lists.  As was mentioned a few
  805. Xparagraphs before, all your passage lists are all kept in memory, and
  806. Xyou can view the list of available ones by typing "l" at the main
  807. Xprompt.  I'd just like to point out that if this seems too cumbersome,
  808. Xyou can simply type "d" and return.  Quranref will retrieve and
  809. X*d*isplay the last passage list you created.
  810. X    One somewhat under-tested aspect of Quranref's search facility
  811. Xis its ability to handle ranges and Boolean operators in search
  812. Xspecifications.  You can, for instance, execute a *f*ind, using a
  813. Xpattern such as "unbelieve.*".  When asked if you are finished, you
  814. Xcan then respond, not with the normal "f," but rather with an "a" (for
  815. SHAR_EOF
  816. true || echo 'restore of README failed'
  817. fi
  818. echo 'End of  part 7'
  819. echo 'File README is continued in part 8'
  820. echo 8 > _shar_seq_.tmp
  821. exit 0
  822.  
  823. exit 0 # Just in case...
  824. -- 
  825. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  826. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  827. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  828. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  829.