Révision 3768
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/TTAnnotater.groovy (revision 3768) | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 | 4 |
|
5 |
import org.txm.core.preferences.TBXPreferences |
|
5 | 6 |
import org.txm.importer.xmltxm.Annotate |
6 | 7 |
import org.txm.importer.xtz.* |
7 | 8 |
import org.txm.Toolbox |
8 | 9 |
import org.txm.core.engines.* |
10 |
import org.txm.importer.ApplyXsl2 |
|
9 | 11 |
|
10 | 12 |
/** |
11 | 13 |
* Wraps current Annotate class into the import workflow |
... | ... | |
25 | 27 |
//String model = module.getParameters().get(ImportKeys.TTMODEL); |
26 | 28 |
boolean cleanDirectories = module.getProject().getCleanAfterBuild(); |
27 | 29 |
|
30 |
boolean expertMode = TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER); |
|
31 |
|
|
28 | 32 |
String corpusname = module.getProject().getName(); |
29 | 33 |
String lang = module.getProject().getLang(); |
30 | 34 |
|
... | ... | |
44 | 48 |
} |
45 | 49 |
} |
46 | 50 |
|
51 |
if (isSuccessFul && expertMode) doPostNLPXSLStep(); |
|
52 |
|
|
47 | 53 |
if (cleanDirectories) { |
48 | 54 |
new File(module.getBinaryDirectory(), "treetagger").deleteDir() |
49 | 55 |
new File(module.getBinaryDirectory(), "ptreetagger").deleteDir() |
... | ... | |
52 | 58 |
|
53 | 59 |
if (!isSuccessFul) reason = "TreeTagger annotation failed." |
54 | 60 |
} |
61 |
|
|
62 |
/** |
|
63 |
* read from $inputDirectory and write the result in $bindir/txm |
|
64 |
* |
|
65 |
*/ |
|
66 |
public boolean doPostNLPXSLStep() { |
|
67 |
|
|
68 |
//filesToProcess = inputDirectory.listFiles(); |
|
69 |
|
|
70 |
File postnlpXSLdirectory = new File(module.getSourceDirectory(), "xsl/4-postnlp") |
|
71 |
|
|
72 |
def xslFiles = postnlpXSLdirectory.listFiles(new FileFilter() { |
|
73 |
public boolean accept(File pathname) { return pathname.getName().endsWith(".xsl");} |
|
74 |
}); |
|
75 |
def xslParams = project.getXsltParameters() |
|
76 |
xslParams["output-directory"] = outputDirectory.getAbsoluteFile().toURI().toString(); |
|
77 |
|
|
78 |
if (postnlpXSLdirectory.exists() && xslFiles != null && xslFiles.size() > 0) { |
|
79 |
|
|
80 |
def files = inputDirectory.listFiles() |
|
81 |
|
|
82 |
println "-- PostNLP XSL Step with the $postnlpXSLdirectory directory." |
|
83 |
xslFiles.sort() |
|
84 |
for (File xslFile : xslFiles) { |
|
85 |
if (xslFile.isDirectory() || xslFile.isHidden() || !xslFile.getName().endsWith(".xsl")) continue; |
|
86 |
//if (!xslFile.getName().matches("[1-9]-.+")) continue; |
|
87 |
|
|
88 |
if (ApplyXsl2.processImportSources(xslFile, files, xslParams)) { |
|
89 |
inputDirectory = outputDirectory; // the files to process are now in the "txm" directory |
|
90 |
println "" |
|
91 |
} else { |
|
92 |
reason = "Fail to apply post NLP XSL: $xslFile" |
|
93 |
return false; |
|
94 |
} |
|
95 |
} |
|
96 |
} else { |
|
97 |
//println "Nothing to do." |
|
98 |
} |
|
99 |
return true; |
|
100 |
} |
|
55 | 101 |
|
56 | 102 |
@Override |
57 | 103 |
public void cancel() { |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy (revision 3768) | ||
---|---|---|
126 | 126 |
|
127 | 127 |
// main workflow of XTZ importer step |
128 | 128 |
|
129 |
boolean expertMode = TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER); |
|
130 |
|
|
129 | 131 |
if (!doFixSurrogates()) return; |
130 | 132 |
if (!doSplitMergeXSLStep()) return; |
131 | 133 |
if (!doFrontXSLStep()) return; |
... | ... | |
135 | 137 |
if (!doEncodeMileStonesStep()) return; |
136 | 138 |
if (!doToXMLTXMStep()) return; |
137 | 139 |
if (!doInjectMetadataStep()) return; |
140 |
if (expertMode && !doBackXSLStep()) return; |
|
138 | 141 |
|
139 | 142 |
isSuccessFul = filesToProcess.size() > 0 |
140 | 143 |
|
... | ... | |
289 | 292 |
inputDirectory = outputDirectory; // the files to process are now in the "txm" directory |
290 | 293 |
println "" |
291 | 294 |
} else { |
292 |
reason = "Fail to apply front XSL: $xslPath"
|
|
295 |
reason = "Fail to apply front XSL: $xslFile"
|
|
293 | 296 |
return false; |
294 | 297 |
} |
295 | 298 |
} |
... | ... | |
299 | 302 |
return true; |
300 | 303 |
} |
301 | 304 |
|
305 |
/** |
|
306 |
* read from $inputDirectory and write the result in $bindir/txm |
|
307 |
* |
|
308 |
*/ |
|
309 |
public boolean doBackXSLStep() { |
|
310 |
|
|
311 |
//filesToProcess = inputDirectory.listFiles(); |
|
312 |
|
|
313 |
File backXSLdirectory = new File(module.getSourceDirectory(), "xsl/4-back") |
|
314 |
|
|
315 |
def xslFiles = backXSLdirectory.listFiles(new FileFilter() { |
|
316 |
public boolean accept(File pathname) { return pathname.getName().endsWith(".xsl");} |
|
317 |
}); |
|
318 |
|
|
319 |
xslParams["output-directory"] = outputDirectory.getAbsoluteFile().toURI().toString(); |
|
320 |
|
|
321 |
if (backXSLdirectory.exists() && xslFiles != null && xslFiles.size() > 0) { |
|
322 |
|
|
323 |
println "-- Back XSL Step with the $backXSLdirectory directory." |
|
324 |
xslFiles.sort() |
|
325 |
for (File xslFile : xslFiles) { |
|
326 |
if (xslFile.isDirectory() || xslFile.isHidden() || !xslFile.getName().endsWith(".xsl")) continue; |
|
327 |
//if (!xslFile.getName().matches("[1-9]-.+")) continue; |
|
328 |
|
|
329 |
if (ApplyXsl2.processImportSources(xslFile, filesToProcess, xslParams)) { |
|
330 |
println "" |
|
331 |
} else { |
|
332 |
reason = "Fail to apply back XSL: $xslFile" |
|
333 |
return false; |
|
334 |
} |
|
335 |
} |
|
336 |
} else { |
|
337 |
//println "Nothing to do." |
|
338 |
} |
|
339 |
return true; |
|
340 |
} |
|
341 |
|
|
302 | 342 |
public boolean doCheckXMLFileStep() { |
303 | 343 |
filesToProcess = [] |
304 | 344 |
println "-- Checking XML-TEI files for well-formedness." |
TXM/trunk/bundles/org.txm.core/src/java/org/txm/importer/ApplyXsl2.java (revision 3768) | ||
---|---|---|
436 | 436 |
cpb.tick(); |
437 | 437 |
File outfile = new File(outdir, name); |
438 | 438 |
|
439 |
if (!f.getAbsolutePath().equals(outfile.getAbsolutePath()) && f.lastModified() <= outfile.lastModified()) { |
|
440 |
if (debug) System.out.println("skipped: " + f);
|
|
441 |
continue; // input file is older than output file |
|
442 |
} |
|
439 |
// if (!f.getAbsolutePath().equals(outfile.getAbsolutePath()) && f.lastModified() <= outfile.lastModified()) {
|
|
440 |
// if (debug) System.out.println("Skipping: " + f);
|
|
441 |
// continue; // input file is older than output file
|
|
442 |
// }
|
|
443 | 443 |
|
444 | 444 |
if (deleteOutput) outfile = null; // if outfile is null builder.process won't create the output file adn will replace f |
445 | 445 |
|
Formats disponibles : Unified diff