Simple indexer for help system
Bill Gribble
grib@gnumatic.com
Wed, 13 Dec 2000 17:42:49 -0600
I wrote this dirt stupid script to build a searchable index for our
help files. The idea would be that it would be run at compile time to
allow runtime keyword searches.
Any reason y'all see why it couldn't actually be refined to the point
of being useful (it's really just a toy) and be used in gnucash?
b.g.
#! /bin/bash
rm -f /tmp/tmpindex /tmp/tmpkeys
# match word occurrences to files
for i in "$@" ;
do
cat $i | sed -e "s/<[^>]*>//g"| tr \",\(\)\;\&\<\>\!\$\* ' ' |
tr -s ' ' '\n' | tr -d [:blank:] |
tr [:upper:] [:lower:] | sed -e "s/^..$//g" | sed -e "s/^.$//g" |
grep -E "^.+$" | sed -e 's/\. *$//g' | sed -e 's/: *$//g' |
sed -e s/^\'//g | sed -e s/\'$//g |
sed -e s/\$/\ $i/g | sort | uniq >> /tmp/tmpindex
done
# extract the keys
cat /tmp/tmpindex | sed -e "s/^\([^ ]*\) .*$/\1/" | sort | uniq > /tmp/tmpkeys
# build the index
echo "building db..."
rm -f p/tmpdb
for i in `cat /tmp/tmpkeys`;
do
list=`grep -E ^$i /tmp/tmpindex | sed -e "s/^[^ ]* \(.*\)$/\1/" |
uniq `;
echo $i: $list >> /tmp/tmpdb ;
done