Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / scripts / importer / xtz / TTAnnotater.groovy @ 1137

History | View | Annotate | Download (1.4 kB)

1
package org.txm.scripts.importer.xtz
2

    
3
import java.io.File;
4

    
5
import org.txm.importer.xmltxm.Annotate
6
import org.txm.importer.xtz.*
7
import org.txm.Toolbox
8
import org.txm.core.engines.*
9

    
10
/**
11
 * Wraps current Annotate class into the import workflow
12
 * 
13
 * @author mdecorde
14
 *
15
 */
16
class TTAnnotater extends Annotater {
17

    
18
        public TTAnnotater(ImportModule module) {
19
                super(module);
20
        }
21

    
22
        @Override
23
        public void process() {
24

    
25
                //String model = module.getParameters().get(ImportKeys.TTMODEL);
26
                boolean cleanDirectories = module.getProject().getCleanAfterBuild();
27
                
28
                String corpusname = module.getProject().getName();
29
                String lang = module.getProject().getLang();
30

    
31
                def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
32
                if (module.isMultiThread()) {
33
                        def hash = [:]
34
                        for (File txmFile : inputDirectory.listFiles()) {
35
                                hash[txmFile.getName()] = lang;
36
                        }
37
                        if (engine.processDirectory(inputDirectory, module.getBinaryDirectory(), ["langs":hash])) {
38
                                isSuccessFul = true;
39
                        }
40
                } else {
41
                        if (engine.processDirectory(inputDirectory, module.getBinaryDirectory(), ["lang":lang])) {
42
                                isSuccessFul = true;
43
                        }
44
                }
45
                
46
                if (cleanDirectories) {
47
                        new File(module.getBinaryDirectory(), "treetagger").deleteDir()
48
                        new File(module.getBinaryDirectory(), "annotations").deleteDir()
49
                }
50
                
51
                if (!isSuccessFul) reason = "TreeTagger annotation failed."
52
        }
53

    
54
        @Override
55
        public void cancel() {
56
                //a.setCancelNow();
57
        }
58
}