Révision 2928
tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/Annotate.groovy (revision 2928) | ||
---|---|---|
127 | 127 |
* @param rootDirFile the root dir file |
128 | 128 |
* @param modelfile the modelfile |
129 | 129 |
*/ |
130 |
public void initTTOutfileInfos(File rootDirFile, File modelfile, String modelfilename) |
|
131 |
{ |
|
130 |
public void initTTOutfileInfos(File rootDirFile, File modelfile, String modelfilename) { |
|
132 | 131 |
initTTOutfileInfos(rootDirFile, modelfile, modelfilename, null); |
133 | 132 |
} |
134 | 133 |
|
... | ... | |
139 | 138 |
* @param modelfile the modelfile |
140 | 139 |
* @param properties : 2 element array that contains the word properties to create. It can be null (the modelfilename will be used) |
141 | 140 |
*/ |
142 |
public void initTTOutfileInfos(File rootDirFile, File modelfile, String modelfilename, String[] properties) |
|
143 |
{ |
|
141 |
public void initTTOutfileInfos(File rootDirFile, File modelfile, String modelfilename, String[] properties) {
|
|
142 |
|
|
144 | 143 |
id = modelfilename; |
145 | 144 |
String[] split = id.split("\\."); |
146 | 145 |
if (split.length > 0) id = split[0]; |
... | ... | |
170 | 169 |
} |
171 | 170 |
|
172 | 171 |
//TODO: the tagset, website and description should be referenced in the model catalog |
173 |
if(modelfile.getName() == "rgaqcj.par") { |
|
172 |
if (modelfile.getName() == "rgaqcj.par") {
|
|
174 | 173 |
typesDesc = [ |
175 | 174 |
"CATTEX pos tagset built with BFM texts", |
176 | 175 |
"fr lemma of the model "+modelfile+" - " |
... | ... | |
216 | 215 |
* @param options, if null use value set in Toolbox preferences |
217 | 216 |
* @return true, if successful |
218 | 217 |
*/ |
219 |
public boolean applyTT(File ttsrcfile, File ttoutfile, File modelfile, String[] options) |
|
220 |
{ |
|
218 |
public boolean applyTT(File ttsrcfile, File ttoutfile, File modelfile, String[] options) {
|
|
219 |
|
|
221 | 220 |
try { |
222 | 221 |
File infile = ttsrcfile; |
223 | 222 |
File outfile = ttoutfile; |
... | ... | |
336 | 335 |
System.out.println("Failed to build tt src file of "+srcfile); |
337 | 336 |
} |
338 | 337 |
|
339 |
if (cancelNow) return; |
|
338 |
if (cancelNow) { |
|
339 |
return false; |
|
340 |
} |
|
340 | 341 |
|
341 | 342 |
File modelDirectory = new File(TreeTaggerPreferences.getInstance().getString(TreeTaggerPreferences.MODELS_PATH)); |
342 | 343 |
if (!modelDirectory.exists()) { |
... | ... | |
352 | 353 |
//APPLY TREETAGGER |
353 | 354 |
files = new File(binDir, "treetagger").listFiles(IOUtils.HIDDENFILE_FILTER) |
354 | 355 |
println("Applying $modelfilename TreeTagger model on dir: "+new File(binDir, "treetagger")+ " ("+files.size()+" files)") |
355 |
if (files == null || files.size() == 0) |
|
356 |
if (files == null || files.size() == 0) {
|
|
356 | 357 |
return false; |
358 |
} |
|
357 | 359 |
File modelfile; |
358 | 360 |
cpb = new ConsoleProgressBar(files.size()) |
359 | 361 |
for (File f : files) { |
... | ... | |
404 | 406 |
} |
405 | 407 |
println("") |
406 | 408 |
|
407 |
if (cancelNow) return; |
|
409 |
if (cancelNow) { |
|
410 |
return false; |
|
411 |
} |
|
408 | 412 |
|
409 | 413 |
//BUILD STAND-OFF FILES |
410 | 414 |
if (modelfile == null) { |
... | ... | |
415 | 419 |
initTTOutfileInfos(binDir, modelfile, modelfilename); |
416 | 420 |
files = new File(binDir, "treetagger").listFiles(IOUtils.HIDDENFILE_FILTER)// now contains the result files of TT |
417 | 421 |
println "Building stdoff files ("+files.size()+") from dir:"+new File(binDir, "treetagger")+" to "+new File(binDir, "annotations"); |
418 |
if (files == null || files.size() == 0) |
|
422 |
if (files == null || files.size() == 0) {
|
|
419 | 423 |
return false; |
424 |
} |
|
420 | 425 |
cpb = new ConsoleProgressBar(files.size()) |
421 | 426 |
for (File ttrezfile : files) { |
422 | 427 |
cpb.tick() |
423 | 428 |
File annotfile = new File(binDir, "annotations/"+ttrezfile.getName()+"-STOFF.xml"); |
424 |
if (!writeStandoffFile(ttrezfile, annotfile)) |
|
429 |
if (!writeStandoffFile(ttrezfile, annotfile)) {
|
|
425 | 430 |
println("Failed to build standoff file of "+ttrezfile); |
431 |
} |
|
426 | 432 |
} |
427 | 433 |
println("") |
428 | 434 |
|
... | ... | |
473 | 479 |
* @param lang associate a file name with a model filename |
474 | 480 |
* @return true, if successful |
475 | 481 |
*/ |
476 |
public boolean run(File binDir, File txmDir, HashMap<String, String> langs) |
|
477 |
{ |
|
482 |
public boolean run(File binDir, File txmDir, HashMap<String, String> langs) { |
|
478 | 483 |
return run(binDir, txmDir, langs, false, new String[0], new String[0]); |
479 | 484 |
} |
480 | 485 |
|
... | ... | |
487 | 492 |
* @param replace, replace or create a word property |
488 | 493 |
* @return true, if successful |
489 | 494 |
*/ |
490 |
public boolean run(File binDir, File txmDir, HashMap<String, String> langs, boolean replace, String[] properties, String[] options) |
|
491 |
{ |
|
495 |
public boolean run(File binDir, File txmDir, HashMap<String, String> langs, boolean replace, String[] properties, String[] options) {
|
|
496 |
|
|
492 | 497 |
if (!new File(TreeTaggerPreferences.getInstance().getString(TreeTaggerPreferences.INSTALL_PATH)+"/bin/").exists()) { |
493 | 498 |
println("Path to TreeTagger is wrong "+TreeTaggerPreferences.getInstance().getString(TreeTaggerPreferences.INSTALL_PATH)+"/bin/") |
494 | 499 |
return true; |
... | ... | |
540 | 545 |
println "" |
541 | 546 |
return true; |
542 | 547 |
} |
548 |
|
|
543 | 549 |
public boolean run(File f, String lang, File binDir, File txmDir) { |
544 | 550 |
|
545 | 551 |
File annotDir = new File(binDir,"annotations"); |
... | ... | |
552 | 558 |
return run(f, lang, binDir, txmDir, false, new String[0], new String[0], annotDir, ptreetaggerDir, treetaggerDir) |
553 | 559 |
} |
554 | 560 |
|
555 |
|
|
556 | 561 |
public boolean run(File f, String lang, File binDir, File txmDir, boolean replace, String[] properties, String[] options, File annotDir, File ptreetaggerDir, File treetaggerDir) { |
557 | 562 |
|
558 | 563 |
File modelfile = new File(modelsDirectory, lang+".par"); |
Formats disponibles : Unified diff