Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / importer / xtz / xtzLoader.groovy @ 479

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
//
23
//
24
// $LastChangedDate: 2015-06-03 15:04:53 +0200 (mer., 03 juin 2015) $
25
// $LastChangedRevision: 2984 $
26
// $LastChangedBy: mdecorde $
27
//
28
package org.txm.importer.xtz;
29

    
30
import javax.xml.stream.*
31

    
32
import org.txm.*
33
import org.txm.metadatas.*
34
import org.txm.objects.*
35
import org.txm.scripts.teitxm.*
36
import org.txm.tokenizer.TokenizerClasses
37
import org.txm.utils.*
38
import org.txm.utils.i18n.*
39

    
40
String userDir = System.getProperty("user.home");
41

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

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

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

    
68
//params.getKeyValueParameters().put(ImportKeys.CLEAN, "false")
69
//params.getKeyValueParameters().put(ImportKeys.MULTITHREAD, "false")
70
//params.getKeyValueParameters().put(ImportKeys.DEBUG, "false")
71
//params.getKeyValueParameters().put(ImportKeys.UPDATECORPUS, "false")
72

    
73
XTZImport i = new XTZImport(params);
74
/*
75
 * To customize the XTZ import, replace the importer, compiler, annotater or pager objects before calling process()
76
                i.importer = new XTZImporter(i)
77
                i.compiler = new XTZCompiler(i)
78
                i.annotater = new TTAnnotater(i);
79
                i.pager = new XTZPager(i)
80
 */
81
i.process();
82
readyToLoad = i.isSuccessful