Révision 1164

tmp/org.txm.ca.core/src/org/txm/ca/core/preferences/CAPreferences.java (revision 1164)
12 12
 * @author sjacquot
13 13
 *
14 14
 */
15
public class CAPreferences extends TXMPreferences {
15
public class CAPreferences extends ChartsEnginePreferences {
16 16

  
17 17
	/** The Constant QUALITYDISPLAY. */
18 18
	public static final String QUALITY_DISPLAY_FORMAT = "quality_display_format"; //$NON-NLS-1$
tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java (revision 1164)
133 133
		this(null, lexicalTable);
134 134
	}
135 135
	
136
	public LexicalTable getParent() {
137
		return (LexicalTable)parent;
138
	}
139
	
136 140
	/**
137 141
	 * Creates a new empty CA.
138 142
	 *
tmp/org.txm.specificities.core/src/org/txm/specificities/core/preferences/SpecificitiesPreferences.java (revision 1164)
12 12
 * @author sjacquot
13 13
 *
14 14
 */
15
public class SpecificitiesPreferences extends TXMPreferences {
15
public class SpecificitiesPreferences extends ChartsEnginePreferences {
16 16

  
17

  
18 17
	/**
19 18
	 * Maximum score.
20 19
	 */
......
25 24
	 */
26 25
	public static final String FORMAT = "format"; //$NON-NLS-1$
27 26
	
28
	
29 27
	// charts
30 28
	public static final String CHART_GROUP_BY_LINES = "chart_group_by_lines"; //$NON-NLS-1$
31 29
	public static final String CHART_DRAW_BARS = "chart_draw_bars"; //$NON-NLS-1$
tmp/org.txm.ahc.core/src/org/txm/ahc/core/functions/AHC.java (revision 1164)
60 60
	 * Counter used in name suffix.
61 61
	 */
62 62
	protected static int ahcCounter = 1;
63
	
64 63

  
64

  
65 65
	/** The symbol. */
66 66
	String symbol = null;
67 67

  
68 68
	/** The CA symbol target. */
69 69
	String target;
70 70

  
71
	
71

  
72 72
	/**
73 73
	 * The coordinates of the clusters.
74 74
	 */
......
104 104
	 */
105 105
	protected double[] inertiaGains = null;
106 106

  
107
	protected CA ca;
108
	protected LexicalTable table;
109

  
110
	
111
	
112
	
113
	
114
	
115 107
	/**
116 108
	 * The metric (euclidean, manhattan).
117 109
	 */
......
135 127
	 */
136 128
	@Parameter(key=AHCPreferences.COLUMNS_COMPUTING)
137 129
	protected boolean columnsComputing;
138
	
130

  
139 131
	/**
140 132
	 * To display in 2D or 3D.
141 133
	 */
142 134
	@Parameter(key=AHCPreferences.RENDERING_2D)
143 135
	protected boolean rendering2D;
144
	
145
	
146
	
136

  
137

  
138

  
147 139
	/**
148 140
	 * Instantiates a new AHC.
149 141
	 *
......
157 149
	public AHC(String parametersNodePath)	{
158 150
		this(parametersNodePath, null);
159 151
	}
160
	
152

  
161 153
	/**
162 154
	 * Instantiates a new AHC.
163 155
	 *
......
171 163
	public AHC(CA ca)	{
172 164
		this(null, ca);
173 165
	}
174
	
166

  
167
	public CA getParent() {
168
		return (CA) parent;
169
	}
170

  
175 171
	/**
176 172
	 * Instantiates a new AHC.
177 173
	 *
......
191 187

  
192 188
		Log.info("Computing CAH...");
193 189
		try {
194
			this.table = this.ca.getLexicalTable();
195
			this.target = this.ca.getSymbol();
190
			CA ca = getParent();
191
			LexicalTable table = ca.getLexicalTable();
192
			this.target = ca.getSymbol();
196 193

  
197 194
			// reset the number of clusters to default if columns or rows computing has changed
198
			if(this.hasParameterChanged(AHCPreferences.COLUMNS_COMPUTING))	{
199
				this.numberOfClusters = AHCPreferences.getInstance().getInt(AHCPreferences.N_CLUSTERS);
200
			}
195
			//			if(this.hasParameterChanged(AHCPreferences.COLUMNS_COMPUTING))	{
196
			//				this.numberOfClusters = AHCPreferences.getInstance().getInt(AHCPreferences.N_CLUSTERS);
197
			//			}
201 198

  
202 199
			String colOrLine = "columns"; //$NON-NLS-1$
203 200
			if (!this.columnsComputing) {
......
216 213
					", metric=\"" + this.metric + "\"" + //$NON-NLS-1$ //$NON-NLS-2$
217 214
					", method=\"" + this.method + "\"" + //$NON-NLS-1$ //$NON-NLS-2$
218 215
					", graph=FALSE)"); //$NON-NLS-1$
219
			
216

  
220 217
		} catch(Exception e) {
221 218
			Log.printStackTrace(e);
222 219
			return false;
......
227 224
		this.dirty = false;
228 225
		return true;
229 226
	}
230
	
231
	
227

  
228

  
232 229
	/**
233 230
	 * 
234 231
	 * @param columns
......
255 252

  
256 253
	@Override
257 254
	public boolean loadParameters() {
258
//		if(this.ca == null)	{ // moved to ComputeAHC command 
259
//			this.ca = (CA) this.getParent();
260
//			this.ca.setVisible(false); // hide the temporary CA
261
//		}
255
		//		if(this.ca == null)	{ // moved to ComputeAHC command 
256
		//			this.ca = (CA) this.getParent();
257
		//			this.ca.setVisible(false); // hide the temporary CA
258
		//		}
262 259
		return true;
263 260
	}
264 261

  
......
271 268
	@Override
272 269
	public boolean canCompute() {
273 270
		return
274
				this.ca != null
275
				&& Arrays.binarySearch(AHC.getMethods(), this.method) >= 0 
271
				Arrays.binarySearch(AHC.getMethods(), this.method) >= 0 
276 272
				&& Arrays.binarySearch(AHC.getMetrics(), this.metric) >= 0
277 273
				&& this.numberOfClusters >= 2;
278 274
	}
......
599 595
	 */
600 596
	public int getMaxClustersCount()	{
601 597

  
602
		int maxClustersCount = -1;
603

  
598
		int maxClustersCount = 16;
604 599
		try {
605
			RWorkspace rw = RWorkspace.getRWorkspaceInstance();
606
			REXP sv = rw.eval("min(length(" + symbol + "$data$clust) - 1, 16)"); //$NON-NLS-1$ //$NON-NLS-2$
607
			maxClustersCount = sv.asInteger();
608
		} catch(Exception e) {
609
			System.out.println("Error: "+e.getLocalizedMessage());
610
			Log.printStackTrace(e);
600
			int n = -1;
601
			if (!this.columnsComputing) {
602
				n = this.getParent().getParent().getNRows() - 1; // -1 because HCPC can't make as much groups as rows
603
			} else {
604
				n = this.getParent().getParent().getNColumns() - 1; // -1 because HCPC can't make as much groups as cols
605
			}
606
			
607
			if (n >= 0 && n < maxClustersCount) {
608
				maxClustersCount = n;
609
			}
610
		} catch (Exception e) {
611
			// TODO Auto-generated catch block
612
			e.printStackTrace();
611 613
		}
612 614

  
615
		//		try {
616
		//			RWorkspace rw = RWorkspace.getRWorkspaceInstance();
617
		//			REXP sv = rw.eval("min(length(" + symbol + "$data$clust) - 1, 16)"); //$NON-NLS-1$ //$NON-NLS-2$
618
		//			maxClustersCount = sv.asInteger();
619
		//		} catch(Exception e) {
620
		//			System.out.println("Error: "+e.getLocalizedMessage());
621
		//			Log.printStackTrace(e);
622
		//		}
623

  
613 624
		// FIXME: FactoMineR plot.HCPC doesn't manage more than 16 clusters when tree.barplot=TRUE, therefore we can't plot a SVG with more than that, see ticket #836 then use the code below in ChartsEngine to compute
614 625
		// the real maximum available clusters count
615 626
		//		// CA
......
650 661
		return numberOfClusters;
651 662
	}
652 663

  
653
	public CA getCA() {
654
		return ca;
655
	}
656

  
657 664
	public LexicalTable getLexicalTable() {
658
		return table;
665
		return getParent().getLexicalTable();
659 666
	}
660 667

  
661 668

  
662 669
	@Override
663 670
	public String getSimpleName() {
664 671
		// FIXME: to define
665
//		StringBuffer buffer = new StringBuffer();
666
//		buffer.append(this.columnsComputing ? "cols" : "rows"); //$NON-NLS-1$
667
//		buffer.append(this.method);
668
//		buffer.append(this.metric);
669
//		buffer.append(this.numberOfClusters);
672
		//		StringBuffer buffer = new StringBuffer();
673
		//		buffer.append(this.columnsComputing ? "cols" : "rows"); //$NON-NLS-1$
674
		//		buffer.append(this.method);
675
		//		buffer.append(this.metric);
676
		//		buffer.append(this.numberOfClusters);
670 677
		return this.getName();
671 678
	}
672 679

  
......
689 696
	}
690 697

  
691 698

  
692
	
699

  
693 700
	/**
694 701
	 * Gets the 2D rendering state.
695 702
	 * If false, the rendering will be done in 3D.
tmp/org.txm.ahc.core/src/org/txm/ahc/core/preferences/AHCPreferences.java (revision 1164)
12 12
 * @author sjacquot
13 13
 *
14 14
 */
15
public class AHCPreferences extends TXMPreferences {
15
public class AHCPreferences extends ChartsEnginePreferences {
16 16

  
17 17
	/**
18 18
	 * To display in 2D or 3D.
tmp/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/functions/Cooccurrence.java (revision 1164)
220 220
	
221 221
	/** The minscore. */
222 222
	@Parameter(key=CooccurrencePreferences.MIN_SCORE)
223
	protected Double pScoreMinFilter;
223
	protected Float pScoreMinFilter;
224 224
	
225 225
	/**
226 226
	 * The structural unit context limit.
......
796 796
	}
797 797

  
798 798
	public void setParameters(CQLQuery query, List<WordProperty> properties, StructuralUnit limit, int maxLeft, int minLeft, int minRight,
799
			int maxRight, int minFreq, double minScore, int minCof, boolean includeXpivot, boolean buildLexicalTableWithCooccurrents) {
799
			int maxRight, int minFreq, float minScore, int minCof, boolean includeXpivot, boolean buildLexicalTableWithCooccurrents) {
800 800

  
801 801
		this.pQuery = query;
802 802
		this.pProperties = properties;
......
842 842
			int minLeft = parameters.getInteger(CooccurrencePreferences.MIN_LEFT);
843 843
			int maxRight = parameters.getInteger(CooccurrencePreferences.MAX_RIGHT);
844 844
			int minRight = parameters.getInteger(CooccurrencePreferences.MIN_RIGHT);
845
			double minScore = parameters.getDouble(CooccurrencePreferences.MIN_SCORE);
845
			float minScore = parameters.getFloat(CooccurrencePreferences.MIN_SCORE);
846 846
			int minCof = parameters.getInteger(CooccurrencePreferences.MIN_COUNT);
847 847
			int minFreq = parameters.getInteger(TXMPreferences.F_MIN);
848 848
			boolean buildLexicalTableWithCooccurrents = parameters.getBoolean(CooccurrencePreferences.PARTIAL_LEXICAL_TABLE);
......
877 877
	 * @param count the count
878 878
	 * @param score the score
879 879
	 */
880
	public void setThresfold(int freq, int count, double score) {
880
	public void setThresfold(int freq, int count, float score) {
881 881

  
882 882
		pFminFilter = freq;
883 883
		pFCoocFilter = count;
tmp/org.txm.ahc.rcp/src/org/txm/ahc/rcp/editors/AHCChartEditor.java (revision 1164)
104 104

  
105 105
	@Override
106 106
	public void updateEditorFromChart(boolean update) {
107
		
107
		AHC ahc = this.getResult();
108

  
108 109
		// Update the maximum value of the number of clusters spinner according to the new AHC configuration 
109
		this.numberOfClusters.setMaximum(this.getResult().getMaxClustersCount());
110
		this.numberOfClusters.setMaximum(ahc.getMaxClustersCount());
110 111

  
111 112
		// Updates the current value of the number of clusters spinner
112
		this.numberOfClusters.setSelection(this.getResult().getNumberOfClusters());
113
		this.numberOfClusters.setSelection(ahc.getNumberOfClusters());
113 114
		
114
		this.rowsComputing.setSelection(!this.getResult().isColumnsComputing());
115
		this.rowsComputing.setSelection(!ahc.isColumnsComputing());
115 116
	}
116 117

  
117 118
}
tmp/org.txm.properties.rcp/src/org/txm/properties/rcp/editors/PropertiesEditor.java (revision 1164)
45 45
	/**
46 46
	 * The maximum number of word property values to display.
47 47
	 */
48
	@Parameter(key=PropertiesPreferences.MAX_PROPERTIES_TO_DISPLAY)
48
	@Parameter(key = PropertiesPreferences.MAX_PROPERTIES_TO_DISPLAY)
49 49
	protected Spinner maxPropertiesToDisplay;
50 50

  
51 51
	private Button nameSaveButton;
......
75 75

  
76 76
		Group editComposite = this.getTopToolbar().installGroup(PropertiesUIMessages.editor_composite_edit_properties, PropertiesUIMessages.editor_composite_edit_properties, null, null, false);
77 77
		editComposite.setLayout(GLComposite.createDefaultLayout(3));
78
		
78

  
79 79
		Label nameLabel = new Label(editComposite, SWT.NONE);
80 80
		nameLabel.setText(PropertiesUIMessages.editor_label_name);
81 81

  
......
94 94
			}
95 95

  
96 96
			@Override
97
			public void widgetDefaultSelected(SelectionEvent e) { }
97
			public void widgetDefaultSelected(SelectionEvent e) {
98
			}
98 99
		});
99 100

  
100 101
		Label descLabel = new Label(editComposite, SWT.NONE);
101 102
		descLabel.setText(PropertiesUIMessages.editor_label_description);
102 103

  
103
		descriptionText = new StyledText(editComposite, SWT.BORDER|SWT.V_SCROLL);
104
		descriptionText = new StyledText(editComposite, SWT.BORDER | SWT.V_SCROLL);
104 105
		descriptionText.setLayoutData(GridDataFactory.fillDefaults().hint(400, 100).minSize(400, 100).span(1, 2).create());
105 106
		descriptionSaveButton = new Button(editComposite, SWT.PUSH);
106 107
		descriptionSaveButton.setText(PropertiesUIMessages.editor_button_apply);
......
116 117
			}
117 118

  
118 119
			@Override
119
			public void widgetDefaultSelected(SelectionEvent e) { }
120
			public void widgetDefaultSelected(SelectionEvent e) {
121
			}
120 122
		});
121 123

  
122 124
		// browser
......
131 133
		File file = this.getResult().getHTMLFile();
132 134
		if (file.exists()) {
133 135
			this.browser.setUrl(file.toURI().toURL().toString());
134
		}
135
		else	{
136
		} else {
136 137
			Log.severe("Information HTML file doesn't exist."); //$NON-NLS-1$
137 138
		}
138 139
		String n = getResult().getCorpus().getUserName();
139
		if (n == null) n = getResult().getCorpus().getName();
140
		if (n == null)
141
			n = getResult().getCorpus().getName();
140 142
		nameText.setText(n);
141 143

  
142 144
		String d = getResult().getCorpus().getDescription();
......
149 151
	public void updateResultFromEditor() {
150 152
		// nothing to do
151 153
	}
152

  
153 154
}
tmp/org.txm.properties.core/src/org/txm/properties/core/functions/Properties.java (revision 1164)
2 2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3 3
// Lyon 2, University of Franche-Comté, University of Nice
4 4
// Sophia Antipolis, University of Paris 3.
5
// 
5
//
6 6
// The TXM platform is free software: you can redistribute it
7 7
// and/or modify it under the terms of the GNU General Public
8 8
// License as published by the Free Software Foundation,
9 9
// either version 2 of the License, or (at your option) any
10 10
// later version.
11
// 
11
//
12 12
// The TXM platform is distributed in the hope that it will be
13 13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14 14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 15
// PURPOSE. See the GNU General Public License for more
16 16
// details.
17
// 
17
//
18 18
// You should have received a copy of the GNU General
19 19
// Public License along with the TXM platform. If not, see
20 20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
21
//
22
//
23
//
24 24
// $LastChangedDate: 2016-09-19 10:31:00 +0200 (Mon, 19 Sep 2016) $
25 25
// $LastChangedRevision: 3298 $
26
// $LastChangedBy: mdecorde $ 
26
// $LastChangedBy: mdecorde $
27 27
//
28 28
package org.txm.properties.core.functions;
29 29

  
......
67 67
	// Base base;
68 68
	/** The corpus. */
69 69
	protected CQPCorpus corpus;
70
	
70

  
71 71
	// Numbers
72 72
	/** The T. */
73 73
	int numberOfWords = 0; // number of word
74 74

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

  
81 82
	/** The N structures. */
82 83
	int NStructures = 0; // number of structures
83
	
84

  
84 85
	/** The structures counts. */
85 86
	HashMap<String, Integer> structuresCounts = new HashMap<String, Integer>(); // structures counts
86 87

  
87 88
	/** The internal architecture. */
88 89
	List<String> internalArchitecture = new ArrayList<String>(); // cqp structures = propertiesCounts keys but ordered
89
	
90

  
90 91
	/** The hierarchie counts. */
91 92
	HashMap<String, Integer> hierarchieCounts = new HashMap<String, Integer>(); // hierarchic structures counts
92
	
93

  
93 94
	/** The internal architecture properties. */
94 95
	HashMap<String, HashMap<String, List<String>>> internalArchitectureProperties = new HashMap<String, HashMap<String, List<String>>>(); // hierarchic structures counts
95
	
96

  
96 97
	/** The internal architecture properties counts. */
97 98
	HashMap<String, HashMap<String, Integer>> internalArchitecturePropertiesCounts = new HashMap<String, HashMap<String, Integer>>(); // hierarchic structures counts
98 99

  
99 100
	// Annotations description
100 101
	/** The annotations types. */
101 102
	HashMap<String, Integer> annotationsTypes = new HashMap<String, Integer>(); // for each annotation its description
102
	
103

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

  
106 107
	/** The properties. */
107 108
	List<WordProperty> properties;
108
	
109

  
109 110
	/** The structures. */
110 111
	List<StructuralUnit> structures;
111 112

  
......
113 114
	 * The HTML file.
114 115
	 */
115 116
	protected File file;
116
	
117

  
117 118
	/**
118 119
	 * The maximum number of word property values to display.
119 120
	 */
120
	@Parameter(key=PropertiesPreferences.MAX_PROPERTIES_TO_DISPLAY)
121
	@Parameter(key = PropertiesPreferences.MAX_PROPERTIES_TO_DISPLAY)
121 122
	protected int pMaxPropertiesToDisplay;
122
	
123
	
124
	
125
	
123

  
126 124
	/**
127 125
	 * Instantiates a new corpus Properties.
128 126
	 *
129
	 * @param corpus a MainCorpus or a SubCorpus
127
	 * @param corpus
128
	 *            a MainCorpus or a SubCorpus
130 129
	 */
131 130
	public Properties(CQPCorpus corpus) {
132 131
		super(corpus);
......
140 139
		super(parametersNodePath);
141 140
	}
142 141

  
143
	
144
	
145 142
	@Override
146 143
	public boolean loadParameters() {
147 144
		this.corpus = (CQPCorpus) this.parent;
148 145
		return true;
149 146
	}
150 147

  
151
	
152 148
	/**
153 149
	 * Sets the maximum properties to display.
150
	 * 
154 151
	 * @param maxPropertiesToDisplay
155 152
	 */
156 153
	public void setParameters(int maxPropertiesToDisplay) {
......
160 157
		}
161 158
		this.dirty = true;
162 159
	}
163
	
164
	
160

  
165 161
	/**
166 162
	 * Step general infos.
167 163
	 */
168
	public void stepGeneralInfos()
169
	{
164
	public void stepGeneralInfos() {
170 165
		try {
171 166
			properties = corpus.getProperties();
172 167
			NProperties = properties.size();
......
175 170
			Log.printStackTrace(e);
176 171
			return;
177 172
		}
178
		
173

  
179 174
		try {
180 175
			numberOfWords = corpus.getSize();// corpus.getLexicon(corpus.getProperty("id")).nbrOfToken();
181 176
		} catch (CqiClientException e) {
182 177
			Log.severe(PropertiesCoreMessages.Properties_6 + corpus.getName() + PropertiesCoreMessages.Properties_8);
183 178
			Log.printStackTrace(e);
184 179
			return;
185
		} 
180
		}
186 181
	}
187
	
182

  
188 183
	/**
189
	 * step2.
190
	 * randomly position are choose
184
	 * step2. randomly position are choose
191 185
	 */
192 186
	public void stepLexicalProperties() {
193 187
		propertiesValues.clear();
194
		
188

  
195 189
		AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
196 190
		for (Property p : properties) {
197
			//int size;
191
			// int size;
198 192
			try {
199
				//size = CorpusManager.getCorpusManager().getCqiClient().lexiconSize(p.getQualifiedName());
200
				//propertiesCounts.put(p.getName(), size);
201
				//List<String> list = Arrays.asList(corpus.getLexicon(p).getForms(this.maxvalue));
193
				// size =
194
				// CorpusManager.getCorpusManager().getCqiClient().lexiconSize(p.getQualifiedName());
195
				// propertiesCounts.put(p.getName(), size);
196
				// List<String> list =
197
				// Arrays.asList(corpus.getLexicon(p).getForms(this.maxvalue));
202 198

  
203 199
				int[] positions = new int[Math.min(pMaxPropertiesToDisplay, numberOfWords)];
204
				for(int i = 0 ; i < Math.min(pMaxPropertiesToDisplay, numberOfWords) ; i++) {
200
				for (int i = 0; i < Math.min(pMaxPropertiesToDisplay, numberOfWords); i++) {
205 201
					positions[i] = i;
206 202
				}
207
				
208
				//ArrayList<String> values = new ArrayList<String>();
203

  
204
				// ArrayList<String> values = new ArrayList<String>();
209 205
				LinkedHashSet<String> values = new LinkedHashSet<String>(cqiClient.getSingleData(p, positions));
210 206
				propertiesValues.put(p.getName(), new ArrayList<String>(values));
211 207
			} catch (Exception e) {
......
213 209
			}
214 210
		}
215 211
	}
216
	
212

  
217 213
	/**
218 214
	 * Step structural units.
219 215
	 */
220
	public void stepStructuralUnits()
221
	{
216
	public void stepStructuralUnits() {
222 217
		try {
223 218
			structures = corpus.getOrderedStructuralUnits();
224 219
		} catch (CqiClientException e) {
......
233 228
			hierarchieCounts.put(su.getName(), -1);
234 229
			internalArchitectureProperties.put(su.getName(), new HashMap<String, List<String>>());
235 230
			internalArchitecturePropertiesCounts.put(su.getName(), new HashMap<String, Integer>());
236
			
231

  
237 232
			if (su.getProperties().size() > 0) {
238
				for (StructuralUnitProperty sup : su.getProperties())  {// for each of its property
233
				for (StructuralUnitProperty sup : su.getProperties()) {// for each of its property
239 234
					try {
240 235
						List<String> allvalues = sup.getValues(corpus);
241 236
						internalArchitectureProperties.get(su.getName()).put(sup.getName(), allvalues.subList(0, Math.min(allvalues.size(), pMaxPropertiesToDisplay)));
......
252 247
	}
253 248

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

  
278 273
	/**
279 274
	 * dump the results of the diagnostic in a String containing HTML code.
......
289 284
				"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + //$NON-NLS-1$
290 285
				"</head>" + //$NON-NLS-1$
291 286
				"<body>\n"); //$NON-NLS-1$
292
		buff.append("<h2 style'font-family:\"Arial\";'>"+PropertiesCoreMessages.Properties_3 + this.corpus.getName() +" (id="+this.corpus.getID()+")</h2>\n"); //$NON-NLS-2$ //$NON-NLS-1$
293
		
287
		buff.append("<h2 style'font-family:\"Arial\";'>" + PropertiesCoreMessages.Properties_3 + this.corpus.getName() + " (id=" + this.corpus.getID() + ")</h2>\n"); //$NON-NLS-2$ //$NON-NLS-1$
288

  
294 289
		if (corpus.getDescription() != null && corpus.getDescription().length() > 0) {
295
			buff.append("<p>"+corpus.getDescription()+"</p>"); //$NON-NLS-1$ //$NON-NLS-2$
290
			buff.append("<p>" + corpus.getDescription() + "</p>"); //$NON-NLS-1$ //$NON-NLS-2$
296 291
		}
297
		
298
		buff.append("<h3 style'font-family:\"Arial\";'>"+PropertiesCoreMessages.Properties_5+ "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
299 292

  
293
		buff.append("<h3 style'font-family:\"Arial\";'>" + PropertiesCoreMessages.Properties_5 + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$
294

  
300 295
		// counts
301 296
		buff.append("<ul>\n"); //$NON-NLS-1$
302
		buff.append("<li>" + PropertiesCoreMessages.Properties_7 + numberOfWords + "</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
297
		buff.append("<li>" + PropertiesCoreMessages.Properties_7 + numberOfWords + "</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$
303 298
		buff.append("<li>" + PropertiesCoreMessages.Properties_9 + (NProperties - 1) + "</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$
304 299
		buff.append("<li>" + PropertiesCoreMessages.Properties_16 + NStructures + "</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$
305 300
		buff.append("</ul>\n"); //$NON-NLS-1$
306 301

  
307 302
		// Propriétés d'occurrences
308
		buff.append("<h3 style'font-family:\"Arial\";'>"+NLS.bind(PropertiesCoreMessages.Properties_14, pMaxPropertiesToDisplay) + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
303
		buff.append("<h3 style'font-family:\"Arial\";'>" + NLS.bind(PropertiesCoreMessages.Properties_14, pMaxPropertiesToDisplay) + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$
309 304
		ArrayList<String> properties = new ArrayList<String>(propertiesValues.keySet());
310 305
		Collections.sort(properties);
311 306
		buff.append("<ul>\n"); //$NON-NLS-1$
312 307
		for (String s : properties) {
313
			if (!s.equals("id")) //$NON-NLS-1$
314
			{
315
				//buff.append("<li> " + s + " (" + propertiesCounts.get(s) + ") : "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
316
				buff.append("<li> " + s + " : "); //$NON-NLS-1$ //$NON-NLS-2$ 
308
			if (!s.equals("id")) { //$NON-NLS-1$
309
				// buff.append("<li> " + s + " (" + propertiesCounts.get(s) + ") : ");
310
				// //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
311
				buff.append("<li> " + s + " : "); //$NON-NLS-1$ //$NON-NLS-2$
317 312
				for (String v : propertiesValues.get(s))
318 313
					buff.append(v + ", "); //$NON-NLS-1$
319 314
				buff.append("..."); //$NON-NLS-1$
320
				buff.append("</li>\n"); //$NON-NLS-1$ 
315
				buff.append("</li>\n"); //$NON-NLS-1$
321 316
			}
322 317
		}
323 318
		buff.append("</ul>\n"); //$NON-NLS-1$
324 319

  
325 320
		// Propriété de structures
326
		buff.append("<h3 style'font-family:\"Arial\";'>"+NLS.bind(PropertiesCoreMessages.Properties_22, pMaxPropertiesToDisplay)+"</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$
321
		buff.append("<h3 style'font-family:\"Arial\";'>" + NLS.bind(PropertiesCoreMessages.Properties_22, pMaxPropertiesToDisplay) + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$
327 322
		buff.append("<ul>\n"); //$NON-NLS-1$
328 323
		for (String s : internalArchitecture) {
329 324
			StringBuffer subbuffer = new StringBuffer();
330 325
			if (s.equals("txmcorpus")) //$NON-NLS-1$
331
				continue;//ignore the txmcorpus structure
332
			
326
				continue;// ignore the txmcorpus structure
327

  
333 328
			properties = new ArrayList<String>(internalArchitectureProperties.get(s).keySet());
334
			
329

  
335 330
			subbuffer.append("<li> " + s + "\n<ul>\n"); //$NON-NLS-1$ //$NON-NLS-2$
336 331
			if (internalArchitectureProperties.get(s).keySet().size() == 0)
337
				subbuffer.append("<li>"+PropertiesCoreMessages.Properties_26+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
332
				subbuffer.append("<li>" + PropertiesCoreMessages.Properties_26 + "</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$
338 333

  
339
			
340
			//System.out.println("struct: "+s+" >> "+properties);
334
			// System.out.println("struct: "+s+" >> "+properties);
341 335
			Collections.sort(properties);
342
			//System.out.println("struct: "+s+" >sort> "+properties);
336
			// System.out.println("struct: "+s+" >sort> "+properties);
343 337
			int nbOfValues = 0;
344 338
			for (String ps : properties) {
345
				if (!ps.equals("project") && !ps.equals("base") ) //$NON-NLS-1$ //$NON-NLS-2$ 
339
				if (!ps.equals("project") && !ps.equals("base")) //$NON-NLS-1$ //$NON-NLS-2$
346 340
				{
347
					//System.out.println("struct: "+s+" >> "+ps);
341
					// System.out.println("struct: "+s+" >> "+ps);
348 342
					int valuecount = internalArchitecturePropertiesCounts.get(s).get(ps);
349 343
					ArrayList<String> values = new ArrayList<String>(internalArchitectureProperties.get(s).get(ps));
350 344
					subbuffer.append("<li> " + ps + " (" + valuecount + ") = "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
351
					//System.out.println("VALUES: "+values);
345
					// System.out.println("VALUES: "+values);
352 346
					Collections.sort(values);
353
					for (int i = 0 ; i < values.size() ; i++) {
347
					for (int i = 0; i < values.size(); i++) {
354 348
						nbOfValues++;
355 349
						String psv = values.get(i);
356 350
						if (psv != null && psv.length() > 0)
357 351
							subbuffer.append(psv.replace("<", "&lt;")); //$NON-NLS-1$ //$NON-NLS-2$
358 352
						else
359 353
							subbuffer.append("\"\""); //$NON-NLS-1$
360
						
361
						if (i == values.size() -1)
354

  
355
						if (i == values.size() - 1)
362 356
							subbuffer.append("."); //$NON-NLS-1$
363 357
						else
364 358
							subbuffer.append(", "); //$NON-NLS-1$
365
						
359

  
366 360
						if (i >= pMaxPropertiesToDisplay) {
367 361
							subbuffer.append("..."); //$NON-NLS-1$
368 362
							break;
......
379 373
		buff.append("</ul>\n"); //$NON-NLS-1$
380 374
		buff.append("</body>\n"); //$NON-NLS-1$
381 375
		buff.append("</html>\n"); //$NON-NLS-1$
382
		
376

  
383 377
		return buff.toString();
384 378
	}
385 379

  
386
	
387
	
388 380
	/**
389 381
	 * dump the result in the console.
390 382
	 *
391
	 * @param maxvalue the maxvalue
383
	 * @param maxvalue
384
	 *            the maxvalue
392 385
	 * @return the string
393 386
	 */
394 387
	public String dump(int maxvalue) {
395 388
		StringBuffer buff = new StringBuffer();
396 389

  
397 390
		buff.append(PropertiesCoreMessages.Properties_40);
398
		buff.append(PropertiesCoreMessages.Properties_41 + String.format(Locale.FRANCE,"%,d", numberOfWords) + "\n"); //$NON-NLS-1$ 
399
		buff.append(PropertiesCoreMessages.Properties_43 + String.format("%,d", NProperties) + "\n"); //$NON-NLS-1$ 
400
		/*for (String s : propertiesCounts.keySet())
401
			if (!s.equals("id")) //$NON-NLS-1$
402
				buff.append(" - " + s + " " + propertiesCounts.get(s) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
403
				*/
404
		buff.append(PropertiesCoreMessages.Properties_49 + String.format("%,d", NStructures) + "\n"); //$NON-NLS-1$ 
391
		buff.append(PropertiesCoreMessages.Properties_41 + String.format(Locale.FRANCE, "%,d", numberOfWords) + "\n"); //$NON-NLS-1$
392
		buff.append(PropertiesCoreMessages.Properties_43 + String.format("%,d", NProperties) + "\n"); //$NON-NLS-1$
393
		/*
394
		 * for (String s : propertiesCounts.keySet()) if (!s.equals("id")) //$NON-NLS-1$
395
		 * buff.append(" - " + s + " " + propertiesCounts.get(s) + "\n"); //$NON-NLS-1$
396
		 * //$NON-NLS-2$ //$NON-NLS-3$
397
		 */
398
		buff.append(PropertiesCoreMessages.Properties_49 + String.format("%,d", NStructures) + "\n"); //$NON-NLS-1$
405 399
		for (String s : structuresCounts.keySet())
406
			buff.append(" - " + s + "\n");//+structuresCounts.get(s)+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
400
			buff.append(" - " + s + "\n");// +structuresCounts.get(s)+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
407 401

  
408 402
		/*
409 403
		 * buff.append("* Structural Units counts\n"); for(String s :
410
		 * internalArchitecture)
411
		 * buff.append(" - "+s+" "+hierarchieCounts.get(s)+"\n");
404
		 * internalArchitecture) buff.append(" - "+s+" "+hierarchieCounts.get(s)+"\n");
412 405
		 */
413 406
		buff.append(PropertiesCoreMessages.Properties_0);
414 407
		for (String s : internalArchitecture) {
......
416 409
			for (String ps : internalArchitectureProperties.get(s).keySet()) {
417 410
				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$
418 411
				{
419
					buff
420
					.append("   - " + ps + "(" + internalArchitectureProperties.get(s).get(ps).size() + ") = "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
412
					buff.append("   - " + ps + "(" + internalArchitectureProperties.get(s).get(ps).size() + ") = "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
421 413

  
422 414
					int valuecount = 0;
423
					for (String psv : internalArchitectureProperties.get(s)
424
							.get(ps)) {
415
					for (String psv : internalArchitectureProperties.get(s).get(ps)) {
425 416
						buff.append(psv);
426 417
						if (valuecount++ >= maxvalue) {
427 418
							buff.append("..."); //$NON-NLS-1$
428 419
							break;
429 420
						}
430
						if (valuecount < internalArchitectureProperties.get(s)
431
								.get(ps).size())
421
						if (valuecount < internalArchitectureProperties.get(s).get(ps).size())
432 422
							buff.append(", "); //$NON-NLS-1$
433 423
					}
434 424

  
......
533 523
	/**
534 524
	 * dump the diagnostic in a text file.
535 525
	 *
536
	 * @param outfile the outfile
537
	 * @param maxvalue the maxvalue
526
	 * @param outfile
527
	 *            the outfile
528
	 * @param maxvalue
529
	 *            the maxvalue
538 530
	 * @return true, if successful
539 531
	 */
540 532
	public boolean toTxt(File outfile, String encoding, int maxvalue) {
......
554 546
	/**
555 547
	 * dump the diagnostic in a HTML file.
556 548
	 *
557
	 * @param outfile the outfile
549
	 * @param outfile
550
	 *            the outfile
558 551
	 * @return true, if successful
559 552
	 */
560 553
	public boolean toHTML(File outfile) {
561 554
		outfile.getParentFile().mkdirs();
562 555
		PrintWriter writer;
563 556
		try {
564
			writer = IOUtils.getWriter(outfile); //$NON-NLS-1$
557
			writer = IOUtils.getWriter(outfile); // $NON-NLS-1$
565 558
			writer.write(this.htmlDump());
566 559
			writer.close();
567 560
		} catch (IOException e) {
......
575 568
	/**
576 569
	 * dump the diagnostic in a text file, maxvalue = 100.
577 570
	 *
578
	 * @param outfile the outfile
571
	 * @param outfile
572
	 *            the outfile
579 573
	 * @return true, if successful
580 574
	 */
581 575
	public boolean toTxt(File outfile) {
......
604 598

  
605 599
	@Override
606 600
	protected boolean _compute() throws Exception {
607
		
601

  
608 602
		this.beginTask("Computing properties...", 3);
609 603
		this.stepGeneralInfos();
610 604
		this.worked(1);
611
		
605

  
612 606
		this.stepLexicalProperties();
613 607
		this.worked(1);
614
		
608

  
615 609
		this.stepStructuralUnits();
616 610
		this.worked(1);
617
		
611

  
618 612
		String txmhome = Toolbox.getTxmHomePath();
619 613
		String filename = corpus.getMainCorpus() + "-" + corpus.getName(); //$NON-NLS-1$
620 614
		if (corpus instanceof MainCorpus) {
621
			filename = corpus.getID(); //$NON-NLS-1$
615
			filename = corpus.getID(); // $NON-NLS-1$
622 616
		}
623
		
617

  
624 618
		filename = AsciiUtils.buildId(filename);
625 619
		file = new File(txmhome, "results/" + filename + "-infos.html"); //$NON-NLS-1$ //$NON-NLS-2$
626
		
620

  
627 621
		this.toHTML(file);
628 622
		return true;
629 623
	}
630
	
624

  
631 625
	/**
632 626
	 * Gets the HTML file.
627
	 * 
633 628
	 * @return the HTML file
634 629
	 */
635 630
	public File getHTMLFile() {
......
647 642
		return true;
648 643
	}
649 644

  
650
	
651 645
	@Override
652 646
	public boolean saveParameters() {
653 647
		// nothing to do -> all parameters are already managed by autoSaveParameters
tmp/org.txm.partition.core/src/org/txm/partition/core/preferences/PartitionDimensionsPreferences.java (revision 1164)
10 10
 * @author sjacquot
11 11
 *
12 12
 */
13
public class PartitionDimensionsPreferences extends TXMPreferences {
13
public class PartitionDimensionsPreferences extends ChartsEnginePreferences {
14 14

  
15
	
16
	
17 15
	public static final String CHART_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE = "chart_dimensions_display_parts_count_in_title"; //$NON-NLS-1$
18 16
	public static final String CHART_DIMENSIONS_SORT_BY_SIZE = "chart_dimensions_sort_by_parts_size"; //$NON-NLS-1$
19 17
	
20
	
21
	
22 18
	/**
23 19
	 * Gets the instance.
24 20
	 * @return the instance
......
29 25
		}
30 26
		return TXMPreferences.instances.get(PartitionDimensionsPreferences.class);
31 27
	}
32

  
33 28
	
34 29
	@Override
35 30
	public void initializeDefaultPreferences() {
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 1164)
498 498
	 * @throws Exception 
499 499
	 */
500 500
	public int getNRows() throws Exception {
501
		return statsData.getNRows();
501
		if (statsData != null) {
502
			return statsData.getNRows();
503
		} else {
504
			return 0;
505
		}
502 506
	}
503 507

  
504 508
	/**
......
538 542
	}
539 543

  
540 544
	public Vector getRowNames() throws Exception {
541
		return statsData.getRowNames();
545
		if (statsData != null) {
546
			return statsData.getRowNames();
547
		} else {
548
			return null;
549
		}
542 550
	}
543 551

  
544 552
	@Override
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/listeners/ComputeSelectionListener.java (revision 1164)
35 35
	@Override
36 36
	public void widgetDefaultSelected(SelectionEvent e) {
37 37
		// TODO Auto-generated method stub
38
		if((e.getSource() instanceof Spinner) || e.stateMask != 0)	{
39
			this.editor.compute(true);	
40
		}
38 41
	}
39 42

  
40 43
	@Override
tmp/org.txm.wordcloud.core/src/org/txm/wordcloud/core/preferences/WordCloudPreferences.java (revision 1164)
13 13
 * @author sjacquot
14 14
 *
15 15
 */
16
public class WordCloudPreferences extends TXMPreferences {
16
public class WordCloudPreferences extends ChartsEnginePreferences {
17 17

  
18

  
19 18
	public static final String PREFERENCES_PREFIX = "wordcloud_";
20 19
	
21 20
	public static final String MAX_WORDS_COUNT = PREFERENCES_PREFIX + "max_words"; //$NON-NLS-1$
......
23 22
	public static final String ROTATION_PERCENT = PREFERENCES_PREFIX + "rotation_percent"; //$NON-NLS-1$
24 23
	public static final String RANDOM_POSITIONS = PREFERENCES_PREFIX + "random_positions"; //$NON-NLS-1$
25 24

  
26
	
27 25
	@Override
28 26
	public void initializeDefaultPreferences() {
29 27
		super.initializeDefaultPreferences();
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/handlers/ComputeCooccurrences.java (revision 1164)
90 90

  
91 91
				int minf = CooccurrencePreferences.getInstance().getInt(TXMPreferences.F_MIN);
92 92
				int mincof = CooccurrencePreferences.getInstance().getInt(CooccurrencePreferences.MIN_COUNT);
93
				int minscore = (int) CooccurrencePreferences.getInstance().getDouble(CooccurrencePreferences.MIN_SCORE);
93
				float minscore = CooccurrencePreferences.getInstance().getFloat(CooccurrencePreferences.MIN_SCORE);
94 94
				boolean buildLexicalTableWithCooccurrents = CooccurrencePreferences.getInstance().getBoolean(CooccurrencePreferences.PARTIAL_LEXICAL_TABLE);
95 95

  
96 96
				StructuralUnit limit = null;
......
107 107

  
108 108
				try {
109 109
					cooc = new Cooccurrence(corpus);
110
					cooc.setParameters(query, properties, limit, maxleft, minleft, minright, maxright, minf, mincof, minscore, false, buildLexicalTableWithCooccurrents);
110
					cooc.setParameters(query, properties, limit, maxleft, minleft, minright, maxright, minf, minscore, mincof, false, buildLexicalTableWithCooccurrents);
111 111
				}
112 112
				catch (Exception e) {
113 113
					Log.printStackTrace(e);
tmp/org.txm.progression.core/src/org/txm/progression/core/preferences/ProgressionPreferences.java (revision 1164)
12 12
 * @author sjacquot
13 13
 *
14 14
 */
15
public class ProgressionPreferences extends TXMPreferences {
15
public class ProgressionPreferences extends ChartsEnginePreferences {
16 16

  
17

  
18 17
	/** The Constant REPEAT_VALUES. */
19 18
	public static final String REPEAT_SAME_VALUES = "repeat_same_values"; //$NON-NLS-1$
20 19

  
tmp/org.txm.textsbalance.core/src/org/txm/textsbalance/core/preferences/TextsBalancePreferences.java (revision 1164)
11 11
 * @author sjacquot
12 12
 *
13 13
 */
14
public class TextsBalancePreferences extends TXMPreferences {
14
public class TextsBalancePreferences extends ChartsEnginePreferences {
15 15

  
16 16
	
17 17
	public static final String GROUP_BY_TEXTS = "group_by_texts"; //$NON-NLS-1$

Formats disponibles : Unified diff