forked from brown-uk/dict_uk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
219 lines (159 loc) · 5.49 KB
/
build.gradle
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'eclipse'
version = '1.0'
group = 'org.dict_uk'
String langCode="uk"
String affixDir="data/affix"
String outputDir="out"
String prevDir="../../out/prev"
String testOutputDir="$outputDir/test"
String testPrevDir="$testOutputDir/prev"
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.5'
compile 'org.codehaus.gpars:gpars:1.2.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5'
compile 'commons-cli:commons-cli:1.3'
testCompile 'junit:junit:4.12'
}
eclipse {
classpath {
defaultOutputDir = file('build')
}
}
//
// Auxilliary targets
//
task reverseVerbs (type: JavaExec, dependsOn: classes) {
def inputFile = "$affixDir/v.aff"
inputs.file inputFile
outputs.file "$affixDir/vr.aff"
classpath = sourceSets.main.runtimeClasspath
main = "org.dict_uk.expand.VerbReverse"
args file(inputFile), file(outputs.files[0])
// standardInput = file(inputFile).newInputStream()
// standardOutput = file(outputs.files[0]).newOutputStream()
}
task reverseAdvp (type: JavaExec, dependsOn: classes) {
def inputFile = "$affixDir/v_advp.aff"
inputs.file inputFile
outputs.file "$affixDir/vr_advp.aff"
classpath = sourceSets.main.runtimeClasspath
main = "org.dict_uk.expand.VerbReverse"
args file(inputFile), file(outputs.files[0])
}
task reverseAffix (dependsOn: [reverseVerbs, reverseAdvp]) {
}
task sortDict(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = "org.dict_uk.tools.Sort"
workingDir = file("data/dict")
def files = "alt.lst base-abbr.lst base.lst base-compound.lst colors.lst dot-abbr.lst geography.lst "
files += "slang.lst twisters.lst composite.lst ignored.lst names.lst rare.lst tags.lst"
args files.split()
}
//
// Testing targets
//
task testForCorp(type: JavaExec, dependsOn: [reverseAffix, classes]) {
classpath = sourceSets.main.runtimeClasspath
main = "org.dict_uk.expand.ExpandAll"
workingDir = file("out/test")
def opts = "--corp --indent --mfl --stats --wordlist"
args "-aff", "../../data/affix"
args "-dict", "."
args opts.split()
doLast {
def file="dict_corp_lt.txt"
def noTestOutputChange = (new File("$testOutputDir/$file").text == new File("$testPrevDir/$file").text)
assert noTestOutputChange
file="dict_corp_vis.txt"
noTestOutputChange = (new File("$testOutputDir/$file").text == new File("$testPrevDir/$file").text)
assert noTestOutputChange
}
}
task testForRules(type: JavaExec, dependsOn: [reverseAffix, classes]) {
classpath = sourceSets.main.runtimeClasspath
main = "org.dict_uk.expand.ExpandAll"
workingDir = file("out/test")
def opts = "--rules --mfl --wordlist --log-usage"
args "-aff", "../../data/affix"
args "-dict", "."
args opts.split()
doLast {
def file="dict_rules_lt.txt"
def noTestOutputChange = (new File("$testOutputDir/$file").text == new File("$testPrevDir/$file").text)
assert noTestOutputChange
}
}
task testExpand(dependsOn: [testForCorp, testForRules]) {
}
//
// Main targets
//
task expandForCorp(type: JavaExec, dependsOn: [reverseAffix, testForCorp]) {
classpath = sourceSets.main.runtimeClasspath
main = "org.dict_uk.expand.ExpandAll"
workingDir = file(outputDir)
// def opts = "--corp --indent --mfl --uncontr --stats --wordlist --time"
def opts = "--corp --indent --mfl --stats --wordlist --time"
args "-aff", "../data/affix"
args "-dict", "../data/dict"
args opts.split()
jvmArgs "-Xmx5g"
// jvmArgs "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n"
}
task expandForRules(type: JavaExec, dependsOn: [reverseAffix, testForRules]) {
classpath = sourceSets.main.runtimeClasspath
main = "org.dict_uk.expand.ExpandAll"
workingDir = file(outputDir)
def opts = "--rules --mfl --wordlist --time --log-usage"
args "-aff", "../data/affix"
args "-dict", "../data/dict"
args opts.split()
jvmArgs "-Xmx4g"
}
def get_diff_cmd(outputDir, file) {
return "diff -u $outputDir/prev/$file $outputDir/$file > $outputDir/${file}.diff || echo 'File $file differs!'"
}
task rulesDiff(type: Exec) {
def dictFile="dict_rules_lt.txt"
def cmd = get_diff_cmd(outputDir, dictFile)
cmd += "; " + get_diff_cmd(outputDir, 'words_spell.txt')
commandLine "sh", "-c", "${cmd}"
}
task corpDiff(type: Exec) {
def dictFile="dict_corp_lt.txt"
def cmd = get_diff_cmd(outputDir, dictFile)
cmd += "; " + get_diff_cmd(outputDir, 'words.txt')
cmd += "; " + get_diff_cmd(outputDir, 'lemmas.txt')
cmd += "; " + get_diff_cmd(outputDir, 'tags.txt')
dictFile="dict_corp_vis.txt"
cmd += "; " + get_diff_cmd(outputDir, dictFile)
commandLine "sh", "-c", "${cmd}"
}
task expandForCorpInteractive(type: JavaExec, dependsOn: reverseAffix) {
classpath = sourceSets.main.runtimeClasspath
main = "org.dict_uk.expand.Expand"
workingDir = file(outputDir)
standardInput = System.in
def opts = "--corp --indent -f"
args "-aff", "../data/affix"
args "-dict", "-"
args opts.split()
}
//
// deploy LT dict
//
task deployToLT(type: GradleBuild) {
dir = 'distr/language-dict-uk'
tasks = ['copyDictFiles']
}
task deployCorpToLT(type: GradleBuild) {
dir = 'distr/language-dict-uk'
tasks = ['switchToCorp', 'copyDictFiles']
}