# Makefile for extracting a grammar and training and testing # the maximum entropy model. # # Copyright (C) 2004-2007 Richard Moot (Richard.Moot@labri.fr) # Copyright (C) 2004-2007 CNRS (http://www.cnrs.fr) # Copyright (C) 2004-2007 INRIA (http://www.inria.fr) # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # a small Makefile to make the extraction of corpora and # training/evaluating them easier. a call like # # make tri # # will update the lexicon files, create the maximum entropy # data, partition them into a training and test corpus, # train the supertagger, evaluate the results and finally # output the results as a pdf file. # # Change the variable "prefix" below to be the installation # path of the Corpus tools. # make lex - converts the CGN files to .lex files # make formulas - computes the auxiliary formula files based on # the .lex files # make me - computes the train and test files for the # maximum entropy supertagger # make train - trains a maximum entropy model # make test - test the maximum entropy model # make exp.ps - produces a graphical representation of the # evaluation of the tagged data # make all - do everything # make tri - do everything, but using the trigram supertagger # 20050103 RM prefix = /Users/moot/Corpus binct = bin bindir = $(prefix)/$(binct) bakct = backups bakdir = $(prefix)/$(bakct) synct = r7syn syndir = $(prefix)/$(synct) outct = r7out outdir = $(prefix)/$(outct) lexct = r7out lexdir = $(prefix)/$(lexct) mect = r7out medir = $(prefix)/$(mect) evalct = r7out/eval evaldir = $(prefix)/$(evalct) javact = supertagger javadir = $(prefix)/$(javact) synext = syn outext = out maxmem = -mx1932m cutoff = 2 SHELL = /bin/sh outfiles := $(patsubst %.$(synext),%.lex,$(wildcard $(syndir)/*.$(synext))) lexfiles := $(patsubst %.$(outext),%.lex,$(wildcard $(outdir)/*.$(outext))) classfiles := $(patsubst %.java,%.class,$(wildcard $(javadir)/*.java)) .PHONY: all tri uni .PRECIOUS: lex formulas me train tritrain test tritest .DELETE_ON_ERROR: .SUFFIXES: .SUFFIXES: .tex .pdf .lex .$(synext) .$(outext) lex: $(bindir)/cgntoform $(lexfiles) -cd $(prefix) ; tar cfz $(bakdir)/lex.`date +%Y%m%d`.tgz $(lexct)/*.lex touch lex $(lexdir)/uni.tcl: lex $(bindir)/lex2unigram $(lexdir)/*.lex > $(lexdir)/uni.tcl $(evaldir)/uni.eval: $(lexdir)/uni.tcl $(bindir)/testunigram $(lexdir)/*.lex > $(evaldir)/uni.eval treecounts: lex -cd $(prefix) ; tar cvfz $(bakdir)/formulas.`date +%Y%m%d`.tgz \ $(lexct)/treecounts $(lexct)/formula.pl \ $(lexct)/formula.tcl $(lexct)/counts $(lexct)/out?.pl $(bindir)/treecount $(lexdir)/*.lex > $(lexdir)/treecounts formula.tcl: treecounts $(bindir)/cutoff2forms $(cutoff) $(lexdir)/treecounts $(lexdir)/formula.tcl $(lexdir)/formula.pl $(lexdir)/printform.tcl $(bindir)/subformula.pl $(lexdir) $(lexdir)/formula.pl >> $(lexdir)/formula.tcl $(RM) $(lexdir)/formula.pl formula.pl: formula.tcl $(bindir)/formula2pl $(lexdir)/formula.tcl $(lexdir)/formula.pl counts: formula.pl $(bindir)/formula2counts $(lexdir) formulas: counts touch formulas $(medir)/maxent.train: me $(medir)/maxent.test: me me: formulas -cd $(prefix) ; tar cvfz $(bakdir)/maxent.`date +%Y%m%d`.tgz $(mect)/untaggeddata.txt $(mect)/maxentdata.txt $(mect)/maxent.train $(mect)/maxent.test $(bindir)/lex2me $(lexdir)/*.lex $(bindir)/partition $(medir)/maxentdata.txt $(medir)/maxent.train $(medir)/maxent.test touch me tritrain: $(classfiles) me -cp $(medir)/tri_model.bin.gz $(bakdir)/tri_model.bin.gz.`date +%Y%m%d` cd $(javadir) ; java $(maxmem) TriSuperTaggerME $(medir)/maxent.train $(medir)/tri_model.bin.gz 100 5 touch tritrain train: $(classfiles) me -cp $(medir)/model.bin.gz $(bakdir)/model.bin.gz.`date +%Y%m%d` cd $(javadir) ; java $(maxmem) SuperTaggerME $(medir)/maxent.train $(medir)/model.bin.gz 100 10 touch train $(medir)/model.bin.gz: train $(medir)/tri_model.bin.gz: tritrain $(medir)/tri.tagged: $(classfiles) $(medir)/tri_model.bin.gz me -cp $(medir)/tri.tagged $(bakdir)/tri.tagged.`date +%Y%m%d` cd $(javadir) ; java -mx1600m TriEvaluationGUI $(medir)/maxent.test $(medir)/tri.tagged $(medir)/tri_model.bin.gz $(medir)/maxent.tagged: $(classfiles) $(medir)/maxent.test $(medir)/model.bin.gz -cp $(medir)/maxent.tagged $(bakdir)/maxent.tagged.`date +%Y%m%d` cd $(javadir) ; java -mx1600m EvaluationGUI $(medir)/maxent.test $(medir)/maxent.tagged $(medir)/model.bin.gz tritest: $(evaldir)/tri.eval touch tritest test: $(evaldir)/exp.eval touch test $(evaldir)/tri.eval: $(medir)/tri.tagged -cp $(evaldir)/tri.eval $(evaldir)/tri.eval.`date +%Y%m%d` -cp $(evaldir)/eval.log $(evaldir)/eval.log.`date +%Y%m%d` $(bindir)/evalkmaxent $(medir)/maxent.test $(medir)/tri.tagged > $(evaldir)/tri.eval $(evaldir)/exp.eval: $(medir)/maxent.tagged -cp $(evaldir)/exp.eval $(evaldir)/exp.eval.`date +%Y%m%d` -cp $(evaldir)/eval.log $(evaldir)/eval.log.`date +%Y%m%d` $(bindir)/evalkmaxent $(medir)/maxent.test $(medir)/maxent.tagged > $(evaldir)/exp.eval %.class: %.java javac $< $(outdir)/%.$(outext): $(syndir)/%.$(synext) $(bindir)/filtercgn $< mv $(syndir)/$(@F) $@ $(lexdir)/%.lex: $(outdir)/%.$(outext) $(bindir)/cgntoform $< mv $(outdir)/$(@F) $@ %.tex: %.eval eval2tex $< $(evaldir)/%.pdf: $(evaldir)/%.tex cd $(evaldir) ; pdflatex $< open $@ uni: $(evaldir)/uni.pdf tri: $(evaldir)/tri.pdf all: $(evaldir)/exp.pdf