Révision 700

tmp/org.txm.information.core/plugin.xml (revision 700)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.eclipse.core.runtime.preferences">
6
      <initializer
7
            class="org.txm.information.core.preferences.InformationPreferences">
8
      </initializer>
9
   </extension>
10

  
11
</plugin>
0 12

  
tmp/org.txm.information.core/.settings/org.eclipse.jdt.core.prefs (revision 700)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4
org.eclipse.jdt.core.compiler.compliance=1.6
5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7
org.eclipse.jdt.core.compiler.source=1.6
0 8

  
tmp/org.txm.information.core/.classpath (revision 700)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
0 8

  
tmp/org.txm.information.core/META-INF/MANIFEST.MF (revision 700)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Information Core
4
Bundle-SymbolicName: org.txm.information.core;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Vendor: Textometrie.org
7
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
8
Export-Package: org.txm.information.core.functions,
9
 org.txm.information.core.messages,
10
 org.txm.information.core.preferences
11
Require-Bundle: org.txm.utils,
12
 org.txm.core;bundle-version="0.8.0",
13
 org.txm.searchengine.cqp.core;bundle-version="1.1.0"
0 14

  
tmp/org.txm.information.core/.project (revision 700)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.information.core</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
	</buildSpec>
24
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
</projectDescription>
0 29

  
tmp/org.txm.information.core/src/org/txm/information/core/functions/Information.java (revision 700)
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: 2016-09-19 10:31:00 +0200 (Mon, 19 Sep 2016) $
25
// $LastChangedRevision: 3298 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.information.core.functions;
29

  
30
import java.io.BufferedWriter;
31
import java.io.File;
32
import java.io.FileNotFoundException;
33
import java.io.FileOutputStream;
34
import java.io.IOException;
35
import java.io.OutputStreamWriter;
36
import java.io.UnsupportedEncodingException;
37
import java.util.ArrayList;
38
import java.util.Collections;
39
import java.util.HashMap;
40
import java.util.LinkedHashSet;
41
import java.util.List;
42
import java.util.Locale;
43

  
44
import org.eclipse.osgi.util.NLS;
45
import org.txm.core.preferences.TBXPreferences;
46
import org.txm.core.preferences.TXMPreferences;
47
import org.txm.core.results.Parameter;
48
import org.txm.core.results.TXMParameters;
49
import org.txm.core.results.TXMResult;
50
import org.txm.information.core.messages.InformationCoreMessages;
51
import org.txm.information.core.preferences.InformationPreferences;
52
import org.txm.objects.Base;
53
import org.txm.searchengine.cqp.AbstractCqiClient;
54
import org.txm.searchengine.cqp.CQPPreferences;
55
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
56
import org.txm.searchengine.cqp.corpus.Corpus;
57
import org.txm.searchengine.cqp.corpus.CorpusManager;
58
import org.txm.searchengine.cqp.corpus.Property;
59
import org.txm.searchengine.cqp.corpus.StructuralUnit;
60
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
61
import org.txm.searchengine.cqp.corpus.WordProperty;
62
import org.txm.utils.AsciiUtils;
63
import org.txm.utils.logger.Log;
64

  
65
// TODO: Auto-generated Javadoc
66
/**
67
 * compute a diagnostic of Corpus, sub corpus and partition @ author mdecorde.
68
 */
69
public class Information extends TXMResult {
70
	// Base base;
71
	/** The corpus. */
72
	Corpus corpus;
73
	
74
	// Numbers
75
	/** The T. */
76
	int T = 0; // number of word
77

  
78
	/** The N properties. */
79
	int NProperties = 0; // number of word properties
80
	//HashMap<String, Integer> propertiesCounts = new HashMap<String, Integer>(); // properties counts
81
	/** The properties values. */
82
	HashMap<String, List<String>> propertiesValues = new HashMap<String, List<String>>(); // properties values
83

  
84
	/** The N structures. */
85
	int NStructures = 0; // number of structures
86
	
87
	/** The structures counts. */
88
	HashMap<String, Integer> structuresCounts = new HashMap<String, Integer>(); // structures counts
89

  
90
	/** The internal architecture. */
91
	List<String> internalArchitecture = new ArrayList<String>(); // wtc structures = propertiesCounts keys but ordered
92
	
93
	/** The hierarchie counts. */
94
	HashMap<String, Integer> hierarchieCounts = new HashMap<String, Integer>(); // hierarchic structures counts
95
	
96
	/** The internal architecture properties. */
97
	HashMap<String, HashMap<String, List<String>>> internalArchitectureProperties = new HashMap<String, HashMap<String, List<String>>>(); // hierarchic structures counts
98
	
99
	/** The internal architecture properties counts. */
100
	HashMap<String, HashMap<String, Integer>> internalArchitecturePropertiesCounts = new HashMap<String, HashMap<String, Integer>>(); // hierarchic structures counts
101

  
102
	// Annotations description
103
	/** The annotations types. */
104
	HashMap<String, Integer> annotationsTypes = new HashMap<String, Integer>(); // for each annotation its description
105
	
106
	/** The annotations origins. */
107
	HashMap<String, Integer> annotationsOrigins = new HashMap<String, Integer>(); // for each annoation its origin description
108

  
109
	// Import description
110
	/** The import description. */
111
	String importDescription = ""; //$NON-NLS-1$
112
	
113
	/** The properties. */
114
	List<WordProperty> properties;
115
	
116
	/** The structures. */
117
	List<StructuralUnit> structures;
118

  
119
	/**
120
	 * The HTML file.
121
	 */
122
	protected File file;
123

  
124
	
125
	
126
	/**
127
	 * The maximum number of word property values to display.
128
	 */
129
	@Parameter(key=InformationPreferences.MAX_VALUE)
130
	protected int maxPropertiesToDisplay;
131
	
132
	
133
	
134
	/**
135
	 * Instantiates a new Information.
136
	 *
137
	 * @param corpus a MainCorpus or a SubCorpus
138
	 */
139
	public Information(Corpus corpus) {
140
		super(corpus);
141
		this.corpus = corpus;
142
	}
143

  
144
	/**
145
	 * Sets the maximum properties to display.
146
	 * @param maxPropertiesToDisplay
147
	 */
148
	public void setParameters(int maxPropertiesToDisplay) {
149
		this.maxPropertiesToDisplay = maxPropertiesToDisplay;
150
		if (this.maxPropertiesToDisplay <= 0) {
151
			this.maxPropertiesToDisplay = 10;
152
		}
153
		this.dirty = true;
154
	}
155
	
156

  
157
//	public boolean setParameters(TXMParameters parameters) {
158
//		try {
159
//			Integer max = null;
160
//			Object o = parameters.get(CQPPreferences.MAX_VALUE);
161
//			if (o instanceof Integer) max = (Integer)o;
162
//			else if (o instanceof String) max = Integer.parseInt(o.toString());
163
//			
164
//			this.setParameters(max);
165
//		} catch (Exception e) {
166
//			System.out.println("Error while setting parameters of Informations: "+e.getLocalizedMessage());
167
//			return false;
168
//		}
169
//		return true;
170
//	}
171
	
172
	/**
173
	 * Step general infos.
174
	 */
175
	public void stepGeneralInfos()
176
	{
177
		try {
178
			properties = corpus.getProperties();
179
			NProperties = properties.size();
180
		} catch (CqiClientException e) {
181
			Log.severe(InformationCoreMessages.Diagnostic_1 + corpus.getName() + InformationCoreMessages.Diagnostic_4);
182
			Log.printStackTrace(e);
183
			return;
184
		}
185
		
186
		try {
187
			T = corpus.getSize();// corpus.getLexicon(corpus.getProperty("id")).nbrOfToken();
188
		} catch (CqiClientException e) {
189
			Log.severe(InformationCoreMessages.Diagnostic_6 + corpus.getName() + InformationCoreMessages.Diagnostic_8);
190
			Log.printStackTrace(e);
191
			return;
192
		} 
193
	}
194
	
195
	/**
196
	 * step2.
197
	 * randomly position are choose
198
	 */
199
	public void stepLexicalProperties()
200
	{
201
		AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
202
		for (Property p : properties) {
203
			//int size;
204
			try {
205
				//size = CorpusManager.getCorpusManager().getCqiClient().lexiconSize(p.getQualifiedName());
206
				//propertiesCounts.put(p.getName(), size);
207
				//List<String> list = Arrays.asList(corpus.getLexicon(p).getForms(this.maxvalue));
208

  
209
				int[] positions = new int[Math.min(maxPropertiesToDisplay, T)];
210
				for(int i = 0 ; i < Math.min(maxPropertiesToDisplay, T) ; i++) {
211
					positions[i] = i;
212
				}
213
				
214
				//ArrayList<String> values = new ArrayList<String>();
215
				LinkedHashSet<String> values = new LinkedHashSet<String>(cqiClient.getSingleData(p, positions));
216
				propertiesValues.put(p.getName(), new ArrayList<String>(values));
217
			} catch (Exception e) {
218
				Log.printStackTrace(e);
219
			}
220
		}
221
	}
222
	
223
	/**
224
	 * Step structural units.
225
	 */
226
	public void stepStructuralUnits()
227
	{
228
		try {
229
			structures = corpus.getOrderedStructuralUnits();
230
		} catch (CqiClientException e) {
231
			Log.severe(InformationCoreMessages.Diagnostic_1 + corpus.getName() + InformationCoreMessages.Diagnostic_11);
232
			Log.printStackTrace(e);
233
			return;
234
		}
235
		NStructures = structures.size();
236
		for (StructuralUnit su : structures) { // for each structural unit
237
			internalArchitecture.add(su.getName());
238
			hierarchieCounts.put(su.getName(), -1);
239
			internalArchitectureProperties.put(su.getName(), new HashMap<String, List<String>>());
240
			internalArchitecturePropertiesCounts.put(su.getName(), new HashMap<String, Integer>());
241
			
242
			if (su.getProperties().size() > 0) {
243
				for (StructuralUnitProperty sup : su.getProperties())  {// for each of its property
244
					try {
245
						List<String> allvalues = sup.getValues(corpus);
246
						internalArchitectureProperties.get(su.getName()).put(sup.getName(), allvalues.subList(0, Math.min(allvalues.size(), maxPropertiesToDisplay)));
247
						internalArchitecturePropertiesCounts.get(su.getName()).put(sup.getName(), allvalues.size());
248
					} catch (Exception e) {
249
						ArrayList<String> list = new ArrayList<String>(1);
250
						list.add(InformationCoreMessages.Diagnostic_2);
251
						internalArchitectureProperties.get(su.getName()).put(sup.getName(), list);
252
						internalArchitecturePropertiesCounts.get(su.getName()).put(sup.getName(), -1);
253
					}
254
				}
255
			}
256
		}
257
	}
258

  
259
//	/**
260
//	 * Instantiates a new diagnostic.
261
//	 *
262
//	 * @param partition the partition
263
//	 * @throws CqiClientException the cqi client exception
264
//	 */
265
//	public Information(Partition partition) throws CqiClientException {
266
//		corpus = partition.getCorpus();
267
//		this.partition = partition;
268
//		int T = corpus.getSize();
269
//		System.out.println(InformationCoreMessages.Diagnostic_12);
270
//		int nbParts = partition.getNPart();
271
//		List<String> partNames = partition.getPartNames();
272
//		List<Integer> partSizes = new ArrayList<Integer>();
273
//		List<List<Property>> partProperties = new ArrayList<List<Property>>();
274
//		List<String> partQueries = new ArrayList<String>();
275
//		for (Part part : partition.getParts()) {
276
//			partSizes.add(part.getSize());
277
//			partProperties.add(part.getProperties());
278
//			partQueries.add(part.getQuery().getQueryString());
279
//		}
280
//	}
281

  
282
	/**
283
	 * dump the results of the diagnostic in a String containing HTML code.
284
	 *
285
	 * @return the string
286
	 */
287
	public String htmlDump() {
288
		StringBuffer buff = new StringBuffer();
289

  
290
		buff.append("<? version=\"1.0\" encoding=\"UTF-8\"?>\n" + //$NON-NLS-1$
291
				"<html>" + //$NON-NLS-1$
292
				"<head>" + //$NON-NLS-1$
293
				"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + //$NON-NLS-1$
294
				"</head>" + //$NON-NLS-1$
295
				"<body>\n"); //$NON-NLS-1$
296
		buff.append("<h2 style'font-family:\"Arial\";'>"+InformationCoreMessages.Diagnostic_3 + this.corpus.getName() + "</h2>\n"); //$NON-NLS-2$ //$NON-NLS-1$
297
		
298
		if (corpus.getDescription() != null && corpus.getDescription().length() > 0) {
299
			buff.append("<p>"+corpus.getDescription()+"</p>"); //$NON-NLS-1$ //$NON-NLS-2$
300
		}
301
		
302
		buff.append("<h3 style'font-family:\"Arial\";'>"+InformationCoreMessages.Diagnostic_5+ "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
303

  
304
		
305
		
306
		// counts
307
		buff.append("<ul>\n"); //$NON-NLS-1$
308
		buff.append("<li>" + InformationCoreMessages.Diagnostic_7 + T + "</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
309
		buff
310
		.append("<li>" + InformationCoreMessages.Diagnostic_9 + (NProperties - 1) + "</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$
311
		buff.append("<li>" + InformationCoreMessages.Diagnostic_16 + NStructures + "</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$
312
		buff.append("</ul>\n"); //$NON-NLS-1$
313

  
314
		// Propriétés d'occurrences
315
		buff.append("<h3 style'font-family:\"Arial\";'>"+NLS.bind(InformationCoreMessages.Diagnostic_14, maxPropertiesToDisplay) + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
316
		ArrayList<String> properties = new ArrayList<String>(propertiesValues.keySet());
317
		Collections.sort(properties);
318
		buff.append("<ul>\n"); //$NON-NLS-1$
319
		for (String s : properties) {
320
			if (!s.equals("id")) //$NON-NLS-1$
321
			{
322
				//buff.append("<li> " + s + " (" + propertiesCounts.get(s) + ") : "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
323
				buff.append("<li> " + s + " : "); //$NON-NLS-1$ //$NON-NLS-2$ 
324
				for (String v : propertiesValues.get(s))
325
					buff.append(v + ", "); //$NON-NLS-1$
326
				buff.append("..."); //$NON-NLS-1$
327
				buff.append("</li>\n"); //$NON-NLS-1$ 
328
			}
329
		}
330
		buff.append("</ul>\n"); //$NON-NLS-1$
331

  
332
		// Propriété de structures
333
		buff.append("<h3 style'font-family:\"Arial\";'>"+NLS.bind(InformationCoreMessages.Diagnostic_22, maxPropertiesToDisplay)+"</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$
334
		buff.append("<ul>\n"); //$NON-NLS-1$
335
		for (String s : internalArchitecture) {
336
			StringBuffer subbuffer = new StringBuffer();
337
			if (s.equals("txmcorpus")) //$NON-NLS-1$
338
				continue;//ignore the txmcorpus structure
339
			
340
			properties = new ArrayList<String>(internalArchitectureProperties.get(s).keySet());
341
			
342
			subbuffer.append("<li> " + s + "\n<ul>\n"); //$NON-NLS-1$ //$NON-NLS-2$
343
			if (internalArchitectureProperties.get(s).keySet().size() == 0)
344
				subbuffer.append("<li>"+InformationCoreMessages.Diagnostic_26+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
345

  
346
			
347
			//System.out.println("struct: "+s+" >> "+properties);
348
			Collections.sort(properties);
349
			//System.out.println("struct: "+s+" >sort> "+properties);
350
			int nbOfValues = 0;
351
			for (String ps : properties) {
352
				if (!ps.equals("project") && !ps.equals("base") ) //$NON-NLS-1$ //$NON-NLS-2$ 
353
				{
354
					//System.out.println("struct: "+s+" >> "+ps);
355
					int valuecount = internalArchitecturePropertiesCounts.get(s).get(ps);
356
					ArrayList<String> values = new ArrayList<String>(internalArchitectureProperties.get(s).get(ps));
357
					subbuffer.append("<li> " + ps + " (" + valuecount + ") = "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
358
					//System.out.println("VALUES: "+values);
359
					Collections.sort(values);
360
					for (int i = 0 ; i < values.size() ; i++) {
361
						nbOfValues++;
362
						String psv = values.get(i);
363
						if (psv != null && psv.length() > 0)
364
							subbuffer.append(psv.replace("<", "&lt;")); //$NON-NLS-1$ //$NON-NLS-2$
365
						else
366
							subbuffer.append("\"\""); //$NON-NLS-1$
367
						
368
						if (i == values.size() -1)
369
							subbuffer.append("."); //$NON-NLS-1$
370
						else
371
							subbuffer.append(", "); //$NON-NLS-1$
372
						
373
						if (i >= maxPropertiesToDisplay) {
374
							subbuffer.append("..."); //$NON-NLS-1$
375
							break;
376
						}
377
					}
378
					subbuffer.append("</li>\n"); //$NON-NLS-1$
379
				}
380
			}
381
			subbuffer.append("</ul>\n</li>\n"); //$NON-NLS-1$
382
			if (nbOfValues > 0) {
383
				buff.append(subbuffer);
384
			}
385
		}
386
		buff.append("</ul>\n"); //$NON-NLS-1$
387
		buff.append("</body>\n"); //$NON-NLS-1$
388
		buff.append("</html>\n"); //$NON-NLS-1$
389
		
390
		return buff.toString();
391
	}
392

  
393
	
394
	
395
	/**
396
	 * dump the result in the console.
397
	 *
398
	 * @param maxvalue the maxvalue
399
	 * @return the string
400
	 */
401
	public String dump(int maxvalue) {
402
		StringBuffer buff = new StringBuffer();
403

  
404
		buff.append(InformationCoreMessages.Diagnostic_40);
405
		buff.append(InformationCoreMessages.Diagnostic_41 + String.format(Locale.FRANCE,"%,d", T) + "\n"); //$NON-NLS-1$ 
406
		buff.append(InformationCoreMessages.Diagnostic_43 + String.format("%,d", NProperties) + "\n"); //$NON-NLS-1$ 
407
		/*for (String s : propertiesCounts.keySet())
408
			if (!s.equals("id")) //$NON-NLS-1$
409
				buff.append(" - " + s + " " + propertiesCounts.get(s) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
410
				*/
411
		buff.append(InformationCoreMessages.Diagnostic_49 + String.format("%,d", NStructures) + "\n"); //$NON-NLS-1$ 
412
		for (String s : structuresCounts.keySet())
413
			buff.append(" - " + s + "\n");//+structuresCounts.get(s)+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
414

  
415
		/*
416
		 * buff.append("* Structural Units counts\n"); for(String s :
417
		 * internalArchitecture)
418
		 * buff.append(" - "+s+" "+hierarchieCounts.get(s)+"\n");
419
		 */
420
		buff.append(InformationCoreMessages.Diagnostic_0);
421
		for (String s : internalArchitecture) {
422
			buff.append(" - " + s + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
423
			for (String ps : internalArchitectureProperties.get(s).keySet()) {
424
				if (!(s.equals("text") && (ps.equals("project") || ps.equals("base") || ps.equals("id")))) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
425
				{
426
					buff
427
					.append("   - " + ps + "(" + internalArchitectureProperties.get(s).get(ps).size() + ") = "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
428

  
429
					int valuecount = 0;
430
					for (String psv : internalArchitectureProperties.get(s)
431
							.get(ps)) {
432
						buff.append(psv);
433
						if (valuecount++ >= maxvalue) {
434
							buff.append("..."); //$NON-NLS-1$
435
							break;
436
						}
437
						if (valuecount < internalArchitectureProperties.get(s)
438
								.get(ps).size())
439
							buff.append(", "); //$NON-NLS-1$
440
					}
441

  
442
					buff.append("\n"); //$NON-NLS-1$
443
				}
444
			}
445
		}
446

  
447
		return buff.toString();
448
	}
449

  
450
	/**
451
	 * dump the result in the console with maxvalue=30.
452
	 *
453
	 * @return the string
454
	 */
455
	public String dump() {
456
		return dump(30);
457
	}
458

  
459
	/**
460
	 * Gets the name.
461
	 *
462
	 * @return the name
463
	 */
464
	public String getName() {
465
		return corpus.getName();
466
	}
467

  
468
	/**
469
	 * Gets the base.
470
	 *
471
	 * @return the base
472
	 */
473
	public Base getBase() {
474
		return corpus.getBase();
475
	}
476

  
477
	/**
478
	 * Gets the t.
479
	 *
480
	 * @return the t
481
	 */
482
	public int getT() {
483
		return T;
484
	}
485

  
486
	/**
487
	 * Gets the n properties.
488
	 *
489
	 * @return the n properties
490
	 */
491
	public int getNProperties() {
492
		return NProperties;
493
	}
494

  
495
	/**
496
	 * Gets the internal architecture.
497
	 *
498
	 * @return the internal architecture
499
	 */
500
	public List<String> getInternalArchitecture() {
501
		return internalArchitecture;
502
	}
503

  
504
	/**
505
	 * Gets the n structures.
506
	 *
507
	 * @return the n structures
508
	 */
509
	public int getNStructures() {
510
		return NStructures;
511
	}
512

  
513
	/**
514
	 * Gets the structures counts.
515
	 *
516
	 * @return the structures counts
517
	 */
518
	public HashMap<String, Integer> getStructuresCounts() {
519
		return structuresCounts;
520
	}
521

  
522
	/**
523
	 * Gets the annotations types.
524
	 *
525
	 * @return the annotations types
526
	 */
527
	public HashMap<String, Integer> getAnnotationsTypes() {
528
		return annotationsTypes;
529
	}
530

  
531
	/**
532
	 * Gets the annotations origins.
533
	 *
534
	 * @return the annotations origins
535
	 */
536
	public HashMap<String, Integer> getAnnotationsOrigins() {
537
		return annotationsOrigins;
538
	}
539

  
540
	/**
541
	 * Gets the import description.
542
	 *
543
	 * @return the import description
544
	 */
545
	public String getImportDescription() {
546
		return importDescription;
547
	}
548

  
549
	/**
550
	 * dump the diagnostic in a text file.
551
	 *
552
	 * @param outfile the outfile
553
	 * @param maxvalue the maxvalue
554
	 * @return true, if successful
555
	 */
556
	public boolean toTxt(File outfile, String encoding, int maxvalue) {
557
		BufferedWriter writer = null;
558
		try {
559
			writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile),	encoding));
560
		} catch (UnsupportedEncodingException e1) {
561
			org.txm.utils.logger.Log.printStackTrace(e1);
562
			return false;
563
		} catch (FileNotFoundException e1) {
564
			org.txm.utils.logger.Log.printStackTrace(e1);
565
			return false;
566
		}
567

  
568
		try {
569
			writer.write(this.dump(maxvalue));
570
			writer.close();
571
		} catch (IOException e) {
572
			org.txm.utils.logger.Log.printStackTrace(e);
573
			return false;
574
		}
575

  
576
		return true;
577
	}
578

  
579
	/**
580
	 * dump the diagnostic in a HTML file.
581
	 *
582
	 * @param outfile the outfile
583
	 * @return true, if successful
584
	 */
585
	public boolean toHTML(File outfile) {
586
		OutputStreamWriter writer;
587
		try {
588
			writer = new OutputStreamWriter(new FileOutputStream(outfile), "UTF-8"); //$NON-NLS-1$
589
			writer.write(this.htmlDump());
590
			writer.close();
591
		} catch (IOException e) {
592
			org.txm.utils.logger.Log.printStackTrace(e);
593
			return false;
594
		}
595

  
596
		return true;
597
	}
598

  
599
	/**
600
	 * dump the diagnostic in a text file, maxvalue = 100.
601
	 *
602
	 * @param outfile the outfile
603
	 * @return true, if successful
604
	 */
605
	public boolean toTxt(File outfile) {
606
		return toTxt(outfile, "UTF-8", 100); //$NON-NLS-1$
607
	}
608

  
609
	@Override
610
	public void clean() {
611
		// TODO Auto-generated method stub
612
	}
613

  
614
	@Override
615
	public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception {
616
		return toTxt(outfile, encoding, 100);
617
	}
618

  
619
	@Override
620
	public String getSimpleName() {
621
		return "Informations";
622
	}
623

  
624
	@Override
625
	public String getDetails() {
626
		return "" + T;
627
	}
628

  
629
	@Override
630
	protected boolean _compute() throws Exception {
631
		
632
		this.beginTask("Computing informations...", 3);
633
		this.stepGeneralInfos();
634
		this.worked(1);
635
		
636
		this.stepLexicalProperties();
637
		this.worked(1);
638
		
639
		this.stepStructuralUnits();
640
		this.worked(1);
641
		
642
		String txmhome = TXMPreferences.getString(TBXPreferences.USER_TXM_HOME, TBXPreferences.PREFERENCES_NODE);
643
		String filename = corpus.getParent().getName() + "-" + corpus.getName(); //$NON-NLS-1$
644
		filename = AsciiUtils.buildId(filename);
645
		file = new File(txmhome, "results/" + filename + "-infos.html"); //$NON-NLS-1$ //$NON-NLS-2$
646
		
647
		this.toHTML(file);
648
		return true;
649
	}
650
	
651
	/**
652
	 * Gets the HTML file.
653
	 * @return the HTML file
654
	 */
655
	public File getHTMLFile() {
656
		return file;
657
	}
658

  
659
	@Override
660
	public boolean canCompute() {
661
		return corpus != null;
662
	}
663

  
664
	@Override
665
	public boolean setParameters(TXMParameters parameters) {
666
		this.maxPropertiesToDisplay = parameters.getInteger(InformationPreferences.MAX_VALUE);
667
		return true;
668
	}
669

  
670
	@Override
671
	public boolean loadParameters() {
672
		// nothing to do
673
		return true;
674
	}
675

  
676
	
677
	@Override
678
	public boolean saveParameters() {
679
		// nothing to do
680
		return true;
681
	}
682
}
0 683

  
tmp/org.txm.information.core/src/org/txm/information/core/package.html (revision 700)
1
<html>
2
<body>
3
<p>Diagnostic function</p>
4
</body>
5
</html>
0 6

  
tmp/org.txm.information.core/src/org/txm/information/core/preferences/InformationPreferences.java (revision 700)
1
package org.txm.information.core.preferences;
2

  
3

  
4
import org.eclipse.core.runtime.preferences.DefaultScope;
5
import org.osgi.framework.FrameworkUtil;
6
import org.osgi.service.prefs.Preferences;
7
import org.txm.core.preferences.TXMPreferences;
8

  
9
/**
10
 * Information preferences initializer.
11
 * @author sjacquot
12
 *
13
 */
14
public class InformationPreferences extends TXMPreferences {
15

  
16
	// auto populate the preference node qualifier from the current bundle id
17
	public static final String PREFERENCES_NODE = FrameworkUtil.getBundle(InformationPreferences.class).getSymbolicName();
18
	
19
	public static final String PREFERENCES_PREFIX = "information_"; //$NON-NLS-1$
20
	
21
	
22
	/**
23
	 * The maximum number of word property values to display.
24
	 */
25
	public static final String MAX_VALUE = PREFERENCES_PREFIX + "max_properties_to_display"; //$NON-NLS-1$
26

  
27
	
28
	@Override
29
	public void initializeDefaultPreferences() {
30
		Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE);
31
		
32
		preferences.putInt(MAX_VALUE, 10);
33
		
34
	}
35
	
36
}
0 37

  
tmp/org.txm.information.core/src/org/txm/information/core/messages/messages.properties (revision 700)
1

  
2
Diagnostic_0  = * Structural Units properties\n
3
Diagnostic_1  = ** Failed to access corpus 
4
Diagnostic_11 = \ structures
5
Diagnostic_14 = Lexical Units properties (max {0} values)
6
Diagnostic_16 = Number of structural units 
7
Diagnostic_2  = ** Error
8
Diagnostic_22 = Structural Units properties (max {0} values)
9
Diagnostic_26 = No property
10
Diagnostic_3  = Description of 
11
Diagnostic_4  = \ properties
12
Diagnostic_40 = * General Statistics\n
13
Diagnostic_41 = - T 
14
Diagnostic_43 = - Word properties 
15
Diagnostic_49 = - S 
16
Diagnostic_5  = General Statistics
17
Diagnostic_6  = ** Failed to access corpus 
18
Diagnostic_7  = Number of words 
19
Diagnostic_8  = \ lexicon
20
Diagnostic_9  = Number of word properties 
0 21

  
tmp/org.txm.information.core/src/org/txm/information/core/messages/InformationCoreMessages.java (revision 700)
1
package org.txm.information.core.messages;
2

  
3
import org.eclipse.osgi.util.NLS;
4
import org.txm.utils.messages.Utf8NLS;
5

  
6

  
7
/**
8
 * Information core messages.
9
 * 
10
 * @author mdecorde
11
 * @author sjacquot
12
 *
13
 */
14
public class InformationCoreMessages extends NLS {
15

  
16
	private static final String BUNDLE_NAME = "org.txm.information.core.messages.messages"; //$NON-NLS-1$
17

  
18
	
19
	public static String Diagnostic_0;
20
	public static String Diagnostic_1;
21
	public static String Diagnostic_11;
22
	public static String Diagnostic_14;
23
	public static String Diagnostic_16;
24
	public static String Diagnostic_2;
25
	public static String Diagnostic_22;
26
	public static String Diagnostic_26;
27
	public static String Diagnostic_3;
28
	public static String Diagnostic_4;
29
	public static String Diagnostic_40;
30
	public static String Diagnostic_41;
31
	public static String Diagnostic_43;
32
	public static String Diagnostic_49;
33
	public static String Diagnostic_5;
34
	public static String Diagnostic_6;
35
	public static String Diagnostic_7;
36
	public static String Diagnostic_8;
37
	public static String Diagnostic_9;
38

  
39
	
40
	
41
	static {
42
		// initialize resource bundle
43
		Utf8NLS.initializeMessages(BUNDLE_NAME, InformationCoreMessages.class);
44
	}
45

  
46
	private InformationCoreMessages() {
47
	}
48
	
49
}
0 50

  
tmp/org.txm.information.core/src/org/txm/information/core/messages/messages_fr.properties (revision 700)
1

  
2
Diagnostic_0  = <h3>Propriétés des structures\n
3
Diagnostic_1  = ** Echec d'accès au corpus
4
Diagnostic_11 = \ structures
5
Diagnostic_14 = Propriétés des unités lexicales (max {0} valeurs)
6
Diagnostic_16 = Nombre d'unités de structure 
7
Diagnostic_2  = ** Erreur
8
Diagnostic_22 = Propriétés des structures (max {0} valeurs)
9
Diagnostic_26 = Pas de propriété
10
Diagnostic_3  = Description du corpus 
11
Diagnostic_4  = \ propriétés
12
Diagnostic_40 = * Statistiques Générales\n
13
Diagnostic_41 = - T
14
Diagnostic_43 = - Propriétés de mot 
15
Diagnostic_49 = - S
16
Diagnostic_5  = Statistiques Générales
17
Diagnostic_6  = ** Echec d'accès au corpus
18
Diagnostic_7  = Nombre de mots 
19
Diagnostic_8  = \ lexique
20
Diagnostic_9  = Nombre de propriétés de mot 
0 21

  
tmp/org.txm.information.core/build.properties (revision 700)
1
source.. = src/
2
output.. = bin/
3
bin.includes = META-INF/,\
4
               .,\
5
               plugin.xml
0 6

  

Formats disponibles : Unified diff