Makefiles

When going through the many steps required to get from a set of queries and a collection through to a table of recall/precision figures, it is useful to have a means of recording these steps. Makefiles, I've found, are a tremendous way of preserving the way an experiment was performed. Using Makefile dependancies can also control what parts of an experimental procedured need to be re-done when a change is made.

For example, look at the following Makefile taken from the 'demo/CACM/' directory.

#
#	Makefile to index and retrieve from the cacm collection
#

#
#	Pull in query and document processing parts
#
include		Make.DocToke
include		Make.QryToke

include		Make.DocTextProcess
include		Make.QryTextProcess



#
#	The default directory for results, can be set on command line
#
ResDir		= results




all:		index retrieve


index:		cacm.dsi cacm.ti queries.dsi

retrieve:	$(ResDir)/res



#
#	If you want to do it again, type 'make again'
#
again:
		touch cacm
		make all ResDir=$(ResDir)

#
#	If you want to clear away all the index files, type 'make clean'
#
clean:
		-rm cacm.dsi cacm.dii
		-rm cacm.ti cacm.dol
		-rm rel_docs/*



#
#	Index the collection
#
cacm.dsi:	cacm Make.DocToke
		cat cacm | $(DocToke) | index_docs cacm cacm - -b -c -s

cacm.ti:	cacm Make.DocToke Make.DocTextProcess
		cat cacm | $(DocToke) | $(DocTextProcess) | index_terms b a cacm 0




#
#	Get relevant documents into correct format
#
rel_docs/*:	qrels
		cat qrels | awk '{print $$1, 0, $$2, 1}' | eval_rel_docs_from_TREC rel_docs



#
#	Do a retrieval
#
$(ResDir)/res:	rel_docs/* cacm.ti cacm.dsi Make.QryToke Make.QryTextProcess

		cat queries | $(QryToke) | $(QryTextProcess) |				\
			retr_rank b cacm cacm -s | eval_tag_rel -s rel_docs/ |		\
			eval_all_rp_from_rel | eval_std11_from_all_rp |			\
			eval_average_from_std11 > $(ResDir)/res

#
#	Place a copy of all Makefiles into results directory
#	so future generations will know how the results were generated.
#
		cp Make* $(ResDir)/
		echo "Recall/Precision figures computed and are in $(ResDir)/res"