#!/bin/csh
#
#  AddAnnotations - Generates database of annotations to the Gatherer's
#  data, then incorporates the changes into the Gatherer's database.
#

#  If you don't run with HARVEST_HOME already set, then hard-code it here
if ($?HARVEST_HOME == 0) then
	setenv HARVEST_HOME /usr/local/harvest
endif

#  Set some information about the Gatherer
set gid = "bruno.cs.colorado.edu:8519"
set gdir = "$HARVEST_HOME/gatherers/cucs"


#  We need the Harvest binaries, the Cache binaries, the Gatherer binaries,
#  and the programs local to the Gatherer
set path = (	$HARVEST_HOME/bin \
		$HARVEST_HOME/lib/cache \
		$HARVEST_HOME/lib/gatherer \
		$gdir/bin \
		$path)

#  This is the Gatherer's directory
cd $gdir

#  Retrieve the needed datafile via the Cache
set t = "/tmp/annotate.$$"
client -r -c cache 'http://www.cs.colorado.edu/faculty/faculty.html' > $t

#  Generate the annotations
rm -f data/MANUAL.gdbm
gdbmutil keys data/INDEX.gdbm | staff-SOIF $t | template2db data/MANUAL.gdbm
rm -f $t

#  Merge the annotations with the PRODUCTION database
rm -f data/WORKING.gdbm
mergedb data/WORKING.gdbm data/PRODUCTION.gdbm data/MANUAL.gdbm
rm -f data/PRODUCTION.gdbm

#  Incorporate the annotations into the Gatherer's database for export
folddb $gid $gdir/data

#  done
exit 0
