Révision 3387

TXM/trunk/org.txm.cooccurrence.rcp/plugin.xml (revision 3387)
20 20
         point="org.eclipse.ui.preferencePages">
21 21
      <page
22 22
            category="org.txm.rcp.preferences.UserPreferencePage"
23
            class="org.txm.cooccurrence.rcp.preferences.CoocPreferencePage"
23
            class="org.txm.cooccurrence.rcp.preferences.CooccurrencesPreferencePage"
24 24
            id="org.txm.cooccurrence.rcp.preferences.CoocPreferencePage"
25 25
            name="%page.name">
26 26
      </page>
TXM/trunk/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/preferences/CoocPreferencePage.java (revision 3387)
1
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté
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.cooccurrence.rcp.preferences;
29

  
30
import org.eclipse.jface.preference.BooleanFieldEditor;
31
import org.eclipse.jface.preference.IntegerFieldEditor;
32
import org.eclipse.jface.preference.StringFieldEditor;
33
import org.eclipse.ui.IWorkbench;
34
import org.txm.cooccurrence.core.preferences.CooccurrencePreferences;
35
import org.txm.cooccurrence.rcp.adapters.CooccurrenceAdapterFactory;
36
import org.txm.cooccurrence.rcp.messages.CooccurrenceUIMessages;
37
import org.txm.core.preferences.TXMPreferences;
38
import org.txm.rcp.preferences.TXMPreferencePage;
39
import org.txm.rcp.preferences.TXMPreferenceStore;
40
import org.txm.rcp.jface.DoubleFieldEditor;
41

  
42
/**
43
 * Cooccurrence preference page.
44
 * 
45
 * @author mdecorde
46
 * @author sjacquot
47
 *
48
 */
49
public class CoocPreferencePage extends TXMPreferencePage {
50
	
51
	
52
	@Override
53
	public void createFieldEditors() {
54
		
55
		/** The scoreformatfield. */
56
		StringFieldEditor scoreformatfield = new StringFieldEditor(CooccurrencePreferences.SCORE_FORMAT, CooccurrenceUIMessages.scoreFormatDefault00000E00, getFieldEditorParent());
57
		scoreformatfield.setTextLimit(15);
58
		
59
		/** The minfreqfield. */
60
		IntegerFieldEditor minfreqfield = new IntegerFieldEditor(TXMPreferences.F_MIN, CooccurrenceUIMessages.minimumFrequencyThresholdOfTheCooccurrent, getFieldEditorParent());
61
		minfreqfield.setValidRange(0, Integer.MAX_VALUE);
62
		
63
		/** The mincountfield. */
64
		IntegerFieldEditor mincountfield = new IntegerFieldEditor(CooccurrencePreferences.MIN_COUNT, CooccurrenceUIMessages.minimumCooccurrencyCountThreshold, getFieldEditorParent());
65
		mincountfield.setValidRange(0, Integer.MAX_VALUE);
66
		
67
		/** The minscorefield. */
68
		DoubleFieldEditor minscorefield = new DoubleFieldEditor(CooccurrencePreferences.MIN_SCORE, CooccurrenceUIMessages.minimumCooccurrencyScoreThreshold, getFieldEditorParent());
69
		minscorefield.setTextLimit(15);
70
		
71
		IntegerFieldEditor maxleftfield = new IntegerFieldEditor(CooccurrencePreferences.MAX_LEFT, CooccurrenceUIMessages.maximumLeft, getFieldEditorParent());
72
		maxleftfield.setValidRange(0, 99999);
73
		
74
		IntegerFieldEditor minleftfield = new IntegerFieldEditor(CooccurrencePreferences.MIN_LEFT, CooccurrenceUIMessages.minimumLeft, getFieldEditorParent());
75
		minleftfield.setValidRange(0, 99999);
76
		
77
		IntegerFieldEditor minrightfield = new IntegerFieldEditor(CooccurrencePreferences.MIN_RIGHT, CooccurrenceUIMessages.minimumRight, getFieldEditorParent());
78
		minrightfield.setValidRange(0, 99999);
79
		
80
		IntegerFieldEditor maxrightfield = new IntegerFieldEditor(CooccurrencePreferences.MAX_RIGHT, CooccurrenceUIMessages.maximumRight, getFieldEditorParent());
81
		maxrightfield.setValidRange(0, 99999);
82
		
83
		BooleanFieldEditor partiallexicaltablefield = new BooleanFieldEditor(CooccurrencePreferences.PARTIAL_LEXICAL_TABLE, CooccurrenceUIMessages.usePartialLexicalTable, getFieldEditorParent());
84
		
85
		addField(scoreformatfield);
86
		addField(minfreqfield);
87
		addField(mincountfield);
88
		addField(minscorefield);
89
		addField(maxleftfield);
90
		addField(minleftfield);
91
		addField(minrightfield);
92
		addField(maxrightfield);
93
		addField(partiallexicaltablefield);
94
	}
95
	
96
	
97
	
98
	@Override
99
	public void init(IWorkbench workbench) {
100
		this.setPreferenceStore(new TXMPreferenceStore(CooccurrencePreferences.getInstance().getPreferencesNodeQualifier()));
101
		// setDescription("Cooccurrences");
102
		this.setTitle(CooccurrenceUIMessages.cooccurrences);
103
		this.setImageDescriptor(CooccurrenceAdapterFactory.ICON);
104
	}
105
	
106
	
107
}
TXM/trunk/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/preferences/CooccurrencesPreferencePage.java (revision 3387)
1
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté
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.cooccurrence.rcp.preferences;
29

  
30
import org.eclipse.jface.preference.BooleanFieldEditor;
31
import org.eclipse.jface.preference.IntegerFieldEditor;
32
import org.eclipse.jface.preference.StringFieldEditor;
33
import org.eclipse.ui.IWorkbench;
34
import org.txm.cooccurrence.core.preferences.CooccurrencePreferences;
35
import org.txm.cooccurrence.rcp.adapters.CooccurrenceAdapterFactory;
36
import org.txm.cooccurrence.rcp.messages.CooccurrenceUIMessages;
37
import org.txm.core.preferences.TXMPreferences;
38
import org.txm.rcp.preferences.TXMPreferencePage;
39
import org.txm.rcp.preferences.TXMPreferenceStore;
40
import org.txm.rcp.jface.DoubleFieldEditor;
41

  
42
/**
43
 * Cooccurrence preference page.
44
 * 
45
 * @author mdecorde
46
 * @author sjacquot
47
 *
48
 */
49
public class CooccurrencesPreferencePage extends TXMPreferencePage {
50
	
51
	
52
	@Override
53
	public void createFieldEditors() {
54
		
55
		/** The scoreformatfield. */
56
		StringFieldEditor scoreformatfield = new StringFieldEditor(CooccurrencePreferences.SCORE_FORMAT, CooccurrenceUIMessages.scoreFormatDefault00000E00, getFieldEditorParent());
57
		scoreformatfield.setTextLimit(15);
58
		
59
		/** The minfreqfield. */
60
		IntegerFieldEditor minfreqfield = new IntegerFieldEditor(TXMPreferences.F_MIN, CooccurrenceUIMessages.minimumFrequencyThresholdOfTheCooccurrent, getFieldEditorParent());
61
		minfreqfield.setValidRange(0, Integer.MAX_VALUE);
62
		
63
		/** The mincountfield. */
64
		IntegerFieldEditor mincountfield = new IntegerFieldEditor(CooccurrencePreferences.MIN_COUNT, CooccurrenceUIMessages.minimumCooccurrencyCountThreshold, getFieldEditorParent());
65
		mincountfield.setValidRange(0, Integer.MAX_VALUE);
66
		
67
		/** The minscorefield. */
68
		DoubleFieldEditor minscorefield = new DoubleFieldEditor(CooccurrencePreferences.MIN_SCORE, CooccurrenceUIMessages.minimumCooccurrencyScoreThreshold, getFieldEditorParent());
69
		minscorefield.setTextLimit(15);
70
		
71
		IntegerFieldEditor maxleftfield = new IntegerFieldEditor(CooccurrencePreferences.MAX_LEFT, CooccurrenceUIMessages.maximumLeft, getFieldEditorParent());
72
		maxleftfield.setValidRange(0, 99999);
73
		
74
		IntegerFieldEditor minleftfield = new IntegerFieldEditor(CooccurrencePreferences.MIN_LEFT, CooccurrenceUIMessages.minimumLeft, getFieldEditorParent());
75
		minleftfield.setValidRange(0, 99999);
76
		
77
		IntegerFieldEditor minrightfield = new IntegerFieldEditor(CooccurrencePreferences.MIN_RIGHT, CooccurrenceUIMessages.minimumRight, getFieldEditorParent());
78
		minrightfield.setValidRange(0, 99999);
79
		
80
		IntegerFieldEditor maxrightfield = new IntegerFieldEditor(CooccurrencePreferences.MAX_RIGHT, CooccurrenceUIMessages.maximumRight, getFieldEditorParent());
81
		maxrightfield.setValidRange(0, 99999);
82
		
83
		StringFieldEditor milestonesfield = new StringFieldEditor(CooccurrencePreferences.MILESTONE_STRUCTURES_TO_IGNORE, "Milestone structures list (comma separated)", getFieldEditorParent());
84
		
85
		BooleanFieldEditor partiallexicaltablefield = new BooleanFieldEditor(CooccurrencePreferences.PARTIAL_LEXICAL_TABLE, CooccurrenceUIMessages.usePartialLexicalTable, getFieldEditorParent());
86
		
87
		addField(scoreformatfield);
88
		addField(minfreqfield);
89
		addField(mincountfield);
90
		addField(minscorefield);
91
		addField(maxleftfield);
92
		addField(minleftfield);
93
		addField(minrightfield);
94
		addField(maxrightfield);
95
		addField(milestonesfield);
96
		addField(partiallexicaltablefield);
97
	}
98
	
99
	
100
	
101
	@Override
102
	public void init(IWorkbench workbench) {
103
		this.setPreferenceStore(new TXMPreferenceStore(CooccurrencePreferences.getInstance().getPreferencesNodeQualifier()));
104
		// setDescription("Cooccurrences");
105
		this.setTitle(CooccurrenceUIMessages.cooccurrences);
106
		this.setImageDescriptor(CooccurrenceAdapterFactory.ICON);
107
	}
108
	
109
	
110
}
0 111

  
TXM/trunk/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/messages/CooccurrenceUIMessages.java (revision 3387)
37 37
	public static String score_2; 
38 38
	public static String cooccurrent; 
39 39
	public static String meanDistance; 
40
	
41
	public static String wordWindow; 
42
	public static String structureWindow; 
40 43

  
41 44
	static {
42 45
		// initialize resource bundle
TXM/trunk/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/messages/messages.properties (revision 3387)
21 21
theScoreThresholdMustBeARealNumberCurrentValueEqualsP0=The score threshold must be a real number (the current value is {0})
22 22
thresholdsColonFmin=Thresholds\: Fmin ≥
23 23
usePartialLexicalTable=Calculate the margins from the frequencies of the co-occurrents instead of the frequencies of all the words of the corpus
24
wordWindow=Word window
25
structureWindow=Structure
TXM/trunk/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/messages/messages_fr.properties (revision 3387)
21 21
theScoreThresholdMustBeARealNumberCurrentValueEqualsP0=Le seuil d''indice doit être un nombre réel (la valeur actuelle est {0})
22 22
thresholdsColonFmin=Seuils \: Fmin ≥
23 23
usePartialLexicalTable=Calculer les marges à partir des fréquences des cooccurents plutôt qu'à partir des fréquences de tous les mots du corpus
24
wordWindow=Fenêtre de mots
25
structureWindow=Structure
TXM/trunk/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/editors/EmpantWidget.java (revision 3387)
27 27
//
28 28
package org.txm.cooccurrence.rcp.editors;
29 29

  
30
import java.util.Arrays;
31
import java.util.Collections;
32
import java.util.Comparator;
33
import java.util.HashSet;
34

  
30 35
import org.eclipse.swt.SWT;
31 36
import org.eclipse.swt.events.KeyListener;
32 37
import org.eclipse.swt.events.SelectionEvent;
33 38
import org.eclipse.swt.events.SelectionListener;
39
import org.eclipse.swt.graphics.Color;
40
import org.eclipse.swt.graphics.RGB;
34 41
import org.eclipse.swt.layout.GridData;
35 42
import org.eclipse.swt.layout.GridLayout;
36 43
import org.eclipse.swt.widgets.Button;
......
38 45
import org.eclipse.swt.widgets.Composite;
39 46
import org.eclipse.swt.widgets.Label;
40 47
import org.eclipse.swt.widgets.Spinner;
48
import org.txm.cooccurrence.core.preferences.CooccurrencePreferences;
49
import org.txm.cooccurrence.rcp.messages.CooccurrenceUIMessages;
41 50
import org.txm.rcp.messages.TXMUIMessages;
42 51
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
43 52
import org.txm.searchengine.cqp.corpus.CQPCorpus;
......
112 121
		l.setText(TXMUIMessages.contextColon);
113 122
		
114 123
		wordType = new Button(line1, SWT.RADIO);
115
		wordType.setText(TXMUIMessages.word);
124
		wordType.setText(CooccurrenceUIMessages.wordWindow);
116 125
		wordType.addSelectionListener(new SelectionListener() {
117 126
			
118 127
			@Override
119 128
			public void widgetSelected(SelectionEvent e) {
120 129
				structs.setEnabled(false);
130
				checkLeft.setSelection(true);
131
				checkRight.setSelection(true);
121 132
				checkXword.setEnabled(false);
133
				
134
				checkXword.setSelection(false);
135
				maxLeft.setSelection(CooccurrencePreferences.getInstance().getInt(CooccurrencePreferences.MAX_LEFT)-1);
136
				minLeft.setSelection(CooccurrencePreferences.getInstance().getInt(CooccurrencePreferences.MIN_LEFT)-1);
137
				minRight.setSelection(CooccurrencePreferences.getInstance().getInt(CooccurrencePreferences.MIN_RIGHT)-1);
138
				maxRight.setSelection(CooccurrencePreferences.getInstance().getInt(CooccurrencePreferences.MAX_RIGHT)-1);
122 139
			}
123 140
			
124 141
			@Override
......
127 144
		wordType.setSelection(true);
128 145
		
129 146
		structType = new Button(line1, SWT.RADIO);
130
		structType.setText(TXMUIMessages.structure);
147
		structType.setText(CooccurrenceUIMessages.structureWindow);
131 148
		structType.addSelectionListener(new SelectionListener() {
132 149
			
133 150
			@Override
134 151
			public void widgetSelected(SelectionEvent e) {
135 152
				structs.setEnabled(true);
153
				checkLeft.setSelection(false);
154
				checkRight.setSelection(false);
136 155
				checkXword.setEnabled(true);
156
				
157
				checkXword.setSelection(true);
158
				maxLeft.setSelection(0);
159
				minLeft.setSelection(0);
160
				minRight.setSelection(0);
161
				maxRight.setSelection(0);
137 162
			}
138 163
			
139 164
			@Override
......
281 306
	private void loadStructs() {
282 307
		try {
283 308
			java.util.List<StructuralUnit> corpusstructuralunits = corpus.getOrderedStructuralUnits();
309
			HashSet<String> suToIgnore = new HashSet<>(Arrays.asList(CooccurrencePreferences.getInstance().getString(CooccurrencePreferences.MILESTONE_STRUCTURES_TO_IGNORE).split(",")));
284 310
			for (StructuralUnit su : corpusstructuralunits) {
285
				if (!su.getName().equals("text") //$NON-NLS-1$
286
						&& !su.getName().equals("txmcorpus")) //$NON-NLS-1$
287
				{
311
				//if (!su.getName().equals("text") && !su.getName().equals("txmcorpus")) { //$NON-NLS-1$ $NON-NLS-2$
312
				if (!suToIgnore.contains(su.getName())) { //$NON-NLS-1$ $NON-NLS-2$
288 313
					structs.add(su.getName());
289 314
				}
290 315
			}
291 316
			if (corpusstructuralunits.size() > 0) {
292
				structs.select(0);
317
				int pi = Arrays.binarySearch(structs.getItems(), "p");
318
				int si = Arrays.binarySearch(structs.getItems(), "s");
319
				if (pi > 0) {
320
					structs.select(pi);
321
				} else if (si > 0) {
322
					structs.select(si);
323
				} else {
324
					structs.select(0);
325
				}
293 326
			}
294 327
		}
295 328
		catch (CqiClientException e) {
TXM/trunk/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationWriter.java (revision 3387)
228 228
		Log.fine(" - Copying previous version of XML files in: " + previousXMLTXMDirectory);
229 229
		// for all annotation PER TEXT, update the XML-TXM files
230 230
		currentText = 0;
231
		ConsoleProgressBar cpb = new ConsoleProgressBar(annotationsPerTexts.size());
231 232
		while (currentText < end_limits.length) { // end limits : 10, 30, 45, 55, 103
232 233
			currentXMLFile = new File(txmDirectory, textsIds.get(currentText) + ".xml");
233 234
			ArrayList<Annotation> allAnnotations = annotationsPerTexts.get(textsIds.get(currentText));
......
267 268
				}
268 269
			}
269 270
			currentText++;
271
			cpb.tick();
270 272
		}
273
		cpb.done();
271 274
		
272 275
		return true;
273 276
	}
TXM/trunk/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/functions/Cooccurrence.java (revision 3387)
1449 1449
				distances.put(signaturestr, (distances.get(signaturestr)) + dist);
1450 1450
			}
1451 1451
			else {
1452
				distances.put(signaturestr, 0.0);
1452
				distances.put(signaturestr, (double)dist);
1453 1453
			}
1454 1454

  
1455 1455
			Integer count = (counts.get(signaturestr));
......
1465 1465
			}
1466 1466

  
1467 1467
			// if ("[1599]".equals(signaturestr)) {
1468
			// System.out.println("p=" + position + " d=" + dist + " total(d)=" + distances.get(signaturestr) + " c=" + counts.get(signaturestr));
1468
			//System.out.println("sign="+allsignaturesstr.get(position)+" p=" + position + " c=" + counts.get(signaturestr) + " d=" + dist + " total(d)=" + distances.get(signaturestr)); 
1469 1469
			// }
1470 1470
			// }
1471 1471

  
......
1585 1585
						indexfreqs.get(specifrownames[ii]), scores[ii][1], // freq
1586 1586
						((float) (distances.get(signaturestr) / counts.get(signaturestr))), // mean distance
1587 1587
						-1);
1588
				if (debug) System.out.println("Line: "+specifrownames[ii]+" dists="+distances.get(signaturestr)+" counts="+counts.get(signaturestr)+" mean="+((float) (distances.get(signaturestr) / counts.get(signaturestr))));
1588
				// System.out.println("Line: "+specifrownames[ii]+" dists="+distances.get(signaturestr)+" counts="+counts.get(signaturestr)+" mean="+((float) (distances.get(signaturestr) / counts.get(signaturestr))));
1589 1589
				// select the line
1590 1590
				if (cline.freq >= this.pFminFilter && cline.nbocc >= this.pFCoocFilter && cline.score >= this.pScoreMinFilter) {
1591 1591
					if (cline.score >= Integer.MAX_VALUE - 5) {
TXM/trunk/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/preferences/CooccurrencePreferences.java (revision 3387)
31 31

  
32 32
	public static final String INCLUDE_X_PIVOT = "include_x_pivot"; //$NON-NLS-1$
33 33
	public static final String PARTIAL_LEXICAL_TABLE = "partial_lexical_table"; //$NON-NLS-1$
34
	public static final String MILESTONE_STRUCTURES_TO_IGNORE = "milestone_structures_to_ignore";
34 35
	
35 36

  
36 37
	public static final String QUERY_FILTER = "query_filter"; //$NON-NLS-1$
......
41 42
	 * @return the instance
42 43
	 */
43 44
	public static TXMPreferences getInstance()	{
45
		
44 46
		if (!TXMPreferences.instances.containsKey(CooccurrencePreferences.class)) {
47
			
45 48
			new CooccurrencePreferences();
46 49
		}
47 50
		return TXMPreferences.instances.get(CooccurrencePreferences.class);
......
50 53

  
51 54
	@Override
52 55
	public void initializeDefaultPreferences() {
56
		
53 57
		super.initializeDefaultPreferences();
54 58
		Preferences preferences = this.getDefaultPreferencesNode();
55 59
		
......
63 67
		preferences.putInt(MIN_RIGHT, 1);
64 68
		preferences.putInt(MAX_RIGHT, 10);
65 69
		
70
		preferences.put(MILESTONE_STRUCTURES_TO_IGNORE, "txmcorpus,text,anchor,cb,fw,gb,lb,milestone,pb");
66 71
		preferences.put(UNIT_PROPERTIES, TXMPreferences.DEFAULT_UNIT_PROPERTY);
67
		
68
		
69 72
	}
70 73
	
71 74
}

Formats disponibles : Unified diff