-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
168 lines (130 loc) · 4.41 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#-----------------------------------------------------------------------------
# USAGE
#-----------------------------------------------------------------------------
#
# make all ................. make install and setup
# make install ............. install ISA in /var/www/html/${ISAROOT}
# make setup ............... make setup for example corpus
# make [VARIABLES] setup ... make setup for some other data
#
# VARIABLES to be set:
#
# ISAROOT ..... root dir for web data
# CORPUS ...... unique name of the corpus (without extension, no subdirectories)
# (this will be used to store all data)
# SRCLANG ..... source language identifier (eg. en, sv, ...)
# TRGLANG ..... target language identifier (eg. en, sv, ...)
#
# SRC_FILE .... path to the source XML file (gzipped)
# TRG_FILE .... path to the target XML file (gzipped)
# ALG_FILE .... path to the sentece alignment file (gzipped)
#
#-----------------------------------------------------------------------------
# EXAMPLE:
#
# make CORPUS=mycorpus-xxyy SRCLANG=xx TRGLANG=yy \
# SRC_FILE=xx/mycorpus.xml.gz \
# TRG_FILE=yy/mycorpus.xml.gz \
# ALG_FILE=xx-yy/mycorpus.xml.gz all
#
#############################################################################
VERSION = 0.1
## example corpus and data - change if necessary
CORPUS = RF-sven-1988
SRCLANG = en
TRGLANG = sv
SRC_FILE = example/RF/en/1988.xml.gz
TRG_FILE = example/RF/sv/1988.xml.gz
ALG_FILE = example/RF/en-sv/1988.xml.gz
## location of html files
WEBHOME = /var/www/html
ISAROOT = ISA
ISAHOME = ${WEBHOME}/${ISAROOT}
INSTALL = install -c
INSTALL_BIN = ${INSTALL} -m 755
INSTALL_DATA = ${INSTALL} -m 644
INSTALLFILES = ${ISAHOME}/index.php \
${ISAHOME}/isa.php ${ISAHOME}/isa.css \
${ISAHOME}/doc/isa.html \
$(patsubst %,${ISAHOME}/%,${wildcard include/*})
# UPLUG = path to uplug start script
# UPLUGSHARE = home directory of shared data
# SENTALIGNER = default alignment program (Gale&Church)
ifndef UPLUG
UPLUG = $(shell which uplug)
endif
ifndef UPLUGSHARE
UPLUGSHARE = $(shell perl -e 'use Uplug::Config;print &shared_home();')
endif
ifndef SENTALIGNER
SENTALIGNER = $(shell perl -e 'use Uplug::Config;print find_executable("align2");')
endif
LANGPAIR = $(SRCLANG)-$(TRGLANG)
INVLANGPAIR = $(TRGLANG)-$(SRCLANG)
DATADIR = corpora/${CORPUS}
## local files
SRCXML = ${DATADIR}/${SRCLANG}.xml
TRGXML = ${DATADIR}/${TRGLANG}.xml
SENTALIGN = ${DATADIR}.ces
SENTALIGNIDS = ${DATADIR}.ids
# configuration files
CONFIG = $(DATADIR)/config.inc
ISACONFIG = $(DATADIR)/config.isa
all: install setup
setup: ${ISAHOME}/$(SRCXML) ${ISAHOME}/$(TRGXML) \
${ISAHOME}/$(SENTALIGN) \
${ISAHOME}/$(CONFIG)
install: ${INSTALLFILES} ${ISAHOME}/$(DATADIR)
${INSTALLFILES}: ${ISAHOME}/%: %
mkdir -p ${dir $@}
${INSTALL_DATA} $< $@
${ISAHOME}/$(DATADIR):
mkdir -p $(dir $@)
chown www-data:www-data $(dir $@)
chmod +s $(dir $@)
mkdir -p $@
chown www-data:www-data $@
${ISAHOME}/$(SENTALIGN): ${ALG_FILE}
mkdir -p ${dir $@}
gzip -cd $< > $@
${ISAHOME}/$(SRCXML): $(SRC_FILE)
mkdir -p ${dir $@}
ifeq ($(shell zgrep '<w' ${SRC_FILE}),)
zcat $< | grep -v '<time ' |\
$(UPLUG) pre/tok -l ${SRCLANG} -out $@
else
zcat $< | grep -v '<time ' > $@
endif
${ISAHOME}/$(TRGXML): $(TRG_FILE)
mkdir -p ${dir $@}
ifeq ($(shell zgrep '<w' ${SRC_FILE}),)
zcat $< | grep -v '<time ' |\
$(UPLUG) pre/tok -l ${TRGLANG} -out $@
else
zcat $< | grep -v '<time ' > $@
endif
${ISAHOME}/$(CONFIG): ${ISAHOME}/$(DATADIR)/%.inc: include/%.in ${ISAHOME}/$(SRCXML) ${ISAHOME}/$(TRGXML)
sed 's#%%IDFILE%%#$(SENTALIGNIDS)#' $< |\
sed 's#%%DATADIR%%#${DATADIR}#' |\
sed 's#%%SRCXML%%#$(SRCXML)#' |\
sed 's#%%TRGXML%%#$(TRGXML)#' |\
sed 's#%%BITEXT%%#$(SENTALIGN)#' |\
sed 's#%%UPLUG%%#$(UPLUG)#' |\
sed 's#%%UPLUGSHARE%%#$(UPLUGSHARE)#' |\
sed 's#%%SENTALIGNER%%#$(SENTALIGNER)#' |\
sed 's#%%LANGPAIR%%#$(LANGPAIR)#' |\
sed 's#%%INVLANGPAIR%%#$(INVLANGPAIR)#' > $@
${ISAHOME}/$(ISACONFIG): ${ISAHOME}/$(DATADIR)/%.isa: include/%.in ${ISAHOME}/$(SRCXML) ${ISAHOME}/$(TRGXML)
sed 's#%%IDFILE%%#$(SENTALIGNIDS)#' $< |\
sed 's#%%DATADIR%%#${DATADIR}#' |\
sed 's#%%SRCXML%%#$(SRCXML)#' |\
sed 's#%%TRGXML%%#$(TRGXML)#' |\
sed 's#%%BITEXT%%#$(SENTALIGN)#' |\
sed 's#%%UPLUG%%#$(UPLUG)#' |\
sed 's#%%UPLUGSHARE%%#$(UPLUGSHARE)#' |\
sed 's#%%SENTALIGNER%%#$(SENTALIGNER)#' |\
sed 's#%%LANGPAIR%%#$(LANGPAIR)#' |\
sed 's#%%INVLANGPAIR%%#$(INVLANGPAIR)#' > $@
clean:
rm -f config.inc
rm -f $(SENTALIGNIDS)