<commit_before>##
## Python compilation/code generation Rules
##

imtests=tfidf kmeans tfidf_and_kmeans
omtests=tfidf_then_kmeans
exes=$(omtests) $(imtests)
#cpps=$(patsubst %, %.cpp, $(imtests))
#jsons=$(patsubst %, %.json, $(exes))

PY=python
COMPILER=jsontocpp.py
OPLIB=SwanMaterialised.json

.SILENT:

%.dir: %.json
	@ echo " #####   Compiling Workflow $<   #####"
	$(PY) $(COMPILER) -i $< -l $(OPLIB) 
	@ echo " #####   Compiling Generated Swan $@ #####"
	@ make `ls -1 $*.dir/*.cpp | sed -e 's/.cpp//'`

## Test Rules

test_%: %.dir
	@ echo " #####   Executing Workflow $*   #####"
	@ $*.dir/$*

test_tfidf_then_kmeans: test_%: tfidf_then_kmeans.dir
	if [ -a $*.dir/tfidf_kmeans ] ; \
	then \
		echo " #####   Executing Optimised Version of Workflow tfidf_kmeans   #####" ; \
		$*.dir/tfidf_kmeans ; \
	else \
		echo " #####   Executing Workflow $* #####" ; \
		$*.dir/tfidf ; \
		$*.dir/kmeans ; \
	fi;
	@ echo " #####   Execution of Workflow $* complete  #####"

##
## Swan/C++ compilation Rules
##


INCLUDE_FILES=traits.h dense_vector.h sparse_vector.h vector_ops.h kmeans.h attributes.h memory.h utils.h data_set.h arff.h normalize.h word_bank.h word_count.h io.h
INCLUDE=$(patsubst %, ../../include/asap/%, $(INCLUDE_FILES))

# OBJ=$(patsubst %, %.o, $(tests))
OPT += 

CXX=icpc
CC=icpc
CXXFLAGS+=-O3 $(OPT) -g -std=c++11 -I. -I.. -DTIMING
CXXFLAGS += -I../../cilkpub_v105/include -I../include
LDFLAGS+=-g -std=c++11 -lrt $(OPT)

%.o: %.cpp $(INCLUDE)

%: %.o

.PHONY: clean
clean:
	rm -fr $(patsubst %,%.dir,$(exes))

test:
	@ echo "_________________________________________________________________________________"
	@ make tfidf.dir
	@ make test_tfidf
	@ echo "_________________________________________________________________________________"
	@ make kmeans.dir
	@ make test_kmeans
	@ echo "_________________________________________________________________________________"
	@ make tfidf_and_kmeans.dir
	@ make test_tfidf_and_kmeans
	@ echo "_________________________________________________________________________________"
	@ make tfidf_then_kmeans.dir
	@ make test_tfidf_then_kmeans
	@ echo "_________________________________________________________________________________"
<commit_msg>Changes to Makefile for cmp regression test.  However, kmeans always differ due to variance in floating point numbers, probably take out kmeans regression ?, or change message to show difference, ie. manual judgement<commit_after>##
## Python compilation/code generation Rules
##

imtests=tfidf kmeans tfidf_and_kmeans
omtests=tfidf_then_kmeans
exes=$(omtests) $(imtests)
#cpps=$(patsubst %, %.cpp, $(imtests))
#jsons=$(patsubst %, %.json, $(exes))

PY=python
COMPILER=jsontocpp.py
OPLIB=SwanMaterialised.json

.SILENT:

%.dir: %.json
	@ echo " #####   Compiling Workflow $<   #####"
	$(PY) $(COMPILER) -i $< -l $(OPLIB) 
	@ echo " #####   Compiling Generated Swan $@ #####"
	@ make `ls -1 $*.dir/*.cpp | sed -e 's/.cpp//'`

## Test Rules
test_tfidf: test_%: tfidf.dir
	@ echo " #####   Executing Workflow $*   #####"
	@ $*.dir/$*
	@if cmp tfidf_output.arff tfidf_output.arff.good ; then echo "SUCCESS -- Output compared successfully" ; else echo "FAILURE -- Output deviates from reference" ; fi

test_kmeans: test_%: kmeans.dir
	@ echo " #####   Executing Workflow $*   #####"
	@ $*.dir/$*
	@if cmp kmeans_output.txt kmeans_output.txt.good ; then echo "SUCCESS -- Output compared successfully" ; else echo "FAILURE -- Output deviates from reference" ; fi

test_tfidf_and_kmeans: test_%: tfidf_and_kmeans.dir
	@ echo " #####   Executing Workflow $*   #####"
	@ $*.dir/$*
	@if cmp kmeans_output.txt kmeans_output.txt.good ; then echo "SUCCESS -- Output compared successfully" ; else echo "FAILURE -- Output deviates from reference" ; fi

test_tfidf_then_kmeans: test_%: tfidf_then_kmeans.dir
	if [ -a $*.dir/tfidf_kmeans ] ; \
	then \
		echo " #####   Executing Optimised Version of Workflow tfidf_kmeans   #####" ; \
		$*.dir/tfidf_kmeans ; \
	else \
		echo " #####   Executing Workflow $* #####" ; \
		$*.dir/tfidf ; \
		$*.dir/kmeans ; \
	fi;
	@ echo " #####   Execution of Workflow $* complete  #####"
	@if cmp tfidf_output.arff test_tfidf_then_kmeans_output.arff.good ; then echo "SUCCESS -- Output compared successfully" ; else echo "FAILURE -- Output deviates from reference" ; fi
	@if cmp kmeans_output.txt test_tfidf_then_kmeans_output.txt.good ; then echo "SUCCESS -- Output compared successfully" ; else echo "FAILURE -- Output deviates from reference" ; fi
##
## Swan/C++ compilation Rules
##


INCLUDE_FILES=traits.h dense_vector.h sparse_vector.h vector_ops.h kmeans.h attributes.h memory.h utils.h data_set.h arff.h normalize.h word_bank.h word_count.h io.h
INCLUDE=$(patsubst %, ../../include/asap/%, $(INCLUDE_FILES))

# OBJ=$(patsubst %, %.o, $(tests))
OPT += 

CXX=icpc
CC=icpc
CXXFLAGS+=-O3 $(OPT) -g -std=c++11 -I. -I.. -DTIMING
CXXFLAGS += -I../../cilkpub_v105/include -I../include
LDFLAGS+=-g -std=c++11 -lrt $(OPT)

%.o: %.cpp $(INCLUDE)

%: %.o

.PHONY: clean
clean:
	rm -fr $(patsubst %,%.dir,$(exes))

test:
	@ echo "_________________________________________________________________________________"
	@ make tfidf.dir
	@ make test_tfidf
	@ cp tfidf_output.arff test_tfidf_output.arff.good
	@ echo "_________________________________________________________________________________"
	@ make kmeans.dir
	@ make test_kmeans
	@ cp kmeans_output.txt test_kmeans_output.txt.good
	@ echo "_________________________________________________________________________________"
	@ make tfidf_and_kmeans.dir
	@ make test_tfidf_and_kmeans
	@ cp kmeans_output.txt test_tfidf_and_kmeans_output.txt.good
	@ echo "_________________________________________________________________________________"
	@ make tfidf_then_kmeans.dir
	@ make test_tfidf_then_kmeans
	@ cp tfidf_output.arff test_tfidf_then_kmeans_output.arff.good
	@ cp kmeans_output.txt test_tfidf_then_kmeans_output.txt.good
	@ echo "_________________________________________________________________________________"
{'fraction_non_alphanumeric': 0.15333221980958744, 'fraction_numerical': 0.0030065141139134794, 'mean_word_length': 4.5806150978564775, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1153605', 'n_tokens_mistral': 2152, 'n_tokens_neox': 2054, 'n_words': 451}