Statistics
| Revision:

root / tmp / org.txm.tigersearch.rcp / bin / org / txm / importer / srcmf2 / srcmfLoader.groovy @ 458

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.srcmf2;
29

    
30
import javax.xml.stream.XMLStreamReader;
31

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

    
47
String userDir = System.getProperty("user.home");
48

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

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

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

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

    
80
TSImport i = new TSImport(params);
81
i.process();
82
readyToLoad = i.isSuccessful