Révision 2969

tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/PrepareAFVOIXOFFCorpusMacro.groovy (revision 2969)
62 62
backtomedia/sync_mode=Structure
63 63
concordance/context_limits=text
64 64
concordance/context_limits_type=list
65
concordance/view_reference_pattern={"format"\\:"","properties"\\:["text_datedediffusion","u_time","div_identifiantdelanotice"]}
66
concordance/sort_reference_pattern={"format"\\:"","properties"\\:["text_datedediffusion","u_time","div_identifiantdelanotice"]}
65
concordance/view_reference_pattern={"format"\\:"","properties"\\:["text_date-de-diffusion","u_time","div_identifiant-de-la-notice"]}
66
concordance/sort_reference_pattern={"format"\\:"","properties"\\:["text_date-de-diffusion","u_time","div_identifiant-de-la-notice"]}
67 67
concordance/name=concordance
68 68
eclipse.preferences.version=1"""
69 69

  
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/transcriberLoader.groovy (revision 2969)
67 67
String userDir = System.getProperty("user.home");
68 68

  
69 69
def MONITOR;
70
Project project;
70
Project corpusProject;
71 71

  
72
try {project=projectBinding;MONITOR=monitor} catch (Exception)
72
try {corpusProject=projectBinding;MONITOR=monitor} catch (Exception)
73 73
{	}
74
if (project == null) { println "no project set. Aborting"; return; }
74
if (corpusProject == null) { println "no project set. Aborting"; return; }
75 75

  
76
String corpusname = project.getName();
76
String corpusname = corpusProject.getName();
77 77
String basename = corpusname
78
String rootDir = project.getSrcdir();
79
String lang = project.getLang()
78
String rootDir = corpusProject.getSrcdir();
79
String lang = corpusProject.getLang()
80 80
String model = lang
81
String encoding = project.getEncoding()
82
boolean annotate = project.getAnnotate()
83
String xsl = project.getFrontXSL();
84
def xslParams = project.getXsltParameters();
85
int wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
86
String page_element = project.getEditionDefinition("default").getPageElement()
87
boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
88
boolean update = project.getDoUpdate()
81
String encoding = corpusProject.getEncoding()
82
boolean annotate = corpusProject.getAnnotate()
83
String xsl = corpusProject.getFrontXSL();
84
def xslParams = corpusProject.getXsltParameters();
85
int wordsPerPage = corpusProject.getEditionDefinition("default").getWordsPerPage()
86
String page_element = corpusProject.getEditionDefinition("default").getPageElement()
87
boolean build_edition = corpusProject.getEditionDefinition("default").getBuildEdition()
88
boolean update = corpusProject.getDoUpdate()
89 89

  
90 90
File srcDir = new File(rootDir);
91
File binDir = project.getProjectDirectory();
91
File binDir = corpusProject.getProjectDirectory();
92 92
binDir.mkdirs();
93 93
if (!binDir.exists()) {
94 94
	println "Could not create binDir "+binDir
......
195 195
		if (MONITOR != null) MONITOR.worked(1, "IMPORTER")
196 196
		if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
197 197
		println "-- IMPORTER"
198
		def imp = new importer(trsfiles, binDir, txmDir, metadatas, lang) //put result in the txm folder of binDir
198
		def imp = new importer(trsfiles, binDir, txmDir, metadatas, lang, corpusProject) //put result in the txm folder of binDir
199 199
		if (!imp.run()) {
200 200
			println "Failed to prepare files - Aborting";
201 201
			return;
......
245 245
			def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
246 246
			if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
247 247
				annotationSuccess = true;
248
				
249
				String cleanDirectories = corpusProject.getCleanAfterBuild();
250
				if ("true".equals(cleanDirectories)) {
251
					new File(corpusProject.getProjectDirectory(), "ptreetagger").deleteDir()
252
					new File(corpusProject.getProjectDirectory(), "treetagger").deleteDir()
253
					new File(corpusProject.getProjectDirectory(), "annotations").deleteDir()
254
				}
248 255
			}
249 256
		}
250 257
	} // end of importer and annotate steps
......
280 287
	if(debug) comp.setDebug();
281 288
	comp.removeInterviewers(removeInterviewer);
282 289
	comp.setIgnoreTranscriberMetadata(ignoreTranscriberMetadata);
283
	if (!comp.run(project, xmltxmFiles, corpusname, "default", binDir)) {
290
	if (!comp.run(corpusProject, xmltxmFiles, corpusname, "default", binDir)) {
284 291
		println "Failed to compile files";
285 292
		return;
286 293
	}
......
308 315
			List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang);
309 316
			List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang);
310 317

  
311
			Text t = project.getText(txtname)
318
			Text t = corpusProject.getText(txtname)
312 319
			if (t == null) {
313
				t = new Text(project);
320
				t = new Text(corpusProject);
314 321
				t.setName(txtname);
315 322
			}
316 323
			t.setSourceFile(txmFile)
......
340 347
		File cssfile = new File(Toolbox.getTxmHomePath(), "css/transcriber.css")
341 348
		File cssTXMFile = new File(Toolbox.getTxmHomePath(), "css/txm.css")
342 349
		if (cssfile.exists() && htmlDir.exists()) {
343
			FileCopy.copy(cssfile, new File(htmlDir, "onepage/transcriber.css"));
344 350
			FileCopy.copy(cssfile, new File(htmlDir, "default/txm.css"));
345 351
			FileCopy.copy(cssfile, new File(htmlDir, "default/transcriber.css"));
346 352
		}
......
353 359
			String txtname = txmFile.getName();
354 360
			int i = txtname.lastIndexOf(".");
355 361
			if(i > 0) txtname = txtname.substring(0, i);
356
			File mediaFile = new File(project.getSrcdir(), txtname + ".mp3")
357
			if (!mediaFile.exists()) mediaFile = new File(project.getSrcdir(), txtname + ".wav")
358
			if (!mediaFile.exists()) mediaFile = new File(project.getSrcdir(), txtname + ".mp4")
359
			if (!mediaFile.exists()) mediaFile = new File(project.getSrcdir(), txtname + ".avi")
362
			File mediaFile = new File(corpusProject.getSrcdir(), txtname + ".mp3")
363
			if (!mediaFile.exists()) mediaFile = new File(corpusProject.getSrcdir(), txtname + ".wav")
364
			if (!mediaFile.exists()) mediaFile = new File(corpusProject.getSrcdir(), txtname + ".mp4")
365
			if (!mediaFile.exists()) mediaFile = new File(corpusProject.getSrcdir(), txtname + ".avi")
360 366

  
361 367
			if (mediaFile.exists()) {
362 368
				File copy = new File(binDir, "media/"+mediaFile.getName())
......
371 377

  
372 378
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
373 379
if (MONITOR != null) MONITOR.worked(20, "FINALIZING")
374
readyToLoad = project.save();
380
readyToLoad = corpusProject.save();
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/compiler.groovy (revision 2969)
117 117
	 * @param outdir the outdir
118 118
	 * @return true, if successful
119 119
	 */
120
	public boolean run(Project project, List<File> xmlfiles, String corpusname, String projectname, File binDir) {
120
	public boolean run(Project corpusProject, List<File> xmlfiles, String corpusname, String projectname, File binDir) {
121 121
		
122 122
		//println "run compiler with $xmlfiles, $basename and $outdir"
123 123
		this.outdir = binDir;
......
129 129

  
130 130
		sectionAttrs = new HashSet<String>() // reset section attributs set
131 131

  
132
		CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class);
132
		CorpusBuild corpus = corpusProject.getCorpusBuild(corpusProject.getName(), MainCorpus.class);
133 133
		if (corpus != null) {
134
			if (project.getDoUpdate()) {
134
			if (corpusProject.getDoUpdate()) {
135 135
				corpus.clean(); // remove old files
136 136
			} else {
137 137
				corpus.delete(); // remove old files and TXMResult children
138 138
			}
139 139
		} else {
140
			corpus = new MainCorpus(project);
141
			corpus.setID(project.getName());
142
			corpus.setName(project.getName());
140
			corpus = new MainCorpus(corpusProject);
141
			corpus.setID(corpusProject.getName());
142
			corpus.setName(corpusProject.getName());
143 143
		}
144 144
		corpus.setDescription("Built with the XML-TRS import module");
145 145
		
......
237 237

  
238 238
		} catch (Exception ex) {System.out.println(ex); return false;}
239 239

  
240
		String cleanDirectories = corpusProject.getCleanAfterBuild();
241
		if ("true".equals(cleanDirectories)) {
242
			new File(corpusProject.getProjectDirectory(), "cqp").deleteDir()
243
		}
244
		
240 245
		return true;
241 246
	}
242 247

  
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/importer.groovy (revision 2969)
52 52
import java.util.HashMap;
53 53
import org.txm.scripts.importer.*;
54 54
import org.txm.utils.*;
55
import org.txm.objects.Project;
55 56
import org.txm.metadatas.*;
56 57

  
57 58
/**
......
82 83
	Metadatas metadatas;
83 84

  
84 85
	String lang; // language used by the tokenizer
86
	
87
	Project corpusProject;
85 88

  
86 89
	/**
87 90
	 * Instantiates a new importer.
......
90 93
	 * @param outdir the outdir
91 94
	 * @param metadatas the metadatas
92 95
	 */
93
	public importer(ArrayList<File> trsfiles, File binDir, File txmDir, Metadatas metadatas, lang) {
96
	public importer(ArrayList<File> trsfiles, File binDir, File txmDir, Metadatas metadatas, lang, Project corpusProject) {
94 97
		this.trsfiles = trsfiles;
95 98
		this.txmDir = txmDir;
96 99
		this.binDir = binDir;
97 100
		this.metadatas = metadatas;
98 101
		this.lang = lang;
102
		this.corpusProject = corpusProject;
99 103
	}
100 104

  
101 105
	/**
......
245 249
			}
246 250
		}
247 251

  
252
		String cleanDirectories = corpusProject.getCleanAfterBuild();
253
		if ("true".equals(cleanDirectories)) {
254
			new File(corpusProject.getProjectDirectory(), "tokenized").deleteDir()
255
			new File(corpusProject.getProjectDirectory(), "src").deleteDir()
256
			new File(corpusProject.getProjectDirectory(), "split").deleteDir()
257
		}
258
		
248 259
		cpb.done()
249 260
				
250 261
		return txmDir.listFiles() != null;
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/ImportModuleCustomization.java (revision 2969)
4 4

  
5 5
/**
6 6
 * static class that defines what parameters are used by import modules
7
 * 
7 8
 * @author mdecorde
8 9
 *
9 10
 */
10 11
public class ImportModuleCustomization {
11 12
	
12 13
	public static final String PARALLEL = "parallel"; //$NON-NLS-1$
14
	
13 15
	public static final String ENCODING = "encoding"; //$NON-NLS-1$
16
	
14 17
	public static final String LANG = "lang"; //$NON-NLS-1$
18
	
15 19
	public static final String XSLT = "xslt"; //$NON-NLS-1$
20
	
16 21
	public static final String TOKENIZER = "tokenizer"; //$NON-NLS-1$
22
	
17 23
	public static final String ADVANCEDTOKENIZER = "tokenizer-advanced"; //$NON-NLS-1$
24
	
18 25
	public static final String EDITIONS_WORDSPERPAGE = "editions-wordsperpage"; //$NON-NLS-1$
26
	
19 27
	public static final String EDITIONS_PAGEELEMENT = "editions-pageelement"; //$NON-NLS-1$
28
	
20 29
	public static final String PATTRIBUTES = "pAttributes"; //$NON-NLS-1$
30
	
21 31
	public static final String SATTRIBUTES = "sAttributes"; //$NON-NLS-1$
32
	
22 33
	public static final String PREBUILD = "preBuild"; //$NON-NLS-1$
34
	
23 35
	public static final String QUERIES = "queries"; //$NON-NLS-1$
36
	
24 37
	public static final String UI = "uis"; //$NON-NLS-1$
38
	
25 39
	public static final String OPTIONS = "options"; //$NON-NLS-1$
40
	
26 41
	public static final String TEXTUALPLANS = "textualplans";
42
	
27 43
	public static final String IMPORT_NAME = "import_name";
28 44
	
29
	static HashMap<String, HashMap<String, Boolean>> allParams = new HashMap<String, HashMap<String, Boolean>>();
30
	static HashMap<String, String> names = new HashMap<String, String>();
45
	static HashMap<String, HashMap<String, Boolean>> allParams = new HashMap<>();
31 46
	
32
	static { //init import module
33
		HashMap<String,Boolean> params = new HashMap<String, Boolean>();
47
	static HashMap<String, String> names = new HashMap<>();
48
	
49
	static { // init import module
50
		HashMap<String, Boolean> params = new HashMap<>();
34 51
		params.put(PARALLEL, false);
35 52
		params.put(ENCODING, true);
36 53
		params.put(LANG, false);
......
49 66
		allParams.put("discoursLoader.groovy", params); //$NON-NLS-1$
50 67
		names.put("discoursLoader.groovy", "CNR + CSV"); //$NON-NLS-1$ //$NON-NLS-2$
51 68
		
52
		params = new HashMap<String, Boolean>();
69
		params = new HashMap<>();
53 70
		params.put(PARALLEL, false);
54 71
		params.put(ENCODING, true);
55 72
		params.put(LANG, true);
......
68 85
		allParams.put("cqpLoader.groovy", params); //$NON-NLS-1$
69 86
		names.put("cqpLoader.groovy", "CQP"); //$NON-NLS-1$ //$NON-NLS-2$
70 87
		
71
		params = new HashMap<String, Boolean>();
88
		params = new HashMap<>();
72 89
		params.put(PARALLEL, false);
73 90
		params.put(ENCODING, true);
74 91
		params.put(LANG, true);
......
87 104
		allParams.put("hyperbaseLoader.groovy", params); //$NON-NLS-1$
88 105
		names.put("hyperbaseLoader.groovy", "Hyperbase"); //$NON-NLS-1$ //$NON-NLS-2$
89 106
		
90
		params = new HashMap<String, Boolean>();
107
		params = new HashMap<>();
91 108
		params.put(PARALLEL, false);
92 109
		params.put(ENCODING, true);
93 110
		params.put(LANG, true);
......
106 123
		allParams.put("alcesteLoader.groovy", params); //$NON-NLS-1$
107 124
		names.put("alcesteLoader.groovy", "Alceste"); //$NON-NLS-1$ //$NON-NLS-2$
108 125
		
109
		params = new HashMap<String, Boolean>();
126
		params = new HashMap<>();
110 127
		params.put(PARALLEL, false);
111 128
		params.put(ENCODING, true);
112 129
		params.put(LANG, true);
......
125 142
		allParams.put("txtLoader.groovy", params); //$NON-NLS-1$
126 143
		names.put("txtLoader.groovy", "TXT + CSV"); //$NON-NLS-1$ //$NON-NLS-2$
127 144
		
128
		params = new HashMap<String, Boolean>();
145
		params = new HashMap<>();
129 146
		params.put(PARALLEL, false);
130 147
		params.put(ENCODING, false);
131 148
		params.put(LANG, true);
......
140 157
		params.put(QUERIES, true);
141 158
		params.put(UI, true);
142 159
		params.put(TEXTUALPLANS, false);
143
		params.put(OPTIONS, false);
160
		params.put(OPTIONS, true);
144 161
		allParams.put("transcriberLoader.groovy", params); //$NON-NLS-1$
145 162
		names.put("transcriberLoader.groovy", "XML-TRS + CSV"); //$NON-NLS-1$ //$NON-NLS-2$
146 163
		
147
		params = new HashMap<String, Boolean>();
164
		params = new HashMap<>();
148 165
		params.put(PARALLEL, false);
149 166
		params.put(ENCODING, false);
150 167
		params.put(LANG, true);
......
163 180
		allParams.put("tmxLoader.groovy", params); //$NON-NLS-1$
164 181
		names.put("tmxLoader.groovy", "XML-TMX"); //$NON-NLS-1$ //$NON-NLS-2$
165 182
		
166
		params = new HashMap<String, Boolean>();
183
		params = new HashMap<>();
167 184
		params.put(PARALLEL, false);
168 185
		params.put(ENCODING, false);
169 186
		params.put(LANG, true);
......
182 199
		allParams.put("xmlLoader.groovy", params); //$NON-NLS-1$
183 200
		names.put("xmlLoader.groovy", "XML/w + CSV"); //$NON-NLS-1$ //$NON-NLS-2$
184 201
		
185
		params = new HashMap<String, Boolean>();
202
		params = new HashMap<>();
186 203
		params.put(PARALLEL, false);
187 204
		params.put(ENCODING, false);
188 205
		params.put(LANG, true);
......
201 218
		allParams.put("xmltxmLoader.groovy", params); //$NON-NLS-1$
202 219
		names.put("xmltxmLoader.groovy", "XML-TEI TXM"); //$NON-NLS-1$ //$NON-NLS-2$
203 220
		
204
		params = new HashMap<String, Boolean>();
221
		params = new HashMap<>();
205 222
		params.put(PARALLEL, false);
206 223
		params.put(ENCODING, false);
207 224
		params.put(LANG, true);
......
220 237
		allParams.put("factivaLoader.groovy", params); //$NON-NLS-1$
221 238
		names.put("factivaLoader.groovy", "XML-PPS"); //$NON-NLS-1$ //$NON-NLS-2$
222 239
		
223
		params = new HashMap<String, Boolean>();
240
		params = new HashMap<>();
224 241
		params.put(PARALLEL, false);
225 242
		params.put(ENCODING, false);
226 243
		params.put(LANG, true);
......
239 256
		allParams.put("factivamailLoader.groovy", params); //$NON-NLS-1$
240 257
		names.put("factivamailLoader.groovy", "Factiva TXT"); //$NON-NLS-1$ //$NON-NLS-2$
241 258
		
242
		params = new HashMap<String, Boolean>();
259
		params = new HashMap<>();
243 260
		params.put(PARALLEL, false);
244 261
		params.put(ENCODING, false);
245 262
		params.put(LANG, true);
......
258 275
		allParams.put("bfmLoader.groovy", params); //$NON-NLS-1$
259 276
		names.put("bfmLoader.groovy", "XML-TEI BFM"); //$NON-NLS-1$ //$NON-NLS-2$
260 277
		
261
		params = new HashMap<String, Boolean>();
278
		params = new HashMap<>();
262 279
		params.put(PARALLEL, false);
263 280
		params.put(ENCODING, false);
264 281
		params.put(LANG, true);
......
277 294
		allParams.put("frantextLoader.groovy", params); //$NON-NLS-1$
278 295
		names.put("frantextLoader.groovy", "XML-TEI Frantext"); //$NON-NLS-1$ //$NON-NLS-2$
279 296
		
280
		params = new HashMap<String, Boolean>();
297
		params = new HashMap<>();
281 298
		params.put(PARALLEL, false);
282 299
		params.put(ENCODING, false);
283 300
		params.put(LANG, true);
......
302 319
	 * @param importscript
303 320
	 * @return the import parameter section configuration depending on the <code>importscript</code>. If their is no setting for <code>importscript</code> return a default configuration
304 321
	 */
305
	public static HashMap<String,Boolean> getParameters(String importscript)
306
	{
322
	public static HashMap<String, Boolean> getParameters(String importscript) {
307 323
		if (allParams.containsKey(importscript)) {
308 324
			return allParams.get(importscript);
309
		} else {
310
			HashMap<String, Boolean> params = new HashMap<String, Boolean>();
325
		}
326
		else {
327
			HashMap<String, Boolean> params = new HashMap<>();
311 328
			params.put(PARALLEL, true);
312 329
			params.put(ENCODING, true);
313 330
			params.put(LANG, true);
......
327 344
		}
328 345
	}
329 346
	
330
	public static String getName(String importscript)
331
	{
347
	public static String getName(String importscript) {
332 348
		if (allParams.containsKey(importscript)) {
333 349
			return names.get(importscript);
334
		} else {
350
		}
351
		else {
335 352
			return importscript;
336 353
		}
337 354
	}

Formats disponibles : Unified diff