/
build.gradle
356 lines (276 loc) · 8.84 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
buildscript {
apply from: "conf.gradle"
apply from: "sysconf/versions.gradle"
apply from: "sysconf/schemas.gradle"
repositories {
mavenCentral()
maven {
url "http://beta.hpcc.uh.edu/nexus/content/groups/public"
}
}
dependencies {
classpath group: 'edu.harvard.chs', name : 'cite' , version: versionMap['cite']
classpath group: 'org.homermultitext', name : 'citemgr' , version: versionMap['citemgr']
classpath group: 'edu.holycross.shot', name : 'hocuspocus' , version: versionMap['hocuspocus']
classpath group: 'edu.holycross.shot', name : 'prestochango' , version: versionMap['prestochango']
classpath group: 'edu.holycross.shot', name : 'abracadabra' , version: versionMap['abracadabra']
classpath group: 'edu.holycross.shot', name : 'nysi' , version: versionMap['nysi']
//classpath group: 'org.homermultitext', name : 'hmt-utils', version: versionMap['hmtutils']
}
}
import edu.holycross.shot.hocuspocus.Corpus
import edu.holycross.shot.prestochango.CollectionArchive
import edu.holycross.shot.abracadabra.CiteIndex
import edu.holycross.shot.nysi.ImgTurtleizer
import edu.holycross.shot.hocuspocus.TextInventory
import edu.harvard.chs.cite.CtsUrn
import org.apache.tools.ant.filters.*
apply plugin: "base"
/* Settings for Digital Scholarly Edition data */
/*
if (hasProperty('dse')) {
apply from: dse
}
*/
repositories {
mavenCentral()
maven {
url "http://beta.hpcc.uh.edu/nexus/content/groups/public"
}
maven {
url "https://oss.sonatype.org"
}
}
/*
task checkti(type: JavaExec) {
description = "Verifies contents of configured text inventory."
main = "org.homermultitext.citemanager.TIVerifier"
args = ["${ctsinventory}"]
classpath sourceSets.main.output.classesDir
classpath configurations.runtime
}
task checkccinv() {
description = "Verifies contents of configured collection inventory."
doLast {
System.err.println "checkccinv: not yet implemented."
}
}
task checkidxinv() {
description = "Verifies contents of configured collection inventory."
doLast {
System.err.println "checkidxinv: not yet implemented."
}
}
task checkimginv() {
description = "Verifies contents of configured collection inventory."
doLast {
System.err.println "checkimginv: not yet implemented."
}
}
*/
task ctstab() {
description = "Generates a tabular representation of all texts in configured text archive."
}
ctstab.doFirst() {
if (! buildDir.exists()) {
buildDir.mkdir()
}
File tabs = new File(buildDir, "tabs")
if (! tabs.exists()) {
tabs.mkdir()
}
}
ctstab.doLast() {
println "Tabulating corpus from configuration in " + ctsinventory + " and " + ctscitationconfig + " against local files in " + ctsarchive
println "Saving results in ${buildDir}/tabs"
File inv = new File("${ctsinventory}")
File citationConfig = new File("${ctscitationconfig}")
File textArchive = new File("${ctsarchive}")
File tiSchema = new File("${project.rootDir}/${textInvSchema}")
File citationConfSchema = new File("${project.rootDir}/${citationConfSchema}")
Corpus c = new Corpus(inv, citationConfig, textArchive, tiSchema)
//c.debug = 10
c.tabulateRepository(new File(buildDir, "tabs"))
}
task ctsttl() {
description = "Generates RDF representation of all texts in configured text archive"
}
ctsttl.doFirst {
println "Building RDF for corpus from configuration in " + ctsinventory + " and " + ctscitationconfig + " against local files in " + ctsarchive
println "Saving results in ${buildDir}/tabs"
}
ctsttl.doLast {
if (! buildDir.exists()) {
buildDir.mkdir()
}
File inv
File citeConf
File archiveDir
File citationConfig
String prefix = project.prefixString
if ((ctsinventory != "") && (ctsarchive != "")) {
try {
inv = new File("${ctsinventory}")
citeConf = new File("${ctscitationconfig}")
archiveDir = new File("${ctsarchive}")
citationConfig = new File("${ctscitationconfig}")
} catch (Exception e) {
System.err.println "ctsttl: unable to create inventory and archive!"
throw e
}
// TEST:
TextInventory ti = new TextInventory(inv)
Corpus c = new Corpus(inv,citationConfig,archiveDir, new File("${project.rootDir}/${textInvSchema}"))
System.err.println "Here are the files in my corpus; " + c.filesInArchive()
File ttlDir = new File(buildDir, "ttl")
if (! ttlDir.exists()) {
ttlDir.mkdir()
}
File ttlFile = new File(ttlDir,"cts.ttl")
c.turtleizeRepository(ttlDir, true)
}
}
task filterImgs(type: Copy) {
description = "Filter copies configurable image collection info."
from (file(imgcolldir)) {
include '*.csv'
}
filter(ReplaceTokens, tokens : [pyramids : pyramids] )
into "${buildDir}/images"
}
filterImgs.doFirst {
println "Filter copy images in " + imgcolldir
}
task imgttl(dependsOn: [filterImgs]) {
description = "Generates RDF for configured NYSI"
}
imgttl.doLast {
boolean prefix = project.hasProperty("prefixAll")
File rdfDir = new File("${buildDir}/ttl")
if (! rdfDir.exists()) {
rdfDir.mkdir()
}
File ttlFile = new File(rdfDir,"citeimgs.ttl")
ImgTurtleizer imgttl = new ImgTurtleizer("${buildDir}/images")
File imageDir = new File("${buildDir}/images")
if (! buildDir.exists()) {
buildDir.mkdir()
}
if (! imageDir.exists()) {
imageDir.mkdir()
}
imgttl.ttl(ttlFile, prefix)
}
task ccttl {
description = "Generates RDF for Collections configured for prestochango"
}
ccttl.doLast {
boolean prefix = project.hasProperty("prefixAll")
File schemaFile = new File("${project.rootDir}/${collectionInvSchema}")
if ((collinv != "") && (collarchive != "")) {
File invFile = new File(collinv)
File archiveDir = new File(collarchive)
CollectionArchive cc = new CollectionArchive(invFile, schemaFile, archiveDir)
//cc.debug = 5
println "\nFrom inventory in ${collinv} and data in ${collarchive}:"
println "\tCollection list: " + cc.getCollections() + "\n"
if (! buildDir.exists()) {
buildDir.mkdir()
}
File ttlDir = new File(buildDir, "ttl")
if (! ttlDir.exists()) {
ttlDir.mkdir()
}
File testOut = new File(ttlDir, "collections.ttl")
//testOut.setText(cc.turtleizeArchive())
//cc.ttl(testOut, prefix)
testOut.setText("")
if (prefix){ testOut << cc.prefix }
testOut << cc.ttlExtensionMap()
cc.collections.each { c ->
testOut << cc.turtleizeCollection(c)
}
}
}
task idxttl () {
description = "Generates RDF for indices configured for abracadabra"
}
idxttl.doLast {
boolean prefix = project.hasProperty("prefixAll")
File inv
File idxDir
if ((idxinv != "") && (idxarchive != "")) {
try {
inv = new File("${idxinv}")
idxDir = new File("${idxarchive}")
} catch (Exception e) {
System.err.println "idxttl: unable to make index inventory and archive."
throw e
}
CiteIndex idx = new CiteIndex(inv, idxDir)
if (! buildDir.exists()) {
buildDir.mkdir()
}
File ttlDir = new File(buildDir, "ttl")
if (! ttlDir.exists()) {
ttlDir.mkdir()
}
File outFile = new File (ttlDir,"indices.ttl")
idx.ttl(outFile, prefix)
}
}
//task ttl (dependsOn: [ctsttl, imgttl, ccttl, idxttl]) {
task ttl (dependsOn: [ctsttl, imgttl, ccttl, idxttl]) {
description = "Concatenates separate TTL files into a single graph."
doLast {
String charEnc = "UTF-8"
String prefix = "${prefixString}"
// TRY LIKE THIS ?
//src.withInputStream { input ->
// target << input
//}
def fileSet = [
new File("${buildDir}/ttl/cts.ttl"),
new File("${buildDir}/ttl/collections.ttl"),
new File("${buildDir}/ttl/indices.ttl"),
new File("${buildDir}/ttl/citeimgs.ttl")
]
File composite = new File(buildDir, "all.ttl")
fileSet.each { f ->
if (f.exists()) {
f.withInputStream { input ->
composite << input
}
//ttl.withWriterAppend(charEnc) { writer ->
// f.newReader(charEnc).eachLine {String line ->
// writer << "\n${line}"
// }
}
}
}
}
// too slow to tolerate :-(
/*
System.err.println "Adding data from cts ttl ..."
ctsttl.eachLine(charEnc) {
ttl.append("${it}\n")
}
System.err.println "Adding data from collections ttl ..."
collectionsttl.eachLine(charEnc) {
ttl.append("${it}\n")
}
System.err.println "Adding data from index ttl ..."
idxttl.eachLine(charEnc) {
ttl.append("${it}\n")
}
System.err.println "Adding data from image ttl ..."
citeimgttl.eachLine(charEnc) {
ttl.append("${it}\n")
}
*/
/*s
// Big project runs out of memory with this approach :-(
//+ ctsttl.getText(charEnc) + collectionsttl.getText(charEnc) + idxttl.getText(charEnc) + citeimgttl.getText(charEnc), charEnc)
System.out.println "\nCompleted generating all TTL in ${buildDir}/ttl.\n"
}
}*/