Fixing things
[apertium.git] / crossdics / build.xml
blob15e3f0e0459e518469d55fb58f48a4a5e7aabd23
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <project name="cross-dics" basedir="." default="cross">
4         <description>Cross dictionaries</description>
6         <property name="dics.dir" location="dics" />
7         <property name="crp.dir" location="crp" />
9         <!-- Dictionaries to cross -->
10         <property name="bil-AB" value="${dics.dir}/apertium-bb-aa.bb-aa.dix" />
11         <property name="bil-BC" value="${dics.dir}/apertium-bb-cc.bb-cc.dix" />
12         <property name="monol-A" value="${dics.dir}/apertium-bb-aa.aa.dix" />
13         <property name="monol-C" value="${dics.dir}/apertium-bb-cc.cc.dix" />
14         <property name="mod-AB" value="-n" />
15         <property name="mod-BC" value="-n" />
16         <property name="cross-model" value="schemas/cross-model-test.xml" />
18         <!-- Dictionary (to sort, to reverse, etc) -->
19    <!-- Example: -->
20         <property name="dic" value="dics/apertium-aa-bb.aa.dix" />
21         <property name="dic-type" value="-mon" /> <!-- or -bil -->
22         <property name="out" value="apertium-aa-cc.aa-sorted.dix" />
23         
24         <!-- Dictionaries to merge -->
25         <!--
26         <property name="bil-AB1" value="${dics.dir}/apertium-aa-bb.aa-bb-1.dix" />
27         <property name="mod-AB1" value="-n" />  
28         <property name="monol-A1" value="${dics.dir}/apertium-aa-bb.aa-1.dix" />
29         <property name="monol-B1" value="${dics.dir}/apertium-aa-bb.aa-1.dix" />
30         
31         <property name="bil-AB2" value="${dics.dir}/apertium-aa-bb.aa-bb-2.dix" />
32         <property name="mod-AB2" value="-n" />
33         <property name="monol-A2" value="${dics.dir}/apertium-aa-bb.aa-2.dix" />
34         <property name="monol-B2" value="${dics.dir}/apertium-aa-bb.aa-2.dix" />
35         -->
36         
37         <!-- EXAMPLES -->
38         <!-- Dictionaries to cross (ca-pt example) -->
39         <!--
40         <property name="bil-AB" value="${dics.dir}/apertium-es-ca.es-ca.dix" />
41         <property name="bil-BC" value="${dics.dir}/apertium-es-pt.es-pt.dix" /> 
42         <property name="monol-A" value="${dics.dir}/apertium-es-ca.ca.dix" />
43         <property name="monol-C" value="${dics.dir}/apertium-es-pt.pt.dix" />
44         <property name="mod-AB" value="-n" />
45         <property name="mod-BC" value="-n" />
46         <property name="cross-model" value="schemas/cross-model-test.xml" />
47         -->
49         <!-- Dictionaries to merge (example) -->
50         <!--
51         <property name="bil-AB1" value="dix/apertium-es-fr.es-fr-crossed.dix" />
52         <property name="mod-AB1" value="-n" />
53         <property name="monol-A1" value="dix/apertium-es-fr.es-crossed.dix" />
54         <property name="monol-B1" value="dix/apertium-es-fr.fr-crossed.dix" />
55         <property name="bil-AB2" value="dix/apertium-es-fr.es-fr-crossed-specul.dix"/>
56         <property name="mod-AB2" value="-n" />
57         <property name="monol-A2" value="dix/apertium-es-fr.es-crossed-specul.dix" />
58         <property name="monol-B2" value="dix/apertium-es-fr.fr-crossed-specul.dix" />
59         -->
60                 
61         <!-- Directories -->
62         <property name="build.dir" location="classes" />
63         <property name="src.dir" location="src/" />
64         <property name="log.dir" location="log" />
65         <property name="dix.dir" location="dix" />
66         <property name="zip.dir" location="zip" />
67         <property name="lib.dir" location="lib" />
68         <property name="zip" value="compara-entradas" />
69         <property name="zip.file" value="crossdics" />
70         <property name="appName" value="cross-dics" />
71         <property name="root-folder" value="svn-cross-dics" />
72         
73         <!-- PROPERTIES -->
74         <!-- Memory -->
75         <property name="minMem" value="32" />
76         <property name="maxMem" value="150" />
77         <!-- Time Stamp -->
78         <tstamp>
79                 <format property="pack.timestamp" pattern="yyMMdd-HHmm" />
80         </tstamp>
81         <!-- Main class -->
82         <property name="mainClass" value="ProcessDics" />
83         <!-- Log files -->
84         <property name="outputFile" value="${log.dir}/cross-dics.log" />
85         <!-- Use pattern detection for crossing? -->
86         <property name="use-patterns" value="yes" />
88         
89         <!-- TASKS -->
90         
91         <!-- Prepare Consistent -->
92         <target name="prepare-consistent">
93                 <echo message="Preparing to enhance..." />
94                 <condition property="dics-available">
95                         <and>
96                                 <available file="${bil-AB}" />
97                                 <available file="${bil-BC}" />
98                                 <available file="${monol-A}" />
99                                 <available file="${monol-C}" />
100                         </and>
101                 </condition>
102                 <echo message="Done" />
103                 <fail unless="dics-available">'Some dictionaries are not available!</fail>
104         </target>
106         <!-- Prepare -->
107         <target name="prepare">
108                 <mkdir dir="${dics.dir}" />
109                 <mkdir dir="${log.dir}" />
110                 <mkdir dir="${dix.dir}" />
111                 <mkdir dir="${build.dir}" />
112                 <mkdir dir="${lib.dir}" />
113                 <mkdir dir="${zip.dir}" />
114         </target>
116         <!-- Compile -->
117         <target name="compile" depends="check-java-version,prepare">
118                 <echo message="Compiling Java sources..." />
119                 <javac destdir="${build.dir}/" deprecation="on">
120                         <include name="**/*.java" />
121                         <src path="${src.dir}" />
122                 </javac>
123                 <antcall target="jar" />
124                 <echo message="Done!" />
125         </target>
126         
127 <target name="check-java-version">
128     <condition property="java.version.ok">
129       <or>
130         <equals arg1="${ant.java.version}" arg2="1.5"/>
131         <equals arg1="${ant.java.version}" arg2="1.6"/>
132       </or>
133     </condition>
134            <fail unless="java.version.ok">Java 1.5 or higher is required; found Java ${ant.java.version} in ${java.home}</fail>
135   </target>     
137         <!-- Reverse -->
138         <target name="reverse" depends="compile">
139                 <echo message="Reversing '${dic}'..." />
140                 <java classname="${mainClass}" classpath="${lib.dir}/${appName}.jar" fork="true" output="${outputFile}">
141                         <jvmarg value="-Xms${minMem}m" />
142                         <jvmarg value="-Xmx${maxMem}m" />
143                         <arg value="reverse" />
144                         <arg value="${dic}" />
145                         <arg value="${out}" />
146                 </java>
147                 <antcall target="clean" />
148                 <echo message="Log in '${docs.dir}/${outputFile}'" />
149                 <echo message="Done!" />
150         </target>
152         <!-- Format -->
153         <target name="format">
154                 <echo message="Formatting '${dic}'..." />
155                 <java classname="${mainClass}" classpath="${lib.dir}/${appName}.jar" fork="true" output="${outputFile}">
156                         <jvmarg value="-Xms${minMem}m" />
157                         <jvmarg value="-Xmx${maxMem}m" />
158                         <arg value="format" />
159                         <arg value="${dic-type}" />                     
160                         <arg value="${dic}" />
161                         <arg value="${out}" />
162                 </java>
163                 <antcall target="clean" />
164                 <echo message="Done!" />
165         </target>
167         <!-- Sort -->
168         <target name="sort" depends="compile">
169                 <echo message="Sorting '${dic}'..." />
170                 <java classname="${mainClass}" classpath="${lib.dir}/${appName}.jar" fork="true">
171                         <jvmarg value="-Xms${minMem}m" />
172                         <jvmarg value="-Xmx${maxMem}m" />
173                         <arg value="sort" />
174                         <arg value="${dic-type}" />
175                         <arg value="${dic}" />
176                         <arg value="${out}" />
177                 </java>
178                 <antcall target="clean" />
179                 <echo message="Done!" />
180         </target>
182         <!-- Make consistent -->
183         <target name="consistent" depends="prepare-consistent" if="dics-available">
184                 <echo message="Running '${mainClass} consistent' ..." />
185                 <echo message="Creating consistent dictionaries..." />
186                 <echo message="  ${monol-A}" />
187                 <echo message="  ${monol-C}" />
188                 <echo message="  ${bil-AB}" />
189                 <echo message="  ${bil-BC}" />
190                 <java classname="${mainClass}" classpath="${lib.dir}/${appName}.jar" fork="true" output="${outputFile}">
191                         <jvmarg value="-Xms${minMem}m" />
192                         <jvmarg value="-Xmx${maxMem}m" />
193                         <arg value="consistent" />
195                         <arg value="-bilAB" />
196                         <arg value="${mod-AB}" />
197                         <arg value="${bil-AB}" />
198                         
199                         <arg value="-bilBC" />
200                         <arg value="${mod-BC}" />
201                         <arg value="${bil-BC}" />
202                         
203                         <arg value="-monA" />
204                         <arg value="${monol-A}" />
205                         
206                         <arg value="-monC" />
207                         <arg value="${monol-C}" />
208                 </java>
209                 <antcall target="clean" />
210                 <echo message="Results in '${docs.dir}/${outputFile}'" />
211                 <echo message="Done!" />
212         </target>
214         <!-- Prepare Cross -->
215         <target name="prepare-cross">
216                 <echo message="Preparing to cross..." />
217                 <condition property="dics-available">
218                         <and>
219                                 <available file="${bil-AB}" />
220                                 <available file="${bil-BC}" />
221                                 <available file="${monol-A}" />
222                                 <available file="${monol-C}" />
223                         </and>
224                 </condition>
225                 <echo message="Done" />
226                 <fail unless="dics-available">Usage: ant cross -Dbil-AB bilAB.dix -Dbil-BC bilBC.dix -Dmonol-A monA.dix -Dmonol-C monC.dix [-Dmod-AB -r] [-Dmod-BC -r] (or indicate de dictionaries in build.xml)</fail>
227         </target>
228         <target name="cross-not-available">
229                 <echo message="Cross task is not available."/>
230         </target>
232         <!-- Cross action -->
233         <target name="cross" depends="prepare-cross" if="dics-available">
234                 <echo message="Crossing dictionaries..." />
235                 <echo message="  ${monol-A}" />
236                 <echo message="  ${monol-C}" />
237                 <echo message="  ${bil-AB}" />
238                 <echo message="  ${bil-BC}" />
240                 <java classname="${mainClass}" classpath="${lib.dir}/${appName}.jar" fork="true" output="${outputFile}">
241                         <jvmarg value="-Xms${minMem}m" />
242                         <jvmarg value="-Xmx${maxMem}m" />
243                         <arg value="cross" />
244                         
245                         <arg value="-bilAB" />
246                         <arg value="${mod-AB}" />                       
247                         <arg value="${bil-AB}" />
249                         
250                         <arg value="-bilBC" />
251                         <arg value="${mod-BC}" />                       
252                         <arg value="${bil-BC}" />
253                         
254                         <arg value="-monA" />
255                         <arg value="${monol-A}" />
256                         
257                         <arg value="-monC" />
258                         <arg value="${monol-C}" />
259                         
260                         <arg value="-cross-model" />
261                         <arg value="${cross-model}" />
262                 </java>
263                 <antcall target="clean" />
264                 <echo message="Results in 'dix' folder." />
265                 <echo message="Done!" />
266         </target>
268         <!-- Prepare Merge -->
269         <target name="prepare-merge">
270                 <echo message="Preparing to merge..." />
271                 <condition property="merge-dics-available">
272                         <and>
273                                 <available file="${bil-AB1}" />
274                                 <available file="${bil-AB2}" />
275                                 <available file="${monol-A1}" />
276                                 <available file="${monol-B1}" />
277                                 <available file="${monol-A2}" />
278                                 <available file="${monol-B2}" />
279                         </and>
280                 </condition>
281                 <echo message="Done" />
282                 <fail unless="merge-dics-available">Usage: ant merge
283                 -Dbil-AB1 bilAB1.dix -DbilAB2 bilAB2.dix -Dmonol-A1
284                 monA1.dix -Dmonol-A2 monA2.dix -Dmonol-B1 monB1.dix
285                 -Dmonol-B2 monB2.dix</fail>
286         </target>
288         <!-- Merge action -->
289         <target name="merge" depends="compile,prepare-merge" if="merge-dics-available">
290                 <echo message="Merging dictionaries..." />
291                 <echo message="  ${bil-AB1}" /> 
292                 <echo message="  ${monol-A1}" />        
293                 <echo message="  ${monol-B1}" />        
295                 <echo message="  ${bil-AB2}" /> 
296                 <echo message="  ${monol-A2}" />        
297                 <echo message="  ${monol-B2}" />        
299                 <java classname="${mainClass}" classpath="${lib.dir}/${appName}.jar" fork="true" output="${outputFile}">
300                         <jvmarg value="-Xms${minMem}m" />
301                         <jvmarg value="-Xmx${maxMem}m" />
302                         <arg value="merge" />
304                         <!-- dic set 1 -->                      
305                         <arg value="-bilAB" />
306                         <arg value="${mod-AB1}" />                      
307                         <arg value="${bil-AB1}" />
309                         <arg value="-monA1" />
310                         <arg value="${monol-A1}" />
311                         
312                         <arg value="-monB" />
313                         <arg value="${monol-B1}" />
314                         
315                         <!-- dic set 2 -->
316                         <arg value="-bilAB2" />
317                         <arg value="${mod-AB2}" />                      
318                         <arg value="${bil-AB2}" />
319                         
320                         <arg value="-monA2" />
321                         <arg value="${monol-A2}" />
322                         
323                         <arg value="-monB2" />
324                         <arg value="${monol-B2}" />
325                         
326                 </java>
327                 <antcall target="clean" />
328                 <echo message="Results in '${log.dir}/${outputFile}'" />
329                 <echo message="Done!" />
330         </target>
332         <!-- Merge-morph action -->
333         <target name="merge-morph" depends="compile">
334                 <echo message="Merging morphological dictionaries..." />
335                 <echo message="  ${monol-A1}" />        
336                 <echo message="  ${monol-A2}" />        
337                 <echo message="  ${out}" />     
339                 <java classname="${mainClass}" classpath="${lib.dir}/${appName}.jar" fork="true" output="${outputFile}">
340                         <jvmarg value="-Xms${minMem}m" />
341                         <jvmarg value="-Xmx${maxMem}m" />
342                         <arg value="merge-morph" />
344                         <arg value="-monA1" />
345                         <arg value="${monol-A1}" />
346                         
347                         <arg value="-monA2" />
348                         <arg value="${monol-A2}" />
349                         
350                         <arg value="-out" />
351                         <arg value="${out}" />
352                         
353                 </java>
354                 <antcall target="clean" />
355                 <echo message="Results in '${log.dir}/${outputFile}'" />
356                 <echo message="Done!" />
357         </target>
359         <!-- Merge-bil action -->
360         <target name="merge-bil" depends="compile">
361                 <echo message="Merging bilingual dictionaries..." />
362                 <echo message="  ${bil-AB1}" />
363                 <echo message="  ${mod-AB1}" />         
364                 <echo message="  ${bil-AB2}" />
365                 <echo message="  ${mod-AB2}" /> 
366                 <echo message="  ${out}" />     
368                 <java classname="${mainClass}" classpath="${lib.dir}/${appName}.jar" fork="true" output="${outputFile}">
369                         <jvmarg value="-Xms${minMem}m" />
370                         <jvmarg value="-Xmx${maxMem}m" />
371                         <arg value="merge-bil" />
373                         <arg value="-bilAB1" />
374                         <arg value="${mod-AB1}" />                      
375                         <arg value="${bil-AB1}" />
376                         
377                         <arg value="-bilAB2" />
378                         <arg value="${mod-AB2}" />                      
379                         <arg value="${bil-AB2}" />
380                         
381                         <arg value="-out" />
382                         <arg value="${out}" />
383                         
384                 </java>
385                 <antcall target="clean" />
386                 <echo message="Results in '${log.dir}/${outputFile}'" />
387                 <echo message="Done!" />
388         </target>
390         <!-- Clean -->
391         <target name="clean">
392         </target>
394         <!-- Pack -->
395         <target name="pack" depends="prepare">
396                 <echo message="Packing files..." />
397                 <delete>
398                         <fileset dir="${zip.dir}/" includes="*.tar.gz"/>
399                 </delete>
400                 
401                 <tar tarfile="${zip.dir}/${zip.file}.tar">
402                         <tarfileset dir="../">
403                                 <include name="${root-folder}/build.xml"/>
404                                 <!-- root -->
405                                 <include name="${root-folder}/src/*.java"/>
406                                 <!-- dictools -->
407                                 <include name="${root-folder}/src/dictools/*.java"/>
408                                 <include name="${root-folder}/src/dictools/crossmodel/*.java"/>
409                                 <!-- dics -->
410                                 <include name="${root-folder}/src/dics/elements/dtd/*.java"/>
411                                 <include name="${root-folder}/src/dics/elements/utils/*.java"/>
412                                 <!-- misc -->
413                                 <include name="${root-folder}/src/misc/*.java"/>
414                                 <include name="${root-folder}/src/misc/eues/*.java"/>
416                                 <include name="${root-folder}/dics"/>
417                                 <include name="${root-folder}/dix"/>
418                                 <include name="${root-folder}/schemas/*.xml"/>
419                                 <include name="${root-folder}/lib/cross-dics.jar"/>
420                                 <include name="${root-folder}/log"/>
421                                 <include name="${root-folder}/META-INF/manifest.mf"/>
422                                 <include name="${root-folder}/AUTHORS"/>
423                                 <include name="${root-folder}/COPYING"/>
424                                 <include name="${root-folder}/README"/>                                                         
425                         </tarfileset>
426                 </tar>
427                 <gzip zipfile="${zip.dir}/${zip.file}.tar.gz" src="${zip.dir}/${zip.file}.tar"/>
428                 <delete file="${zip.dir}/${zip.file}.tar" />
429                 <echo message="Done!" />
430         </target>
432         <!-- Help -->
433         <target name="help">
434                 <echo message="Usage: ant [options ...]" />
435                 <echo message="" />
436                 <echo message="Where options include;" />
438                 <echo message="  consistent -Dbil-AB AB.dix [-Dmod-AB -r] -Dbil-BC BC.dix [-Dmod-BC -r] -Dmonol-A monA.dix -Dmonol-C monC.dix   (generates consistent dictionaries)" />
439                 <echo message="  cross      -Dbil-AB AB.dix [-Dmod-AB -r] -Dbil-BC BC.dix [-Dmod-BC -r] -Dmonol-A monA.dix -Dmonol-C monC.dix   (generates crossed dictionaries)" />
440                 <echo message="  merge      -Dbil-AB1 AB1.dix [-Dmod-AB1 -r] -DbilAB2 AB2.dix [-Dmod-AB2 -r] -Dmonol-A1 A1.dix -Dmonol-A2 A2.dix -Dmonol-B1 B1.dix -Dmonol-B2 B2.dix" />
442                 <echo message="  reverse    -Ddic dic.dix [-Dout rev-dic-name.dix]   (reverses a dictionary)" />
443                 <echo message="  format     -Ddic dic.dix [-Dout formatted-dic-name.dix]   (formats a given dictionary)" />
445                 <echo message="  compile    (compiles source files)" />
446                 
447                 <echo message="  help       (shows this help file)" />
448         </target>
450    <!-- Jar -->
451         <target name="jar">
452                 <mkdir dir="lib"/>
453                 <jar destfile="lib/${appName}.jar" basedir="${build.dir}/"
454                 manifest="META-INF/manifest.mf"/>
455         </target>
457    <!-- HowTo-->
458         <target name="howto" depends="compile">
459                 <echo message="Crossing dictionaries..." />
461                 <java classname="HowTo" classpath="${lib.dir}/${appName}.jar" fork="true" output="${outputFile}">
462                         <jvmarg value="-Xms${minMem}m" />
463                         <jvmarg value="-Xmx${maxMem}m" />
464                         <arg value="cross" />
465                 </java>
466                 <antcall target="clean" />
467                 <echo message="Results in '${log.dir}/${outputFile}'" />
468                 <echo message="Done!" />
469         </target>
471         <!-- Test -->
472         <target name="test" depends="compile">
473                 <echo message="Testing..." />
474                 <java classname="Test" classpath="${lib.dir}/${appName}.jar" fork="true">
475                         <jvmarg value="-Xms${minMem}m" />
476                         <jvmarg value="-Xmx${maxMem}m" />
477                 </java>
478                 <antcall target="clean" />
479                 <echo message="Done!" />
480         </target>
482 </project>