Révision 299

tmp/org.txm.lexicon.core/.settings/org.eclipse.jdt.core.prefs (revision 299)
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.lexicon.core/.classpath (revision 299)
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.lexicon.core/META-INF/MANIFEST.MF (revision 299)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Lexicon Core
4
Bundle-SymbolicName: org.txm.lexicon.core
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Vendor: Textometrie.org
7
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
8
Require-Bundle: org.txm.core;bundle-version="0.7.0",
9
 org.eclipse.core.runtime;bundle-version="3.10.0"
10
Export-Package: org.txm.lexicon.core.corpusengine.cqp,
11
 org.txm.lexicon.core.messages
0 12

  
tmp/org.txm.lexicon.core/.project (revision 299)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.lexicon.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.lexicon.core/src/org/txm/lexicon/core/corpusengine/cqp/Lexicon.java (revision 299)
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.lexicon.core.corpusengine.cqp;
29

  
30
import java.io.File;
31
import java.io.FileNotFoundException;
32
import java.io.FileOutputStream;
33
import java.io.IOException;
34
import java.io.OutputStreamWriter;
35
import java.io.UnsupportedEncodingException;
36
import java.util.Arrays;
37
import java.util.Map;
38

  
39
import org.txm.functions.Function;
40
import org.txm.lexicon.core.messages.LexiconCoreMessages;
41
import org.txm.searchengine.cqp.CqpDataProxy;
42
import org.txm.searchengine.cqp.corpus.Corpus;
43
import org.txm.searchengine.cqp.corpus.CorpusManager;
44
import org.txm.searchengine.cqp.corpus.Property;
45
import org.txm.searchengine.cqp.corpus.Subcorpus;
46
import org.txm.statsengine.core.StatException;
47
import org.txm.statsengine.core.data.Vector;
48
import org.txm.statsengine.r.core.data.VectorImpl;
49

  
50
// TODO: Auto-generated Javadoc
51
//  TODO should be put into stat.data package ?
52
/**
53
 * Represent a frequency list according to a {@link Corpus} (or a.
54
 *
55
 * {@link Subcorpus}) and a {@link Property}.
56
 * @author sloiseau
57
 */
58
public class Lexicon extends Function {
59

  
60
	
61
	/** The prefix r. */
62
	protected static String prefixR = "Lexicon"; //$NON-NLS-1$
63

  
64
	/** The nolex. */
65
	protected static int nolex = 1;
66
	
67
	/** The freqs. */
68
	private final int[] freqs;
69
	
70
	/** The ids. */
71
	private final int[] ids;
72
	
73
	/** The forms. */
74
	private String[] forms;
75
	
76
	/** The property. */
77
	private final Property property;
78
	
79
	/** The number of tokens. */
80
	int numberOfTokens = -1;
81

  
82
	/** The cache. */
83
	private Map<Property, CqpDataProxy> cache;
84
	
85
	/** The symbol. */
86
	private String symbol;
87
	
88
	/** The writer. */
89
	private OutputStreamWriter writer;
90

  
91
	/**
92
	 * Protected on purpose: should be accessed through.
93
	 *
94
	 * @param corpus the corpus
95
	 * @param property the property
96
	 * @param freq the freq
97
	 * @param ids the ids
98
	 * {@link Corpus#getLexicon(Property)} or
99
	 * {@link Subcorpus#getLexicon(Property)}.
100
	 */
101
	public Lexicon(Corpus corpus, Property property, final int[] freq, final int[] ids) {
102
		super(corpus);
103
		if (freq.length != ids.length)
104
			throw new IllegalArgumentException(LexiconCoreMessages.Lexicon_0);
105
		this.freqs = freq;
106
		this.ids = ids;
107
		this.forms = null;
108
		this.property = property;
109
	}
110

  
111
	/**
112
	 * Protected on purpose: should be accessed through.
113
	 *
114
	 * @param corpus the corpus
115
	 * @param property the property
116
	 * @param map the map
117
	 * {@link Corpus#getLexicon(Property)} or
118
	 * {@link Subcorpus#getLexicon(Property)}.
119
	 */
120
	public Lexicon(Corpus corpus, Property property, Map<String, Integer> map) {
121
		super(corpus);
122
		int size = map.size();
123
		freqs = new int[size];
124
		forms = map.keySet().toArray(new String[] {});
125
		for (int i = 0; i < forms.length; i++) {
126
			freqs[i] = map.get(forms[i]);
127
		}
128
		this.ids = null;
129
		this.property = property;
130
	}
131

  
132
	/**
133
	 * The dif ferent types in the lexicon, the type at the index <code>j</code>
134
	 * of this array have the frequency at index <code>j</code> in the array
135
	 * returned by {@link #getFreq()}.
136
	 * 
137
	 * @return types as an array of <code>String</code>
138
	 */
139
	public String[] getForms() {
140
		if (forms == null) {
141
			if(ids == null)
142
				return new String[0];
143
			try {
144
				forms = CorpusManager.getCorpusManager().getCqiClient().id2Str(
145
						property.getQualifiedName(), ids);
146
			} catch (Exception e) {
147
				// TODO Auto-generated catch block
148
				org.txm.utils.logger.Log.printStackTrace(e);
149
			}
150
		}
151
		return forms;
152
	}
153
	
154
	/**
155
	 * The dif ferent types in the lexicon, the type at the index <code>j</code>
156
	 * of this array have the frequency at index <code>j</code> in the array
157
	 * returned by {@link #getFreq()}.
158
	 *
159
	 * @param number the number
160
	 * @return types as an array of <code>String</code>
161
	 */
162
	public String[] getForms(int number) {
163
		//System.out.println("Lexicon("+this.property+" get forms. number="+number+", ids len="+ids.length);
164
		if (forms == null) {
165
			try {
166
				number = Math.min(number, ids.length);
167
				if (number <= 0)
168
					return new String[0];
169
				int[] subpositions = new int[number];
170
				System.arraycopy(ids, 0, subpositions, 0, number);
171
				return CorpusManager.getCorpusManager().getCqiClient().id2Str(
172
						property.getQualifiedName(), subpositions);
173
			} catch (Exception e) {
174
				// TODO Auto-generated catch block
175
				org.txm.utils.logger.Log.printStackTrace(e);
176
				return null;
177
			}
178
		}
179
		else
180
		{
181
			number = Math.min(number, ids.length);
182
			if (number <= 0)
183
				return new String[0];
184
			String[] subforms = new String[number];
185
			System.arraycopy(ids, 0, subforms, 0, number);
186
			return subforms;
187
		}
188
	}
189

  
190
	/**
191
	 * return the ids of the entries.
192
	 *
193
	 * @return types as an array of <code>String</code>
194
	 */
195
	public int[] getIds() {
196
		return ids;
197
	}
198

  
199
	/**
200
	 * The dif ferent frequencies in the lexicon. See {@link #getForms()}.
201
	 * 
202
	 * @return frequencies as an array of <code>int</code>
203
	 */
204
	public int[] getFreq() {
205
		return freqs;
206
	}
207

  
208
	/**
209
	 * Number of dif ferent types in the frequency list.
210
	 * 
211
	 * @return number of types in the corpus or subcorpus.
212
	 */
213
	public int nbrOfType() {
214
		return freqs.length;
215
	}
216

  
217
	/**
218
	 * Number of tokens (sum of all the frequencies) in the corpus.
219
	 * 
220
	 * @return the size of the corpus or subcorpus.
221
	 */
222
	public int nbrOfToken() {
223
		if (numberOfTokens <= 0)
224
			computeNumberOfTokens();
225
		return numberOfTokens;
226
	}
227

  
228
	/**
229
	 * Compute number of tokens. / this.nbr
230
	 */
231
	private void computeNumberOfTokens() {
232
		numberOfTokens = 0;
233
		for (int i = 0; i < freqs.length; i++) {
234
			numberOfTokens += freqs[i];
235
			// System.out.println(numberOfTokens);
236
			// if (freqs[i] != 1) System.out.println(freqs[i]);
237
		}
238
	}
239

  
240

  
241
	
242
	/**
243
	 * Convert the Lexicon into a Vector object.
244
	 *
245
	 * @return the vector
246
	 * @throws StatException the stat exception
247
	 */
248
	public Vector asVector() throws StatException {
249
		String symbol = prefixR + (nolex++);
250
		VectorImpl v = new VectorImpl(freqs, symbol);
251
		v.setRNames(getForms());
252
		this.symbol = v.getSymbol();
253
		return v;
254
	}
255

  
256
	//TODO: move this into a Lexicon chart renderer
257
//	/**
258
//	 * Draw a pareto graphic with this frequency list and record it into the
259
//	 * provided filename into svg format.
260
//	 *
261
//	 * @param file where to save the pareto graphic.
262
//	 * @return the pareto graphic
263
//	 * @throws StatException if anything goes wrong.
264
//	 */
265
//	public void getParetoGraphic(File file) throws StatException {
266
//		String rName = asVector().getSymbol();
267
//		String expr = "pareto(" + rName + ")"; //$NON-NLS-1$ //$NON-NLS-2$
268
//		try {
269
//			RWorkspace.getRWorkspaceInstance().plot(file, expr, RDevice.SVG);
270
//		} catch (Exception e) {
271
//			throw new StatException(e);
272
//		}
273
//	}
274

  
275
	/**
276
	 * The corpus or subcorpus this lexicon is build on.
277
	 * 
278
	 * @return the corpus
279
	 */
280
	public Corpus getCorpus() {
281
		return (Corpus) this.parent;
282
	}
283

  
284
	/**
285
	 * The property this lexicon is build on.
286
	 * 
287
	 * @return the property
288
	 */
289
	public Property getProperty() {
290
		return property;
291
	}
292

  
293

  
294
	/**
295
	 * Dump.
296
	 *
297
	 * @param col the col
298
	 * @param txt the txt
299
	 * @return the string
300
	 */
301
	public String dump(String col, String txt) {
302
		StringBuffer buffer = new StringBuffer();
303
		getForms();
304
		for (int i = 0; i < forms.length; i++) {
305
			buffer.append(txt+ forms[i].replace(txt, txt+txt) + txt + col + freqs[i] + "\n"); //$NON-NLS-1$ 
306
		}
307
		return buffer.toString();
308
	}
309

  
310
	/**
311
	 * To txt.
312
	 *
313
	 * @param outfile the outfile
314
	 * @param encoding the encoding
315
	 * @param colseparator the colseparator
316
	 * @param txtseparator the txtseparator
317
	 * @return true, if successful
318
	 */
319
	@Deprecated
320
	public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) {
321
		// NK: writer declared as class attribute to perform a clean if the operation is interrupted
322
		// OutputStreamWriter writer;
323
		try {
324
			this.writer = new OutputStreamWriter(new FileOutputStream(outfile),
325
					encoding); 
326
		} catch (UnsupportedEncodingException e1) {
327
			org.txm.utils.logger.Log.printStackTrace(e1);
328
			return false;
329
		} catch (FileNotFoundException e1) {
330
			org.txm.utils.logger.Log.printStackTrace(e1);
331
			return false;
332
		}
333

  
334
		try {
335
			writer.write(this.dump(colseparator, txtseparator));
336
			writer.close();
337
		} catch (IOException e) {
338
			org.txm.utils.logger.Log.printStackTrace(e);
339
			return false;
340
		}
341

  
342
		return true;
343
	}
344

  
345
	/* (non-Javadoc)
346
	 * @see java.lang.Object#equals(java.lang.Object)
347
	 */
348
	@Override
349
	public boolean equals(Object obj) {
350
		if (!(obj instanceof Lexicon))
351
			return false;
352
		Lexicon other = (Lexicon) obj;
353

  
354
		if (other.nbrOfType() != this.nbrOfType())
355
			return false;
356
		return (Arrays.equals(freqs, other.getFreq()) && Arrays.equals(
357
				getForms(), other.getForms()));
358
	}
359

  
360
	/**
361
	 * Sets the symbol.
362
	 *
363
	 * @param symbol the new symbol
364
	 */
365
	public void setSymbol(String symbol) {
366
		this.symbol = symbol;
367
	}
368
	
369
	/**
370
	 * Gets the symbol.
371
	 *
372
	 * @return the symbol
373
	 */
374
	public String getSymbol()
375
	{
376
		return this.symbol;
377
	}
378

  
379
	@Override
380
	public void clean() {
381
		try {
382
			this.writer.flush();
383
			this.writer.close();	
384
		}
385
		catch (NullPointerException e) {
386
		}
387
		catch (IOException e) {
388
			org.txm.utils.logger.Log.printStackTrace(e);
389
		}
390
	}
391

  
392
	@Override
393
	public boolean delete() {
394
		this.getCorpus().dropLexicon(getProperty());
395
		return super.delete();
396
	}
397

  
398
	@Override
399
	public String getName() {
400
		try {
401
			return LexiconCoreMessages.RESULT_TYPE + ": " + this.parent.getSimpleName() + ": " + this.getSimpleName();	
402
		}
403
		catch(Exception e) {
404
		}
405
		return "";
406
	}
407
	
408
	
409
	@Override
410
	public String toString() {
411
		return super.toString() + ": " + LexiconCoreMessages.Lexicon_3 + getName();
412
	}
413

  
414
	
415
	@Override
416
	public String getSimpleName() {
417
		try {
418
			return this.getProperty().getName();
419
		}
420
		catch(Exception e) {
421
		}
422
		return "";
423
	}
424

  
425
	@Override
426
	public String getDetails() {
427
		//FIXME: the hierarchy of Lexicon and Index should be redefined
428
		// Index should not store a Lexicon?
429
		// + Lexicon should extend Index?
430
//		try {
431
//			Object[] params = new Object[]{this.parent.getSimpleName(),index.getQuery().getQueryString(), index.getProperties(), index.getFmin(), index.getFmax()}; 
432
//			String str;
433
//			if(this.parent instanceof Partition)	{
434
//				str = LexiconCoreMessages.DetailsFromPartition;
435
//			}
436
//			else	{
437
//				str = LexiconCoreMessages.DetailsFromCorpus;
438
//			}
439
//			return NLS.bind(str, params);
440
//		}
441
//		catch(Exception e) {
442
//			return "";
443
//		}
444
		return null;
445
	}
446
}
0 447

  
tmp/org.txm.lexicon.core/src/org/txm/lexicon/core/messages/LexiconCoreMessages.java (revision 299)
1
package org.txm.lexicon.core.messages;
2

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

  
6

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

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

  
18
	public static String RESULT_TYPE;
19
	public static String Lexicon_0;
20
	public static String Lexicon_3;
21
	public static String DetailsFromPartition;
22
	public static String DetailsFromCorpus;
23

  
24
	
25
	static {
26
		// initialize resource bundle
27
		Utf8NLS.initializeMessages(BUNDLE_NAME, LexiconCoreMessages.class);
28
	}
29

  
30
	private LexiconCoreMessages() {
31
	}
32
}
0 33

  
tmp/org.txm.lexicon.core/src/org/txm/lexicon/core/messages/messages.properties (revision 299)
1

  
2
DetailsFromCorpus = Lexicon:\n\	Corpus {0}\n\	query {1}\n\	properties {2}\n\	Fmin {3}\n\	Fmax {4}
3

  
4
DetailsFromPartition = Lexicon:\n\	Partition {0}\n\	query {1}\n\	properties {2}\n\	Fmin {3}\n\	Fmax {4}
5

  
6
Lexicon_0 = Forms and frequencies tables must be of the same length.
7
Lexicon_3 = Lexicon : 
8

  
9
RESULT_TYPE = Lexicon
0 10

  
tmp/org.txm.lexicon.core/src/org/txm/lexicon/core/messages/messages_ru.properties (revision 299)
1

  
2
DetailsFromCorpus = Словарь:\n\	Корпус {0}\n\	Запрос {1}\n\	Свойства {2}\n\	Fmin {3}\n\	Fmax {4}
3

  
4
DetailsFromPartition = Словарь:\n\	Распределение {0}\n\	Запрос {1}\n\	Свойства {2}\n\	Fmin {3}\n\	Fmax {4}
5

  
6
RESULT_TYPE = Словарь
0 7

  
tmp/org.txm.lexicon.core/src/org/txm/lexicon/core/messages/messages_fr.properties (revision 299)
1

  
2
DetailsFromCorpus = Lexique :\n\	Corpus {0}\n\	Requête {1}\n\	Propriétés {2}\n\	Fmin {3}\n\	Fmax {4}
3

  
4
DetailsFromPartition = Lexique :\n\	Partition {0}\n\	Requête {1}\n\	Propriétés {2}\n\	Fmin {3}\n\	Fmax {4}
5

  
6
Lexicon_0 = Le tableau des formes et des fréquences doivent avoir la même longueur.
7
Lexicon_3 = Lexique :
8

  
9
RESULT_TYPE = Lexique
0 10

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

  
tmp/org.txm.lexicon.rcp/plugin.xml (revision 299)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.eclipse.ui.menus">
6
      <menuContribution
7
            allPopups="false"
8
            locationURI="toolbar:org.txm.rcpapplication.toolbartools">
9
         <command
10
               commandId="ComputeLexicon"
11
               icon="icons/lexicon.png"
12
               style="push"
13
               tooltip="%command.tooltip">
14
            <visibleWhen
15
                  checkEnabled="false">
16
               <reference
17
                     definitionId="OneCorpusSelected">
18
               </reference>
19
            </visibleWhen>
20
         </command>
21
      </menuContribution>
22
      <menuContribution
23
            allPopups="false"
24
            locationURI="popup:org.txm.rcpapplication.views.CorporaView">
25
         <command
26
               commandId="ComputeLexicon"
27
               icon="icons/lexicon.png"
28
               style="push">
29
            <visibleWhen
30
                  checkEnabled="false">
31
               <reference
32
                     definitionId="OneCorpusSelected">
33
               </reference>
34
            </visibleWhen>
35
         </command>
36
      </menuContribution>
37
      <menuContribution
38
            locationURI="menu:menu.tools">
39
         <command
40
               commandId="ComputeLexicon"
41
               icon="icons/lexicon.png"
42
               style="push">
43
            <visibleWhen
44
                  checkEnabled="false">
45
               <reference
46
                     definitionId="OneCorpusSelected">
47
               </reference>
48
            </visibleWhen>
49
         </command>
50
      </menuContribution>
51
   </extension>
52
   <extension
53
         point="org.eclipse.ui.commands">
54
               <command
55
            categoryId="org.txm.rcpapplication.category.txm"
56
            defaultHandler="org.txm.lexicon.rcp.handlers.ComputeLexicon"
57
            id="ComputeLexicon"
58
            name="%command.name">
59
      </command>
60
         
61
   </extension>
62
   <extension
63
         point="org.eclipse.ui.editors">
64
               <editor
65
            class="org.txm.lexicon.rcp.editors.DictionnaryEditor"
66
            default="false"
67
            icon="icons/lexicon.png"
68
            id="LexiconEditor"
69
            name="%editor.name">
70
      </editor>
71
         
72
   </extension>
73
   <extension
74
         point="org.eclipse.core.runtime.adapters">
75
      <factory
76
            adaptableType="org.txm.lexicon.core.corpusengine.cqp.Lexicon"
77
            class="org.txm.lexicon.rcp.adapters.LexiconAdapterFactory">
78
         <adapter
79
               type="org.eclipse.ui.model.IWorkbenchAdapter">
80
         </adapter>
81
      </factory>
82
   </extension>
83
   <extension
84
         point="org.eclipse.core.expressions.definitions">
85
      <definition
86
            id="OneLexiconSelected">
87
         <with
88
               variable="selection">
89
            <iterate
90
                  ifEmpty="false"
91
                  operator="and">
92
               <instanceof
93
                     value="org.txm.lexicon.core.corpusengine.cqp.Lexicon">
94
               </instanceof>
95
            </iterate>
96
         </with>
97
      </definition>
98
   </extension>
99

  
100
</plugin>
0 101

  
tmp/org.txm.lexicon.rcp/.settings/org.eclipse.jdt.core.prefs (revision 299)
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.lexicon.rcp/.classpath (revision 299)
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.lexicon.rcp/META-INF/MANIFEST.MF (revision 299)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Lexicon RCP
4
Bundle-SymbolicName: org.txm.lexicon.rcp;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
7
Require-Bundle: org.txm.core;bundle-version="0.7.0",
8
 org.txm.lexicon.core;bundle-version="1.0.0",
9
 org.txm.index.core;bundle-version="1.0.0",
10
 org.txm.index.rcp;bundle-version="1.0.0",
11
 org.eclipse.jface,
12
 org.txm.rcp;bundle-version="0.7.8",
13
 org.eclipse.ui;bundle-version="3.106.1",
14
 org.eclipse.core.runtime;bundle-version="3.10.0",
15
 org.eclipse.core.expressions;bundle-version="3.4.600"
16
Export-Package: org.txm.lexicon.rcp.adapters,
17
 org.txm.lexicon.rcp.editors,
18
 org.txm.lexicon.rcp.handlers
19
Bundle-Vendor: Textometrie.org
0 20

  
tmp/org.txm.lexicon.rcp/.project (revision 299)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.lexicon.rcp</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.lexicon.rcp/src/org/txm/lexicon/rcp/handlers/ComputeLexicon.java (revision 299)
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:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.lexicon.rcp.handlers;
29

  
30
import org.eclipse.core.commands.ExecutionEvent;
31
import org.eclipse.core.commands.ExecutionException;
32
import org.eclipse.ui.IWorkbenchPage;
33
import org.txm.index.core.functions.Index;
34
import org.txm.index.rcp.editors.IndexEditorInput;
35
import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
36
import org.txm.lexicon.rcp.editors.DictionnaryEditor;
37
import org.txm.rcp.handlers.BaseAbstractHandler;
38
import org.txm.rcpapplication.TXMWindows;
39
import org.txm.rcpapplication.views.corpora.CorporaView;
40
import org.txm.searchengine.cqp.corpus.Corpus;
41

  
42
// TODO: Auto-generated Javadoc
43
/**
44
 * Compute a Lexicon used it to create a Index (object) then open it in the
45
 * DictionnaryEditor
46
 * 
47
 * @author mdecorde
48
 * @author sjacquot
49
 */
50
public class ComputeLexicon extends BaseAbstractHandler {
51

  
52
	
53
	
54
	// adds a double click listener to the Corpus View
55
	static	{
56
		CorporaView.addDoubleClickListener(Lexicon.class, ComputeLexicon.class);
57
	}
58

  
59
	
60
	@Override
61
	public Object execute(ExecutionEvent event) throws ExecutionException {
62

  
63
		if(!this.checkCorpusEngine()) {
64
			return false;
65
		}
66
		
67
		Object selection = this.getSelection();
68
		IndexEditorInput editorInput = null;
69
		
70
		
71
		// New lexicon from corpus
72
		if(selection instanceof Corpus)	{
73
			editorInput = new IndexEditorInput((Corpus) selection);
74
		}
75
		// Reopens an existing lexicon
76
		else if(selection instanceof Lexicon)	{
77
			Lexicon lex = (Lexicon) selection;
78
			Index index = new Index(lex.getCorpus(), lex.getProperty());
79
			editorInput = new IndexEditorInput(index);
80
		}
81
		
82
		try {
83
			IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage();
84
			DictionnaryEditor editor = (DictionnaryEditor) page.openEditor(editorInput, "LexiconEditor"); //$NON-NLS-1$
85
			
86
			// compute
87
			if(selection instanceof Corpus)	{
88
				//FIXME: to hide the created index, but the problem is when user deletes the Lexicon node, the Index is not deleted, discuss about this
89
				//Actually I do not understand well the link between Lexicon and Index classes.
90
				//FIXME 2: now the Index is a child of the Lexicon so we can hide it if we want and it will be deleted when the Lexicon will be deleted
91
				editor.compute(false);
92
				//editor.compute();
93
				// editor.initializeFields();
94
			}
95
			
96
		}
97
		catch (Exception e) {
98
			org.txm.rcpapplication.utils.Logger.printStackTrace(e);
99
		} 
100

  
101
		
102
		return null;
103
	}
104
	
105

  
106
}
0 107

  
tmp/org.txm.lexicon.rcp/src/org/txm/lexicon/rcp/adapters/LexiconAdapterFactory.java (revision 299)
1
// Copyright © 2010-2013 ENS de Lyon.
2
package org.txm.lexicon.rcp.adapters;
3

  
4
import org.eclipse.jface.resource.ImageDescriptor;
5
import org.eclipse.ui.model.IWorkbenchAdapter;
6
import org.eclipse.ui.plugin.AbstractUIPlugin;
7
import org.osgi.framework.FrameworkUtil;
8
import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
9
import org.txm.rcp.adapters.TXMResultAdapter;
10
import org.txm.rcp.adapters.TXMResultAdapterFactory;
11

  
12

  
13
/**
14
 * A factory for creating Adapter objects.
15
 *  
16
 * @author mdecorde
17
 * @author sjacquot
18
 */
19
public class LexiconAdapterFactory extends TXMResultAdapterFactory {
20

  
21
	
22
	public static final ImageDescriptor ICON =
23
			AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(LexiconAdapterFactory.class).getSymbolicName(),
24
					"platform:/plugin/"+ FrameworkUtil.getBundle(LexiconAdapterFactory.class).getSymbolicName() + "/icons/lexicon.png"); //$NON-NLS-1$
25
	
26
	@Override
27
	public Object getAdapter(Object adaptableObject, Class adapterType) {
28
		if(adapterType == IWorkbenchAdapter.class && adaptableObject instanceof Lexicon)	{
29
			return new TXMResultAdapter() {
30
				@Override
31
				public ImageDescriptor getImageDescriptor(Object object) {
32
					// TODO Auto-generated method stub
33
					return ICON;
34
				}
35
			};
36
		}
37
		return null;
38
	}
39

  
40

  
41
}
0 42

  
tmp/org.txm.lexicon.rcp/src/org/txm/lexicon/rcp/editors/DictionnaryEditor.java (revision 299)
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:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.lexicon.rcp.editors;
29

  
30
import org.eclipse.osgi.util.NLS;
31
import org.eclipse.swt.widgets.Composite;
32
import org.txm.index.rcp.editors.IndexEditor;
33
import org.txm.lexicon.core.messages.LexiconCoreMessages;
34
// TODO: Auto-generated Javadoc
35
/**
36
 * extends the index editor to set : the number of property to 1 hide the
37
 * query field @ author mdecorde.
38
 */
39
public class DictionnaryEditor extends IndexEditor {
40

  
41
	/* (non-Javadoc)
42
	 * @see org.txm.rcpapplication.editors.index.IndexEditor#createPartControl(org.eclipse.swt.widgets.Composite)
43
	 */
44
	@Override
45
	public void createPartControl(final Composite parent) {
46
		super.createPartControl(parent);
47
		this.propsArea.setMaxPropertyNumber(1);
48
		this.queryWidget.setText("[]"); //$NON-NLS-1$
49
		this.queryWidget.setEnabled(false);
50
		this.queryWidget.setVisible(false);
51
		this.queryWidget.setSize(0, 0);
52
		this.queryWidget.dispose();
53
		this.queryLabel.setVisible(false);
54
		this.queryLabel.dispose();
55
		saveIndex = false;
56
	}
57
	
58

  
59
	/* (non-Javadoc)
60
	 * @see org.txm.rcpapplication.editors.index.IndexEditor#getTitleToolTip()
61
	 */
62
	@Override
63
	public String getTitleToolTip() {
64
		if (index != null) {
65
			String str;
66

  
67
			if (partition != null)
68
				str = NLS.bind(LexiconCoreMessages.DetailsFromPartition, new Object[]{partition.getName(), index.getQuery().getQueryString(), index.getProperties(), index.getFmin(), index.getFmax()});
69
			else
70
				str = NLS.bind(LexiconCoreMessages.DetailsFromCorpus, new Object[]{corpus.getName(), index.getQuery().getQueryString(), index.getProperties(), index.getFmin(), index.getFmax()});
71
			return str;
72
		}
73
		return ""; //$NON-NLS-1$
74
	}
75
	
76
	/* (non-Javadoc)
77
	 * @see org.txm.rcpapplication.editors.index.IndexEditor#getSource()
78
	 */
79
	@Override
80
	public Object getSource()
81
	{
82
		return index.getLexicon();
83
	}
84
}
0 85

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

  
tmp/org.txm.lexicon.rcp/OSGI-INF/l10n/bundle.properties (revision 299)
1

  
2
command.name = Lexicon
3

  
4
command.tooltip = Process the full lexicon
5

  
6
editor.name = Lexicon
0 7

  
tmp/org.txm.lexicon.rcp/OSGI-INF/l10n/bundle_ru.properties (revision 299)
1

  
2
command.name = Словарь
3

  
4
command.tooltip = Вычислить полный словарный состав
5

  
6
editor.name = Словарь
0 7

  
tmp/org.txm.lexicon.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 299)
1

  
2
command.name = Lexique
3

  
4
command.tooltip = Calculer le lexique complet
5

  
6
editor.name = Lexique
0 7

  

Formats disponibles : Unified diff