Statistics
| Revision:

root / tmp / org.txm.tigersearch.rcp / groovy / org / txm / scripts / importer / tigersearch / tigersearchLoader.groovy @ 1000

History | View | Annotate | Download (3.2 kB)

1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
//
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
//
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
//
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
//
22
// $LastChangedDate: 2015-06-03 15:04:53 +0200 (mer., 03 juin 2015) $
23
// $LastChangedRevision: 2984 $
24
// $LastChangedBy: mdecorde $
25
//
26
package org.txm.scripts.importer.tigersearch;
27

    
28
import javax.xml.stream.XMLStreamReader;
29

    
30
import org.txm.scripts.importer.RemoveTag;
31
import org.txm.importer.ApplyXsl2;
32
import org.txm.importer.ValidateXml;
33
import org.txm.objects.*;
34
import org.txm.tokenizer.TokenizerClasses;
35
import org.txm.utils.*;
36
import org.txm.*;
37
import org.txm.importer.xmltxm.*;
38
import org.txm.utils.i18n.*;
39
import org.txm.metadatas.*;
40
import javax.xml.stream.*;
41
import org.w3c.dom.Element
42
import org.txm.utils.xml.DomUtils;
43
import org.txm.importer.xtz.*
44

    
45
String userDir = System.getProperty("user.home");
46

    
47
def MONITOR;
48
boolean debug = org.txm.utils.logger.Log.isPrintingErrors();
49
BaseParameters params;
50
try {params = paramsBinding;MONITOR=monitor} catch (Exception)
51
{        println "DEV MODE";//exception means we debug
52
        debug = true
53
        params = new BaseParameters(new File(userDir, "xml/roland/import.xml"))
54
        params.load()
55
        if (!org.txm.Toolbox.isInitialized()) {
56

    
57
                TokenizerClasses.loadFromNode(params.getTokenizerElement(params.getCorpusElement()));
58
                Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
59
                //Toolbox.setParam(Toolbox.INSTALL_DIR,new File("C:\\Program Files\\TXM"));//For Windows
60
                Toolbox.setParam(Toolbox.TREETAGGER_INSTALL_PATH,new File(userDir,"treetagger"));
61
                //Toolbox.setParam(Toolbox.TREETAGGER_INSTALL_PATH,new File("C:\\Program Files\\treetagger"));//for Windows
62
                Toolbox.setParam(Toolbox.TREETAGGER_MODELS_PATH,new File(userDir,"treetagger/models"));
63
                Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
64
                Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ",");
65
                Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\"");
66
                //Toolbox.setParam(Toolbox.TREETAGGER_MODELS_PATH,new File("C:\\Program Files\\treetagger\\models"));//for Windows
67
                Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"), "TXM"));
68
        }
69
}
70

    
71
if (params == null) { println "no parameters. Aborting"; return; }
72

    
73
//params.getKeyValueParameters().put(ImportKeys.CLEAN, "false")
74
//params.getKeyValueParameters().put(ImportKeys.MULTITHREAD, "false")
75
//params.getKeyValueParameters().put(ImportKeys.DEBUG, "false")
76
//params.getKeyValueParameters().put(ImportKeys.UPDATECORPUS, "false")
77

    
78
TSImport i = new TSImport(params);
79
i.process();
80
readyToLoad = i.isSuccessful