# Makefile for research/wordtuples
#
# (c) Mark Johnson, 3rd May, 2012

CXX = g++
CC = gcc
CFLAGS = -MMD -O3 -Wall -ffast-math -fstrict-aliasing -march=native
# uncomment the next line to turn off optimization and enable debugging with gdb
# CFLAGS = -MMD -g -Wall
CXXFLAGS = $(CFLAGS) 

SOURCES = sym.cc wordtuples.cc interaction.c interaction1.c
OBJECTS = sym.o wordtuples.o interaction.o 
OBJECTS1 = sym.o wordtuples.o interaction1.o

binaries: wordtuples wordtuples1

wordtuples: $(OBJECTS)
	g++ $(OBJECTS) -o wordtuples

wordtuples1: $(OBJECTS1)
	g++ $(OBJECTS1) -o wordtuples1

# make clean  removes all temporary files that can be recomputed
.PHONY: clean
clean: data-clean
	rm -f *.o *.d core 

# this command tells GNU make to look for dependencies in *.d files
-include $(patsubst %.c,%.d,$(SOURCES:%.cc=%.d))

# This runs the collocation-finding software on the Penn treebank strings

MINCOUNT=5
SIGNIFICANCE=1e-10

output.txt: wordtuples data.txt
	cat data.txt | $< 4 $(MINCOUNT) $(SIGNIFICANCE) > $@
	cat data.txt | $< 3 $(MINCOUNT) $(SIGNIFICANCE) >> $@
	cat data.txt | $< 2 $(MINCOUNT) $(SIGNIFICANCE) >> $@

output1.txt: wordtuples1 data.txt
	cat data.txt | $< 4 $(MINCOUNT) $(SIGNIFICANCE) > $@
	cat data.txt | $< 3 $(MINCOUNT) $(SIGNIFICANCE) >> $@
	cat data.txt | $< 2 $(MINCOUNT) $(SIGNIFICANCE) >> $@

data.txt:
	cat /usr/local/data/Penn3/parsed/mrg/wsj/*/*.mrg | munge-trees -Pedy > $@

data-clean:
	rm -f output*.txt data.txt 