Statistics
| Revision:

root / tmp / org.txm.tigersearch.rcp / src / org / txm / importer / srcmf2 / TSImport.groovy @ 458

History | View | Annotate | Download (2.7 kB)

1
package org.txm.importer.srcmf2;
2

    
3
import java.io.File;
4
import java.util.ArrayList;
5
import ims.tiger.index.writer.*
6
import ims.tiger.system.*
7

    
8
import org.txm.importer.xtz.*
9
import org.txm.objects.BaseParameters
10
import org.txm.utils.io.FileCopy;
11
import org.apache.log4j.BasicConfigurator;
12

    
13
class TSImport extends XTZImport {
14
        
15
        public TSImport(BaseParameters params) {
16
                super(params);
17
        }
18
        
19
        @Override
20
        public void init(BaseParameters p) {
21
                super.init(p);
22
                
23
                importer = new TSImporter(this); // only to build metadata
24
                compiler = new XTZCompiler(this)
25
                annotater = null; // no annotater step to do
26
                pager = new XTZPager(this)
27
        }
28
        
29
        @Override
30
        public void start() throws InterruptedException {                
31
                File tigerSrcDir = new File(sourceDirectory, "XML-TS");
32
                if (!tigerSrcDir.exists()) tigerSrcDir = new File(sourceDirectory, "xml-ts");
33
                File xmltxmSrcDir = new File(sourceDirectory, "XML-TXM");
34
                if (!xmltxmSrcDir.exists()) xmltxmSrcDir = new File(sourceDirectory, "xml-txm");
35
                
36
                if (!tigerSrcDir.exists()) {
37
                        println "Error: the XML-TS directory was not found: "+tigerSrcDir
38
                        return
39
                }
40
                if (!xmltxmSrcDir.exists()) {
41
                        println "Error: the XML-XML directory was not found: "+tigerSrcDir
42
                        return
43
                }
44
                
45
                sourceDirectory = xmltxmSrcDir; // hop
46
                File txmDir = new File(binaryDirectory, "txm/"+corpusName); 
47
                txmDir.mkdirs();
48
                FileCopy.copyFiles(sourceDirectory, txmDir) // the compiler step will use these files
49
                super.start();
50
                
51
                if (isSuccessful) {
52
                        // TMR Modifications start here
53
                        File tigerDir = new File(binaryDirectory, "tiger");
54
                        tigerDir.mkdir();
55
                        File master = new File(tigerSrcDir, "master.xml");
56
                        
57
                        File logprop = new File(tigerDir, "tigersearch.logprop");
58
                        
59
                        logprop.withWriter("UTF-8") { writer ->
60
                                writer.write("""# Default log configuration of the TIGERSearch suite
61
log4j.rootLogger=WARN,Logfile
62
log4j.logger.ims.tiger.gui.tigersearch.TIGERSearch=INFO
63
log4j.appender.Logfile=org.apache.log4j.RollingFileAppender
64
log4j.appender.Logfile.File=\${user.home}/tigersearch/tigersearch.log
65
log4j.appender.Logfile.MaxFileSize=500KB
66
log4j.appender.Logfile.MaxBackupIndex=1
67
log4j.appender.Logfile.layout=org.apache.log4j.PatternLayout
68
log4j.appender.Logfile.layout.ConversionPattern=%5r %-5p [%t] %c{2} - %m%n""")        
69
                        }
70
                        
71
                        BasicConfigurator.configure();
72
                        String uri = master.getAbsolutePath();
73
                        File tigerBinDir = new File(tigerDir, corpusName)
74
                        tigerBinDir.mkdir()
75
                        try {
76
                                IndexBuilderErrorHandler handler = new SimpleErrorHandler(tigerBinDir.getAbsolutePath());
77
                                XMLIndexing indexing = new XMLIndexing(corpusName, uri, tigerBinDir.getAbsolutePath(), handler,false);
78
                                indexing.startIndexing();
79
                        }
80
                        catch (Exception e) { System.out.println(e.getMessage()); }
81
                }
82
        }
83
}