Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / scripts / importer / bvh / bvhLoader.groovy @ 1000

History | View | Annotate | Download (4.4 kB)

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

    
35
import java.io.File;
36
import org.txm.scripts.importer.bvh.importer;
37
import org.txm.scripts.importer.bvh.compiler;
38
import org.txm.scripts.importer.bvh.annotate;
39
import org.txm.scripts.importer.bvh.pager;
40
import org.txm.objects.*;
41
import org.txm.*;
42
import org.txm.core.engines.*;
43
import org.txm.importer.scripts.xmltxm.*;
44
import org.txm.utils.i18n.*;
45

    
46
// TODO: Auto-generated Javadoc
47
/**
48
 * Run.
49
 *
50
 * @return the java.lang. object
51
 * @author mdecorde
52
 */
53

    
54
String userDir = System.getProperty("user.home");
55
String lang;
56
String encoding;
57
String rootDir;
58
String model;
59
String basename;
60
try{rootDir = rootDirBinding;lang=langBinding;encoding=encodingBinding;model=modelBinding;basename=basenameBinding}
61
catch(Exception)
62
{        println "DEV MODE";//exception means we debug
63
        if(!org.txm.Toolbox.isInitialized())
64
        {
65
                rootDir = userDir+"/xml/bvh/";
66
                lang="fr";
67
                encoding= "UTF-8";// not used by bvh
68
                model="rgaqcj"; //not used by bvh
69
                basename="bvh"
70
                Toolbox.workspace = new Workspace(new File(userDir,"TXM/workspaces/default.xml"));
71
                Toolbox.setParam(Toolbox.INSTALL_DIR,new File(userDir,"TXM"));
72
                Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
73
                Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ",");
74
                Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\"");
75
                Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"),"TXM"));
76
        }
77
}
78

    
79
println "IMPORTER"
80
new importer().run(new File(rootDir), basename);
81

    
82
File binDir = new File(Toolbox.getTxmHomePath(),"corpora/"+basename);
83
rootDir = binDir.getAbsolutePath();
84

    
85
println "ANNOTATE - fr "
86
new Annotate().run(new File(rootDir),"fr.par");//the files in ./txm
87

    
88
println "ANNOTATE - afr"
89
def secondannotator = new Annotate()
90
secondannotator.run(new File(rootDir),"afr.par");//the files in ./txm
91

    
92
println "--COMPILING"
93
File dir = new File(rootDir);
94
def c = new compiler();
95
c.setDebug();
96
//c.setCwbPath("~/TXM/cwb/bin");
97
c.setLang(lang);
98
if (!c.run(dir)) {
99
        println "Compiler failed"
100
        return;
101
}
102

    
103
//move registry file to cwb registry dir
104
File registryfile = new File(rootDir+"/registry",basename);
105
if(registryfile.exists())
106
        org.txm.utils.io.FileCopy.copy(registryfile,new File(Toolbox.getTxmHomePath(),"registry/"+basename))
107

    
108
Workspace w = org.txm.Toolbox.workspace;
109
Project p = w.getProject("default")
110
p.removeBase(basename)
111
Base b = p.addBase(basename);
112
b.addDirectory(new File(rootDir,"txm"));
113
b.setAttribute("lang", lang)
114
b.propagateAttribute("lang")
115

    
116
println "-- EDITION"
117
new File(rootDir+"/HTML/").deleteDir()
118
new File(rootDir+"/HTML/").mkdir();
119
new File(rootDir+"/HTML/default/").mkdir();
120
files = new File(rootDir,"txm").listFiles();
121

    
122
for(Text text : b.getTexts())
123
{
124
        File srcfile = text.getSource();
125
        File resultfile = new File(rootDir+"/HTML",srcfile.getName().substring(0,srcfile.getName().length()-4)+".html");
126
        List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang);
127
        List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang);
128
        println("Building edition  : "+srcfile+" to : "+resultfile );
129
        
130
        def ed = new pager(srcfile,resultfile, NoSpaceBefore, NoSpaceAfter,600);
131
        Edition editionweb = text.addEdition("default","html",resultfile);
132

    
133
        for(int i = 0 ; i < ed.getPageFiles().size();i++)
134
        {
135
                File f = ed.getPageFiles().get(i);
136
                String idx = ed.getIdx().get(i);
137
                editionweb.addPage(f,idx);
138
        }
139
        
140
//        Edition editionbp = text.addEdition("onepage","html",resultfile);
141
//        editionbp.addPage(resultfile,ed.getIdx().get(0));
142
}
143

    
144
w.save();