Révision 423

tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/handlers/ComputeCooccurrences.java (revision 423)
28 28
package org.txm.cooccurrence.rcp.handlers;
29 29

  
30 30
import java.util.ArrayList;
31
import java.util.HashMap;
32 31
import java.util.List;
33
import java.util.Properties;
34 32

  
35 33
import org.eclipse.core.commands.ExecutionEvent;
36 34
import org.eclipse.core.commands.ExecutionException;
37
import org.eclipse.ui.IWorkbenchPage;
38
import org.eclipse.ui.IWorkbenchWindow;
39
import org.eclipse.ui.handlers.HandlerUtil;
40 35
import org.txm.Toolbox;
41 36
import org.txm.concordance.core.functions.Concordance;
42 37
import org.txm.cooccurrence.core.functions.Cooccurrence;
43 38
import org.txm.cooccurrence.core.preferences.CooccurrencePreferences;
44 39
import org.txm.cooccurrence.rcp.editors.CooccurrencesEditor;
45 40
import org.txm.core.preferences.TXMPreferences;
46
import org.txm.core.results.ITXMResult;
47 41
import org.txm.rcp.Messages;
48 42
import org.txm.rcp.StatusLine;
49 43
import org.txm.rcp.editors.TXMEditorPart;
50 44
import org.txm.rcp.editors.TXMResultEditorInput;
51 45
import org.txm.rcp.handlers.BaseAbstractHandler;
52 46
import org.txm.rcp.views.corpora.CorporaView;
53
import org.txm.searchengine.cqp.CQPEngine;
54 47
import org.txm.searchengine.cqp.corpus.Corpus;
55 48
import org.txm.searchengine.cqp.corpus.Property;
56 49
import org.txm.searchengine.cqp.corpus.StructuralUnit;
......
85 78
		}
86 79

  
87 80

  
88
		if (!CQPEngine.isInitialized()) return null;
81
		if (!Toolbox.isSearchEngineInitialized()) return null;
89 82

  
90 83
		
91 84
		Object selection = this.getSelection();
92 85
		TXMResultEditorInput editorInput = null;
93 86
		
94 87
		// new editor from concordance
88
		// FIXME: need to edit this code, the computing must be done in the editor part, also need to check the process() method
89
		// this code should be moved to the Concordance plugin, it should create a TXMParameters from the concordance object then call this RCP parametrized command "ComputeCooccurrence"
90
		// by giving it the TXMParameters
95 91
		if (selection instanceof Concordance) {
96
			Cooccurrence cooc = computeCooc(selection);
97
			if (cooc != null) {
98
				editorInput = new TXMResultEditorInput(cooc);
92
			
93

  
94
			int minleft = 1;
95
			int maxleft = 50;
96
			int minright = 1;
97
			int maxright = 50;
98

  
99
			int minf = TXMPreferences.getInt(CooccurrencePreferences.MIN_FREQ, CooccurrencePreferences.PREFERENCES_NODE);
100
			int mincof = TXMPreferences.getInt(CooccurrencePreferences.MIN_COUNT, CooccurrencePreferences.PREFERENCES_NODE);
101
			int minscore = (int) TXMPreferences.getDouble(CooccurrencePreferences.MIN_SCORE, CooccurrencePreferences.PREFERENCES_NODE);
102
			boolean buildLexicalTableWithCooccurrents = TXMPreferences.getBoolean(CooccurrencePreferences.PARTIAL_LEXICAL_TABLE, CooccurrencePreferences.PREFERENCES_NODE);
103
			
104
			StructuralUnit limit = null;
105
			Query query = null;
106
			List<Property> properties = null;
107

  
108
			Concordance conc = (Concordance) selection;
109
			Corpus corpus = conc.getCorpus();
110
			maxleft = conc.getLeftContextSize();
111
			maxright = conc.getRightContextSize();
112
			properties = new ArrayList<Property>();
113
			properties.addAll(conc.getAnalysisProperty());
114
			query = conc.getQuery();
115

  
116
			Cooccurrence cooc;
117
			try {
118
				cooc = new Cooccurrence(corpus, query, properties, limit,
119
						maxleft, minleft, minright, maxright, minf, mincof,
120
						minscore, false, buildLexicalTableWithCooccurrents);
121

  
122
				cooc.process();
99 123
			}
124
			catch (Exception e) {
125
				// TODO Auto-generated catch block
126
				org.txm.rcp.utils.Logger.printStackTrace(e);
127
				return null;
128
			}
129

  
130
			editorInput = new TXMResultEditorInput(cooc);
131
			
100 132
		}
101 133
		// new editor from corpus
102 134
		else if (selection instanceof Corpus) {
103 135

  
104 136
			//FIXME: params tests
105
			HashMap<String, Object> params = new HashMap<String, Object>();
106
			params.put("query", "[word=\"faire\"]");
107
			editorInput = new TXMResultEditorInput((ITXMResult) selection, params);
137
//			TXMCommandParameters params = new TXMCommandParameters();
138
//			//params.put("query", "[word=\"faire\"]");
139
//			params.put(CooccurrencePreferences.QUERY, "[word=\"faire\"]");
140
//			params.put(CooccurrencePreferences.MAX_RIGHT, 200);
141
//			editorInput = new TXMResultEditorInput(new Cooccurrence((Corpus)selection, params));
108 142
			
109
			//editorInput = new TXMResultEditorInput((Corpus) selection);
143
			editorInput = new TXMResultEditorInput(new Cooccurrence((Corpus)selection));
110 144
			
111 145
		}
112 146
		// reopening an existing result
......
121 155
		try {
122 156
			StatusLine.setMessage(Messages.ComputeCooccurrences_0);
123 157

  
124
			
125
//			 return page.openEditor(editorInput, CooccurrencesEditor.ID);
126 158
			TXMEditorPart editor = TXMEditorPart.openEditor(editorInput, CooccurrencesEditor.ID);
127
			editor.computeResult(false);
159
			
160
			// new result
161
			if(!(selection instanceof Cooccurrence))	{
162
				editor.computeResult(false);
163
			}
164
			
128 165
			return editor;
129 166
		}
130 167
		catch (Exception e) {
......
136 173
	}
137 174

  
138 175

  
139
	/**
140
	 * Compute cooc.
141
	 *
142
	 * @param selection the selection
143
	 * @return the cooccurrence
144
	 */
145
	public static Cooccurrence computeCooc(Object selection) {
146
		if (!CQPEngine.isInitialized()) return null;
147
		
148
		Cooccurrence cooc = null;
149 176

  
150
		int minleft = 1;
151
		int maxleft = 50;
152
		int minright = 1;
153
		int maxright = 50;
154

  
155
		int minf = TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_FREQ);
156
		int mincof = TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_COUNT);
157
		int minscore = (int) TXMPreferences.getDouble(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_SCORE);
158

  
159
		Corpus corpus = null;
160
		StructuralUnit limit = null;
161
		Query query = null;
162
		List<Property> properties = null;
163

  
164
		if (selection instanceof Concordance) {
165
			Concordance conc = (Concordance) selection;
166
			corpus = conc.getCorpus();
167
			maxleft = conc.getLeftContextSize();
168
			maxright = conc.getRightContextSize();
169
			properties = new ArrayList<Property>();
170
			properties.addAll(conc.getAnalysisProperty());
171
			query = conc.getQuery();
172
			
173
			boolean buildLexicalTableWithCooccurrents = TXMPreferences.getBoolean(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.PARTIAL_LEXICAL_TABLE);
174

  
175
			try {
176
				cooc = new Cooccurrence(corpus, query, properties, limit,
177
						maxleft, minleft, minright, maxright, minf, mincof,
178
						minscore, false, buildLexicalTableWithCooccurrents);
179

  
180
				cooc.process();
181
			} catch (Exception e) {
182
				// TODO Auto-generated catch block
183
				org.txm.rcp.utils.Logger.printStackTrace(e);
184
				return null;
185
			}
186
		} else if (selection instanceof Corpus) {
187
			corpus = (Corpus) selection;
188
		} else {
189
			System.out.println(Messages.ComputeCooccurrences_1 + selection);
190
			return null;
191
		}
192

  
193
		return cooc;
194
	}
195 177
}
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/messages/messages.properties (revision 423)
1 1

  
2
CoocPreferencePage_0 = Score format (default 0.0000E00)
3

  
4
CoocPreferencePage_1 = Minimum frequency threshold of the cooccurent
5

  
2
CoocPreferencePage_0  = Score format (default 0.0000E00)
3
CoocPreferencePage_1  = Minimum frequency threshold of the cooccurent
6 4
CoocPreferencePage_11 = Minimum right
7

  
8 5
CoocPreferencePage_12 = Maximum right
6
CoocPreferencePage_2  = Minimum cooccurency count threshold
7
CoocPreferencePage_3  = Minimum cooccurency score threshold
8
CoocPreferencePage_4  = Maximum left
9
CoocPreferencePage_5  = Cooccurrences
10
CoocPreferencePage_6  = Minimum left
11
CoocPreferencePage_8  = Use partial lexical table
9 12

  
10
CoocPreferencePage_2 = Minimum cooccurency count threshold
11

  
12
CoocPreferencePage_3 = Minimum cooccurency score threshold
13

  
14
CoocPreferencePage_4 = Maximum left
15

  
16
CoocPreferencePage_5 = Cooccurrences
17

  
18
CoocPreferencePage_6 = Minimum left
19

  
20
CoocPreferencePage_8 = Use partial lexical table
21

  
22
CooccurrencesEditor_0 = Sort by: {0}
23

  
24
CooccurrencesEditor_1 = Error while computing the coocurrence:
25

  
13
CooccurrencesEditor_0  = Sort by: {0}
14
CooccurrencesEditor_1  = Error while computing the coocurrence:
26 15
CooccurrencesEditor_10 = Cofrequency
27

  
28 16
CooccurrencesEditor_11 = Score value is not a double float
29

  
30 17
CooccurrencesEditor_12 = Computing the cooccurrents of {0}
31

  
32 18
CooccurrencesEditor_13 = Setting up cooccurrences process
33

  
34 19
CooccurrencesEditor_14 = Computing cooccurrents
35

  
36 20
CooccurrencesEditor_15 = Displaying results
37

  
38 21
CooccurrencesEditor_16 = Can't compute cooccurrences with no context
39

  
40 22
CooccurrencesEditor_17 = Score
41

  
42 23
CooccurrencesEditor_18 = The score threshold must be a real number ! {0}
43

  
44
CooccurrencesEditor_2 = Search
45

  
24
CooccurrencesEditor_2  = Search
46 25
CooccurrencesEditor_20 = Computing the cooccurrents of <{0}> in the {1} corpus
47

  
48 26
CooccurrencesEditor_23 = Done: no result.
49

  
50 27
CooccurrencesEditor_24 = Done: one result.
51

  
52 28
CooccurrencesEditor_25 = Error while reading corpus size
53

  
54
CooccurrencesEditor_27 = build queries
55

  
56
CooccurrencesEditor_28 = get matches
57

  
58
CooccurrencesEditor_29 = build line signatures
59

  
60
CooccurrencesEditor_3 = Cooccurrents properties:
61

  
62
CooccurrencesEditor_30 = counting
63

  
64
CooccurrencesEditor_31 = build lexical table
65

  
66
CooccurrencesEditor_32 = get specif scores
67

  
29
CooccurrencesEditor_3  = Cooccurrents properties:
68 30
CooccurrencesEditor_33 = Start computing cooccurrences
69

  
70 31
CooccurrencesEditor_34 = Done: {0} keywords and {1} cooccurrents
71

  
72
CooccurrencesEditor_4 = Thresholds: Fmin ≥
73

  
74
CooccurrencesEditor_5 = \ Cmin ≥
75

  
76
CooccurrencesEditor_6 = \ Score ≥
77

  
78
CooccurrencesEditor_8 = Cooccurrent
79

  
80
CooccurrencesEditor_9 = Mean distance
32
CooccurrencesEditor_4  = Thresholds: Fmin ≥
33
CooccurrencesEditor_5  = \ Cmin ≥
34
CooccurrencesEditor_6  = \ Score ≥
35
CooccurrencesEditor_8  = Cooccurrent
36
CooccurrencesEditor_9  = Mean distance
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/messages/messages_ru.properties (revision 423)
1 1

  
2
CoocPreferencePage_0 = Формат индекса (по умолчанию 0.0000E00)
3

  
4
CoocPreferencePage_1 = Минимальный порог количества совместных употреблений
5

  
2
CoocPreferencePage_0  = Формат индекса (по умолчанию 0.0000E00)
3
CoocPreferencePage_1  = Минимальный порог количества совместных употреблений
6 4
CoocPreferencePage_11 = Минимум справа
7

  
8 5
CoocPreferencePage_12 = Максимум справа
6
CoocPreferencePage_2  = Минимальный порог частотности совместной встречаемости
7
CoocPreferencePage_3  = Минимальный порог индекса совместной встречаемости
8
CoocPreferencePage_4  = Максимум слева
9
CoocPreferencePage_5  = Совместная встречаемость
10
CoocPreferencePage_6  = Минимум слева
11
CoocPreferencePage_8  = N/A_Use partial lexical table
9 12

  
10
CoocPreferencePage_2 = Минимальный порог частотности совместной встречаемости
11

  
12
CoocPreferencePage_3 = Минимальный порог индекса совместной встречаемости
13

  
14
CoocPreferencePage_4 = Максимум слева
15

  
16
CoocPreferencePage_5 = Совместная встречаемость
17

  
18
CoocPreferencePage_6 = Минимум слева
19

  
20
CoocPreferencePage_8 = N/A_Use partial lexical table
21

  
22
CooccurrencesEditor_0 = Сортировать по: {0}
23

  
13
CooccurrencesEditor_0  = Сортировать по: {0}
24 14
CooccurrencesEditor_10 = Совместная частотность
25

  
26 15
CooccurrencesEditor_11 = Значение индекса не соответствует формату двойной плавающей точки
27

  
28 16
CooccurrencesEditor_12 = Расчет совместной встречаемости {0}
29

  
30 17
CooccurrencesEditor_13 = Отладка расчета совместной встречаемости
31

  
32 18
CooccurrencesEditor_14 = Расчет совместной встречаемости
33

  
34 19
CooccurrencesEditor_15 = Отображение результатов
35

  
36 20
CooccurrencesEditor_16 = ** Невозможно вычислить совместную встречаемость без контекстов
37

  
38 21
CooccurrencesEditor_17 = Индекс
39

  
40 22
CooccurrencesEditor_18 = Порог индекса должен быть действительным числом, отличным от {0}
41

  
42
CooccurrencesEditor_2 = Рассчитать
43

  
23
CooccurrencesEditor_2  = Рассчитать
44 24
CooccurrencesEditor_20 = Расчет совместной встречаемости  <{0}> в корпусе {1}
45

  
46 25
CooccurrencesEditor_23 = Готово: ни одного результата.
47

  
48 26
CooccurrencesEditor_24 = Готово: один результат.
49

  
50
CooccurrencesEditor_27 = Расчет запроса
51

  
52
CooccurrencesEditor_28 = Расчет ответов
53

  
54
CooccurrencesEditor_29 = Расчет подписей к строкам
55

  
56
CooccurrencesEditor_3 = Свойства совместных употреблений: 
57

  
58
CooccurrencesEditor_30 = Подсчет
59

  
60
CooccurrencesEditor_31 = Расчет словарной таблицы
61

  
62
CooccurrencesEditor_32 = Расчет показателей специфичности\	
63

  
27
CooccurrencesEditor_3  = Свойства совместных употреблений: 
64 28
CooccurrencesEditor_33 = Начало расчета совместной встречаемости
65

  
66 29
CooccurrencesEditor_34 = Готово: {1} совместных употреблений на {0} употреблений мотива
67

  
68
CooccurrencesEditor_4 = Пороги: Част ≥
69

  
70
CooccurrencesEditor_5 = Совм-част ≥ 
71

  
72
CooccurrencesEditor_6 = Показатель ≥ 
73

  
74
CooccurrencesEditor_8 = Кооккуррент
75

  
76
CooccurrencesEditor_9 = Средняя дистанция
30
CooccurrencesEditor_4  = Пороги: Част ≥
31
CooccurrencesEditor_5  = Совм-част ≥ 
32
CooccurrencesEditor_6  = Показатель ≥ 
33
CooccurrencesEditor_8  = Кооккуррент
34
CooccurrencesEditor_9  = Средняя дистанция
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/messages/messages_fr.properties (revision 423)
1 1

  
2
CoocPreferencePage_0 = Format de l'indice (par défault 0.0000E00)
3

  
4
CoocPreferencePage_1 = Seuil minimum de fréquence du cooccurrent
5

  
2
CoocPreferencePage_0  = Format de l'indice (par défault 0.0000E00)
3
CoocPreferencePage_1  = Seuil minimum de fréquence du cooccurrent
6 4
CoocPreferencePage_11 = Minimum à droite
7

  
8 5
CoocPreferencePage_12 = Maximum à droite
6
CoocPreferencePage_2  = Seuil minimum de fréquence de cooccurrences
7
CoocPreferencePage_3  = Seuil minimum de l'indice de cooccurrences
8
CoocPreferencePage_4  = Maximum à gauche
9
CoocPreferencePage_5  = Cooccurrences
10
CoocPreferencePage_6  = Minimum à gauche
11
CoocPreferencePage_8  = Utiliser les seulements les fréquences des cooccurents plutôt que celles de tous les mots du corpus
9 12

  
10
CoocPreferencePage_2 = Seuil minimum de fréquence de cooccurrences
11

  
12
CoocPreferencePage_3 = Seuil minimum de l'indice de cooccurrences
13

  
14
CoocPreferencePage_4 = Maximum à gauche
15

  
16
CoocPreferencePage_5 = Cooccurrences
17

  
18
CoocPreferencePage_6 = Minimum à gauche
19

  
20
CoocPreferencePage_8 = Utiliser les seulements les fréquences des cooccurents plutôt que celles de tous les mots du corpus
21

  
22
CooccurrencesEditor_0 = Trier par : {0}
23

  
24
CooccurrencesEditor_1 = ** Une erreur est survenue lors du calcul de la coocurrence:
25

  
13
CooccurrencesEditor_0  = Trier par : {0}
14
CooccurrencesEditor_1  = ** Une erreur est survenue lors du calcul de la coocurrence:
26 15
CooccurrencesEditor_10 = Cofréquence
27

  
28 16
CooccurrencesEditor_11 = La valeur de l'indice n'est pas un flottant double
29

  
30 17
CooccurrencesEditor_12 = Calcul des cooccurrents de {0}
31

  
32 18
CooccurrencesEditor_13 = Réglage du calcul des cooccurrents
33

  
34 19
CooccurrencesEditor_14 = Calcul des cooccurrents
35

  
36 20
CooccurrencesEditor_15 = Affichage des résultats
37

  
38 21
CooccurrencesEditor_16 = ** Impossible de calculer les cooccurrences sans contexte
39

  
40 22
CooccurrencesEditor_17 = Indice
41

  
42 23
CooccurrencesEditor_18 = Le seuil d''indice doit être un nombre réel différent de {0}
43

  
44
CooccurrencesEditor_2 = Calculer
45

  
24
CooccurrencesEditor_2  = Calculer
46 25
CooccurrencesEditor_20 = Calcul des cooccurrents de <{0}> dans le corpus {1}
47

  
48 26
CooccurrencesEditor_23 = Terminé : aucun résultat.
49

  
50 27
CooccurrencesEditor_24 = Terminé : un résultat.
51

  
52 28
CooccurrencesEditor_25 = ** Une erreur est survenue lors du calcul de la taille du corpus
53

  
54
CooccurrencesEditor_27 = Calcul des requêtes
55

  
56
CooccurrencesEditor_28 = Calcul des retours
57

  
58
CooccurrencesEditor_29 = Calcul des signatures de lignes
59

  
60
CooccurrencesEditor_3 = Propriétés des cooccurrents : 
61

  
62
CooccurrencesEditor_30 = Comptage
63

  
64
CooccurrencesEditor_31 = Calcul de la table lexicale
65

  
66
CooccurrencesEditor_32 = Calcul des indices de spécificité\	
67

  
29
CooccurrencesEditor_3  = Propriétés des cooccurrents : 
68 30
CooccurrencesEditor_33 = Début du calcul des cooccurrences
69

  
70 31
CooccurrencesEditor_34 = Terminé : {0} occurrences de pivot et {1} cooccurrents 
71

  
72
CooccurrencesEditor_4 = Seuils : Fmin ≥
73

  
74
CooccurrencesEditor_5 = Cmin ≥ 
75

  
76
CooccurrencesEditor_6 = Indice ≥ 
77

  
78
CooccurrencesEditor_8 = Cooccurrent
79

  
80
CooccurrencesEditor_9 = Distance moyenne
32
CooccurrencesEditor_4  = Seuils : Fmin ≥
33
CooccurrencesEditor_5  = Cmin ≥ 
34
CooccurrencesEditor_6  = Indice ≥ 
35
CooccurrencesEditor_8  = Cooccurrent
36
CooccurrencesEditor_9  = Distance moyenne
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/messages/CooccurrenceUIMessages.java (revision 423)
35 35
	public static String CooccurrencesEditor_24;
36 36

  
37 37
	public static String CooccurrencesEditor_25;
38
	public static String CooccurrencesEditor_27;
39
	public static String CooccurrencesEditor_28;
40
	public static String CooccurrencesEditor_29;
41 38
	public static String CooccurrencesEditor_3;
42
	public static String CooccurrencesEditor_30;
43
	public static String CooccurrencesEditor_31;
44
	public static String CooccurrencesEditor_32;
45 39
	public static String CooccurrencesEditor_33;
46 40
	public static String CooccurrencesEditor_34;
47 41
	public static String CooccurrencesEditor_4;

Formats disponibles : Unified diff