Add verb
[apertium.git] / crossdics / dictools
blobbd1578dc6560a2beb78d3d471f4d9da521920110
1 #!/bin/bash
3 mainClass="ProcessDics"
4 # Minimum and maximum memory for JVM
5 defaultMinMem=32
6 defaultMaxMem=300
7 library='lib/cross-dics.jar'
8 java_options="-Xms${defaultMinMem}m -Xmx${defaultMaxMem}m -cp ${library} $mainClass"
9 #java_options="-Xms${defaultMinMem}m -Xmx${defaultMaxMem}m -cp $CLASSPATH $mainClass"
10 #echo $java_options
13 # cross
15 function cross() {
16 crossmodel="schemas/cross-model-test.xml"
17 if [ $nparams -ge 7 ] && [ $nparams -le 9 ]; then
18 if [ $nparams -ge 8 ]
19 then
20 crossmodel=$8
22 echo "cross model: $crossmodel"
23 java ${java_options} $task -bilAB $3 $4 -bilBC $5 $6 -monA $2 -monC $7 -cross-model $crossmodel $9 2> $task.err
24 else
25 echo "Usage: dictools cross <monA> <-r|-n> <bilAB> <-r|-n> <bilBC> <monC> crossmodel"
26 echo "More information in http://xixona.dlsi.ua.es/wiki/index.php/Crossdics";
31 # format
33 function format() {
34 if [ $nparams == 4 ]
35 then
36 echo "Reading '$3'..."
37 java ${java_options} $task $2 $3 $4 2> format.err
38 echo "Formatted dictonary: $4"
39 echo "Log file in 'format.err'"
40 else
41 echo "Usage: dictools format <-mon|-bil> <dic> <out>"
46 # merge-morph
48 function merge-morph() {
49 if [ $nparams -ge 4 ]
50 then
51 echo "Morphological 1: $2"
52 echo "Morphological 2: $3"
53 java ${java_options} $task -monA1 $2 -monA2 $3 -out $4 $5
54 echo "Merged dictionary: $4"
55 else
56 echo "Usage: dictools merge-morph <monA1> <monA2> <merged>"
61 # merge-bil
63 function merge-bil() {
64 if [ $nparams -eq 6 ]; then
65 echo "Bilingual 1: $3"
66 echo "mode: $2"
67 echo "Bilingual 2: $5"
68 echo "mode: $4"
69 java ${java_options} $task -bilAB1 $2 $3 -bilAB2 $4 $5 -out $6
70 echo "Merged: $6"
71 else
72 echo "Usage: dictools merge-bil <-n|-r> <bilAB1> <-n|-r> <bilAB2> <merged>"
77 # reverse-bil
79 function reverse-bil() {
80 if [ $nparams == 3 ]
81 then
82 echo "Reading '$2'..."
83 java ${java_options} reverse $2 $3 2> reverse-bil.err
84 else
85 echo "Usage: dictools reverse-bil <dic> <out>"
90 # sort
92 function sort() {
93 if [ $nparams == 5 ]
94 then
95 echo "Reading '$4' ($2)"
96 java ${java_options} $task $2 $3 $4 $5
97 echo "Sorted: $5"
98 else
99 echo "Usage: dictools sort <-bil|-mon> <-xinclude|-same-file> <dic.dix> <out.dix>"
104 # process-xincludes
106 function process-xincludes() {
107 if [ $nparams == 3 ]
108 then
109 java ${java_options} gather $2 $3
110 echo "Dictionary: $3"
111 else
112 echo "Usage: dictools process-xincludes <dic> <out.dix>"
117 # get-bil-omegawiki
119 function get-bil-omegawiki() {
120 if [ $nparams == 4 ]
121 then
122 java ${java_options} $task $2 $3 $4
123 echo "Dictionary: $4"
124 else
125 echo "Usage: dictools get-bil-omegawiki <source-lang> <target-lang> <dic-out>"
130 # format-1line
132 function format-1line() {
133 if [ $nparams == 3 ]
134 then
135 java ${java_options} $task $2 $3
136 echo "Dictionary: $3"
137 else
138 echo "Usage: dictools format-1line <dic> <dic-out>"
143 # read-dic
145 function dic-reader() {
146 if [ $nparams -ge 3 ]
147 then
148 java ${java_options} $task $2 $3 $4
149 else
150 echo "Usage: dictools dic-reader <action> [-url] <dic>"
151 echo "where <action> can be:"
152 echo " list-paradigms: list of paradigms";
153 echo " list-lemmas: list of lemmas";
154 echo " list-definitions: list of <sdef> elemenst";
155 echo " list-pairs: list of pairs (for bilingual dictionaries";
156 echo "";
157 echo "More information: http://xixona.dlsi.ua.es/wiki/index.php/Dictionary_reader";
158 echo "";
163 # equiv-paradigms
165 function equiv-paradigms() {
166 if [ $nparams -ge 2 ]
167 then
168 java ${java_options} $task $2 $3
169 else
170 echo "Usage: dictools equiv-paradigms <dic> <out>"
176 # show_help
178 function show_help() {
179 echo "Usage: dictools [task] ..."
180 echo " Tasks:"
181 echo " cross: crosses a set of dictionaries"
182 echo " dic-reader: reads elements from a dictionary"
183 echo " equiv-paradigms: finds equivalent paradigms and updates references"
184 echo " format: formats a dictionary"
185 echo " merge-bil: merges two bilingual dictionaries"
186 echo " merge-morph: merges two morphological dictionaries"
187 echo " process-xincludes: processes and expands all xincludes in the dictionary"
188 echo " reverse-bil: reverses a bilingual dictionary"
189 echo " sort: sorts (and groups by category) a dictionary"
190 echo ""
191 echo "More info: http://xixona.dlsi.ua.es/wiki/index.php/Crossdics"
192 echo ""
193 exit 127
196 task=$1
197 nparams="$#"
198 params="$@"
199 if [ "$#" == 0 ]; then
200 show_help
201 else
202 $task $params