Révision 2619
tmp/org.txm.index.core/src/org/txm/index/core/functions/___Lexicon2.java (revision 2619) | ||
---|---|---|
39 | 39 |
|
40 | 40 |
import org.eclipse.core.runtime.IProgressMonitor; |
41 | 41 |
import org.eclipse.osgi.util.NLS; |
42 |
import org.txm.core.messages.TXMCoreMessages; |
|
43 | 42 |
import org.txm.core.preferences.TXMPreferences; |
44 | 43 |
import org.txm.core.results.Parameter; |
45 | 44 |
import org.txm.core.results.TXMParameters; |
... | ... | |
50 | 49 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
51 | 50 |
import org.txm.searchengine.cqp.corpus.CorpusManager; |
52 | 51 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
53 |
import org.txm.searchengine.cqp.corpus.Part; |
|
54 | 52 |
import org.txm.searchengine.cqp.corpus.Property; |
55 | 53 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
56 | 54 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
57 | 55 |
import org.txm.statsengine.core.StatException; |
58 | 56 |
import org.txm.statsengine.core.data.Vector; |
59 | 57 |
import org.txm.statsengine.r.core.data.VectorImpl; |
58 |
import org.txm.utils.TXMProgressMonitor; |
|
60 | 59 |
import org.txm.utils.logger.Log; |
61 | 60 |
|
62 | 61 |
// TODO should be put into stat.data package ? |
... | ... | |
171 | 170 |
} |
172 | 171 |
|
173 | 172 |
@Override |
174 |
protected boolean _computeLines() throws Exception { |
|
173 |
protected boolean _computeLines(TXMProgressMonitor monitor) throws Exception {
|
|
175 | 174 |
if (this.getParent() instanceof MainCorpus) { |
176 |
return computeWithMainCorpus((MainCorpus) this.getParent(), pProperty, this.splitMonitor(70));
|
|
175 |
return computeWithMainCorpus((MainCorpus) this.getParent(), pProperty, monitor);
|
|
177 | 176 |
} |
178 | 177 |
else if (this.getParent() instanceof Subcorpus) { |
179 |
return computewithSubCorpus((Subcorpus) this.getParent(), pProperty, this.splitMonitor(70));
|
|
178 |
return computewithSubCorpus((Subcorpus) this.getParent(), pProperty, monitor);
|
|
180 | 179 |
} |
181 | 180 |
else { |
182 | 181 |
Log.severe("Error: Lexicon parent is neither a Maincorpus nor a Subcorpus."); //$NON-NLS-1$ |
... | ... | |
195 | 194 |
* @throws CqiClientException |
196 | 195 |
* the cqi client exception |
197 | 196 |
*/ |
198 |
protected boolean computeWithMainCorpus(MainCorpus corpus, Property property, IProgressMonitor monitor) throws CqiClientException {
|
|
197 |
protected boolean computeWithMainCorpus(MainCorpus corpus, Property property, TXMProgressMonitor monitor) throws CqiClientException {
|
|
199 | 198 |
// System.out.println("in "+this.getCqpId()+" look for cached lexicon "+property); |
200 | 199 |
// System.out.println("not found"); |
201 |
this.monitorSetTask("Computing lexicon size...");
|
|
200 |
monitor.monitorSetTask("Computing lexicon size...");
|
|
202 | 201 |
Log.finest(IndexCoreMessages.lexicon + corpus.getID()); |
203 | 202 |
int lexiconSize; |
204 | 203 |
try { |
... | ... | |
215 | 214 |
|
216 | 215 |
int[] freqs; |
217 | 216 |
try { |
218 |
this.monitorSetTask("Computing lexicon frequencies...");
|
|
217 |
monitor.monitorSetTask("Computing lexicon frequencies...");
|
|
219 | 218 |
freqs = CorpusManager.getCorpusManager().getCqiClient().id2Freq(property.getQualifiedName(), ids); |
220 | 219 |
} |
221 | 220 |
catch (Exception e) { |
... | ... | |
236 | 235 |
*/ |
237 | 236 |
// FIXME: why this method needs to create and delete some new subcorpus???? the computing can't be done directly on the corpus argument??? |
238 | 237 |
// eg. dist = CorpusManager.getCorpusManager().getCqiClient().fdist1(corpus.getQualifiedCqpId(), 0, ICqiClient.CQI_CONST_FIELD_MATCH, property.getName()); |
239 |
protected boolean computewithSubCorpus(Subcorpus corpus, Property property, IProgressMonitor monitor) throws CqiClientException {
|
|
238 |
protected boolean computewithSubCorpus(Subcorpus corpus, Property property, TXMProgressMonitor monitor) throws CqiClientException {
|
|
240 | 239 |
|
241 | 240 |
// if (corpus instanceof Part) { |
242 | 241 |
// this.persistable = false; |
... | ... | |
248 | 247 |
int[][] fdist = null; |
249 | 248 |
Subcorpus tmp = null; |
250 | 249 |
try { |
251 |
this.monitorSetTask("Computing lexicon frequencies...");
|
|
250 |
monitor.monitorSetTask("Computing lexicon frequencies...");
|
|
252 | 251 |
tmp = corpus.createSubcorpus(new CQLQuery("[]"), "S" + corpus.getNextSubcorpusCounter(), true); //$NON-NLS-1$ |
253 | 252 |
if (tmp != null) { |
254 | 253 |
fdist = CorpusManager.getCorpusManager().getCqiClient().fdist1(tmp.getQualifiedCqpId(), 0, ICqiClient.CQI_CONST_FIELD_MATCH, property.getName()); |
tmp/org.txm.index.core/src/org/txm/index/core/functions/Lexicon.java (revision 2619) | ||
---|---|---|
39 | 39 |
import org.txm.searchengine.cqp.corpus.Property; |
40 | 40 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
41 | 41 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
42 |
import org.txm.utils.TXMProgressMonitor; |
|
42 | 43 |
import org.txm.utils.logger.Log; |
43 | 44 |
|
44 | 45 |
/** |
... | ... | |
76 | 77 |
|
77 | 78 |
|
78 | 79 |
@Override |
79 |
protected boolean _computeLines() { |
|
80 |
protected boolean _computeLines(TXMProgressMonitor monitor) {
|
|
80 | 81 |
try { |
81 | 82 |
|
82 | 83 |
// this.query = new Query("[]"); //$NON-NLS-1$ |
... | ... | |
84 | 85 |
// this.props.add(property); |
85 | 86 |
Property property = this.pProperties.get(0); |
86 | 87 |
|
87 |
CQPLexicon lexicon = CQPLexicon.getLexicon(this.getCorpus(), property, this.splitMonitor(20));
|
|
88 |
CQPLexicon lexicon = CQPLexicon.getLexicon(this.getCorpus(), property, monitor.createNewMonitor(20));
|
|
88 | 89 |
lexicon.setProperty(property); |
89 | 90 |
lexicon._compute(); |
90 | 91 |
|
tmp/org.txm.index.core/src/org/txm/index/core/functions/PartitionIndex.java (revision 2619) | ||
---|---|---|
50 | 50 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
51 | 51 |
import org.txm.statsengine.r.core.RWorkspace; |
52 | 52 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
53 |
import org.txm.utils.TXMProgressMonitor; |
|
53 | 54 |
import org.txm.utils.logger.Log; |
54 | 55 |
|
55 | 56 |
/** |
... | ... | |
96 | 97 |
} |
97 | 98 |
|
98 | 99 |
@Override |
99 |
protected boolean _compute() throws Exception { |
|
100 |
protected boolean _compute(TXMProgressMonitor monitor) throws Exception {
|
|
100 | 101 |
lines.clear(); |
101 | 102 |
counts.clear(); |
102 | 103 |
currentpartid = 0; |
... | ... | |
108 | 109 |
currentpartid++; |
109 | 110 |
} |
110 | 111 |
|
111 |
this.monitorSetWorked(30);
|
|
112 |
monitor.monitorSetWorked(30);
|
|
112 | 113 |
|
113 | 114 |
setLineCounts(); |
114 | 115 |
|
... | ... | |
117 | 118 |
this.filterLines(); |
118 | 119 |
|
119 | 120 |
|
120 |
this.monitorSetWorked(30);
|
|
121 |
monitor.monitorSetWorked(30);
|
|
121 | 122 |
|
122 |
this.monitorSetTask("Sorting...");
|
|
123 |
monitor.monitorSetTask("Sorting...");
|
|
123 | 124 |
|
124 | 125 |
this.sortLines(SortMode.FREQUNIT, true); |
125 | 126 |
|
126 | 127 |
this.cut(); |
127 | 128 |
|
128 |
this.monitorSetWorked(30);
|
|
129 |
monitor.monitorSetWorked(30);
|
|
129 | 130 |
|
130 | 131 |
this.dirty = false; |
131 | 132 |
this.pTopIndex = 0; |
132 | 133 |
|
133 |
this.monitorSetTask("Index done.");
|
|
134 |
monitor.monitorSetTask("Index done.");
|
|
134 | 135 |
|
135 | 136 |
return true; |
136 | 137 |
} |
tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 2619) | ||
---|---|---|
63 | 63 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
64 | 64 |
import org.txm.statsengine.r.core.RWorkspace; |
65 | 65 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
66 |
import org.txm.utils.TXMProgressMonitor; |
|
66 | 67 |
import org.txm.utils.logger.Log; |
67 | 68 |
|
68 | 69 |
/** |
... | ... | |
169 | 170 |
|
170 | 171 |
|
171 | 172 |
@Override |
172 |
protected boolean _compute() throws Exception { |
|
173 |
protected boolean _compute(TXMProgressMonitor monitor) throws Exception {
|
|
173 | 174 |
|
174 | 175 |
// reset all stored data |
175 | 176 |
if (lines != null) { |
... | ... | |
183 | 184 |
// It works but the problem is the cut() method that really cut the lines rather than doing getLines() that could filtering and returns only the lines between fmin/fmax |
184 | 185 |
// if(this.hasParameterChanged(TXMPreferences.QUERY) || this.hasParameterChanged(TXMPreferences.UNIT_PROPERTIES)) { |
185 | 186 |
|
186 |
if (!_computeLines()) { |
|
187 |
if (!_computeLines(monitor)) {
|
|
187 | 188 |
Log.severe("Error while computing lines. Aborting."); |
188 | 189 |
return false; |
189 | 190 |
} |
190 | 191 |
// } |
191 | 192 |
this.filterLines(); |
192 |
this.monitorSetWorked(30);
|
|
193 |
monitor.monitorSetWorked(30);
|
|
193 | 194 |
|
194 |
this.monitorSetTask("Sorting...");
|
|
195 |
monitor.monitorSetTask("Sorting...");
|
|
195 | 196 |
this.sortLines(SortMode.FREQUNIT, true); |
196 |
this.monitorSetWorked(30);
|
|
197 |
monitor.monitorSetWorked(30);
|
|
197 | 198 |
|
198 | 199 |
this.cut(); |
199 | 200 |
|
200 | 201 |
this.dirty = false; |
201 | 202 |
this.pTopIndex = 0; |
202 | 203 |
|
203 |
this.monitorSetTask("Index done.");
|
|
204 |
monitor.monitorSetTask("Index done.");
|
|
204 | 205 |
|
205 | 206 |
return true; |
206 | 207 |
} |
... | ... | |
212 | 213 |
* @return true if the index lines hae been computed |
213 | 214 |
* @throws Exception |
214 | 215 |
*/ |
215 |
protected boolean _computeLines() throws Exception { |
|
216 |
protected boolean _computeLines(TXMProgressMonitor monitor) throws Exception {
|
|
216 | 217 |
if (parent instanceof CQPCorpus) { |
217 | 218 |
|
218 | 219 |
if (!scanCorpus((CQPCorpus) parent)) { |
tmp/org.txm.referencer.core/src/org/txm/referencer/core/functions/Referencer.java (revision 2619) | ||
---|---|---|
74 | 74 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
75 | 75 |
import org.txm.statsengine.r.core.RWorkspace; |
76 | 76 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
77 |
import org.txm.utils.TXMProgressMonitor; |
|
77 | 78 |
import org.txm.utils.logger.Log; |
78 | 79 |
|
79 | 80 |
/** |
... | ... | |
82 | 83 |
* @author mdecorde |
83 | 84 |
* @author sjacquot |
84 | 85 |
*/ |
85 |
public class Referencer extends TXMResult {
|
|
86 |
|
|
86 |
public class Referencer extends TXMResult { |
|
87 |
|
|
87 | 88 |
/** The noref. */ |
88 | 89 |
protected static int noref = 1; |
89 |
|
|
90 |
|
|
90 | 91 |
/** The prefix r. */ |
91 | 92 |
protected static String prefixR = "Referencer"; //$NON-NLS-1$ |
92 |
|
|
93 |
|
|
93 | 94 |
/** The indexes. */ |
94 | 95 |
int[] indexes; |
95 |
|
|
96 |
|
|
96 | 97 |
/** The lines. */ |
97 | 98 |
List<Line> lines; |
98 |
|
|
99 |
|
|
99 | 100 |
/** The matches. */ |
100 | 101 |
List<Match> matches; |
101 |
|
|
102 |
|
|
102 | 103 |
/** The positions. */ |
103 | 104 |
int[] positions; |
104 |
|
|
105 |
|
|
105 | 106 |
/** The nlines. */ |
106 | 107 |
int nlines; |
107 |
|
|
108 |
|
|
108 | 109 |
/** The processed idx. */ |
109 | 110 |
HashMap<Integer, Line> processedIdx; |
110 |
|
|
111 |
|
|
111 | 112 |
/** The result. */ |
112 | 113 |
QueryResult result; |
113 |
|
|
114 |
|
|
114 | 115 |
/** The symbol. */ |
115 | 116 |
private String symbol; |
116 |
|
|
117 |
|
|
117 | 118 |
/** The writer. */ |
118 | 119 |
private BufferedWriter writer; |
119 |
|
|
120 | 120 |
|
121 | 121 |
|
122 | 122 |
|
123 | 123 |
|
124 |
|
|
124 | 125 |
/** The hierarchic sort. */ |
125 |
@Parameter(key=ReferencerPreferences.SORT_BY_FREQUENCIES)
|
|
126 |
@Parameter(key = ReferencerPreferences.SORT_BY_FREQUENCIES)
|
|
126 | 127 |
protected boolean pHierarchicSort; |
127 | 128 |
|
128 |
@Parameter(key=ReferencerPreferences.PATTERN)
|
|
129 |
@Parameter(key = ReferencerPreferences.PATTERN)
|
|
129 | 130 |
protected List<StructuralUnitProperty> pPattern; |
130 | 131 |
|
131 | 132 |
/** The prop. */ |
132 |
@Parameter(key=ReferencerPreferences.UNIT_PROPERTY)
|
|
133 |
@Parameter(key = ReferencerPreferences.UNIT_PROPERTY)
|
|
133 | 134 |
protected Property pProperty; |
134 |
|
|
135 |
|
|
135 | 136 |
/** The query. */ |
136 |
@Parameter(key=ReferencerPreferences.QUERY)
|
|
137 |
@Parameter(key = ReferencerPreferences.QUERY)
|
|
137 | 138 |
protected CQLQuery pQuery; |
138 |
|
|
139 | 139 |
|
140 | 140 |
|
141 | 141 |
|
142 | 142 |
|
143 |
|
|
143 | 144 |
/** |
144 | 145 |
* Creates a not computed referencer. |
145 | 146 |
* |
... | ... | |
148 | 149 |
public Referencer(CQPCorpus parent) { |
149 | 150 |
super(parent); |
150 | 151 |
} |
151 |
|
|
152 | 152 |
|
153 |
|
|
153 | 154 |
/** |
154 | 155 |
* Creates a not computed referencer. |
156 |
* |
|
155 | 157 |
* @param parametersNodePath |
156 | 158 |
*/ |
157 | 159 |
public Referencer(String parametersNodePath) { |
158 | 160 |
super(parametersNodePath); |
159 | 161 |
} |
160 |
|
|
161 | 162 |
|
163 |
|
|
162 | 164 |
/** |
163 | 165 |
* As r matrix. |
164 | 166 |
* |
... | ... | |
166 | 168 |
* @throws RWorkspaceException the r workspace exception |
167 | 169 |
*/ |
168 | 170 |
public String asRMatrix() throws RWorkspaceException { |
169 |
|
|
171 |
|
|
170 | 172 |
String keywords[] = new String[lines.size()]; |
171 |
for(int i = 0 ; i < lines.size() ; i++)
|
|
173 |
for (int i = 0; i < lines.size(); i++)
|
|
172 | 174 |
keywords[i] = lines.get(i).getPropValue(); |
173 |
//System.out.println(Arrays.toString(keywords)); |
|
174 |
|
|
175 |
String symbol = prefixR+noref;
|
|
176 |
|
|
175 |
// System.out.println(Arrays.toString(keywords));
|
|
176 |
|
|
177 |
String symbol = prefixR + noref;
|
|
178 |
|
|
177 | 179 |
RWorkspace rw = RWorkspace.getRWorkspaceInstance(); |
178 |
rw.eval(symbol+" <- list()"); //$NON-NLS-1$
|
|
180 |
rw.eval(symbol + " <- list()"); //$NON-NLS-1$
|
|
179 | 181 |
rw.addVectorToWorkspace("refkeywords", keywords); //$NON-NLS-1$ |
180 |
rw.eval(symbol+"$keywords <- refkeywords"); //$NON-NLS-1$
|
|
181 |
//rw.eval(symbol+"$query <- \""+this.query.getQueryString()+"\")"); |
|
182 |
rw.eval(symbol+"$refs <- list()"); //$NON-NLS-1$
|
|
182 |
rw.eval(symbol + "$keywords <- refkeywords"); //$NON-NLS-1$
|
|
183 |
// rw.eval(symbol+"$query <- \""+this.query.getQueryString()+"\")");
|
|
184 |
rw.eval(symbol + "$refs <- list()"); //$NON-NLS-1$
|
|
183 | 185 |
int i = 1; |
184 | 186 |
for (Line line : this.lines) { |
185 | 187 |
String refs[] = line.getReferences().toArray(new String[line.getReferences().size()]); |
186 |
//System.out.println(line.getPropValue()+": "+Arrays.toString(refs)); |
|
188 |
// System.out.println(line.getPropValue()+": "+Arrays.toString(refs));
|
|
187 | 189 |
rw.addVectorToWorkspace("reflinerefs", refs); //$NON-NLS-1$ |
188 |
rw.eval(symbol+"$refs[["+i+"]] <- reflinerefs"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
190 |
rw.eval(symbol + "$refs[[" + i + "]] <- reflinerefs"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
189 | 191 |
i++; |
190 | 192 |
} |
191 |
|
|
193 |
|
|
192 | 194 |
noref++; |
193 | 195 |
this.symbol = symbol; |
194 | 196 |
return symbol; |
195 | 197 |
} |
196 |
|
|
198 |
|
|
197 | 199 |
@Override |
198 | 200 |
public void clean() { |
199 | 201 |
try { |
200 | 202 |
if (this.writer != null) { |
201 | 203 |
this.writer.flush(); |
202 |
this.writer.close();
|
|
204 |
this.writer.close(); |
|
203 | 205 |
} |
204 |
} catch (IOException e) { |
|
206 |
} |
|
207 |
catch (IOException e) { |
|
205 | 208 |
// TODO Auto-generated catch block |
206 | 209 |
org.txm.utils.logger.Log.printStackTrace(e); |
207 | 210 |
} |
208 | 211 |
} |
209 |
|
|
212 |
|
|
210 | 213 |
/** |
211 | 214 |
* Clears all lines. |
212 | 215 |
*/ |
213 |
public void clearAllLines() {
|
|
214 |
for(Line line : lines) { // we need to recompute lines references |
|
216 |
public void clearAllLines() {
|
|
217 |
for (Line line : lines) { // we need to recompute lines references
|
|
215 | 218 |
line.clear(); |
216 | 219 |
} |
217 | 220 |
} |
218 |
|
|
221 |
|
|
219 | 222 |
/** |
220 | 223 |
* Calls in order all stages to compute the referencer. |
221 | 224 |
* |
222 | 225 |
* @return true, if successful |
223 | 226 |
*/ |
224 | 227 |
@Override |
225 |
protected boolean _compute() { |
|
228 |
protected boolean _compute(TXMProgressMonitor monitor) {
|
|
226 | 229 |
try { |
227 | 230 |
if (!getQueryMatches()) { |
228 | 231 |
return false; |
229 | 232 |
} |
230 |
|
|
233 |
|
|
231 | 234 |
if (!getQueryindexes()) { |
232 | 235 |
return false; |
233 | 236 |
} |
234 |
|
|
237 |
|
|
235 | 238 |
if (!groupPositionsbyId()) { |
236 | 239 |
return false; |
237 | 240 |
} |
238 | 241 |
} |
239 |
catch(CqiClientException e) { |
|
242 |
catch (CqiClientException e) {
|
|
240 | 243 |
e.printStackTrace(); |
241 | 244 |
return false; |
242 | 245 |
} |
243 |
|
|
246 |
|
|
244 | 247 |
return true; |
245 | 248 |
} |
246 |
|
|
249 |
|
|
247 | 250 |
/** |
248 | 251 |
* Gets the parent corpus. |
249 | 252 |
* |
... | ... | |
252 | 255 |
public CQPCorpus getCorpus() { |
253 | 256 |
return (CQPCorpus) this.parent; |
254 | 257 |
} |
255 |
|
|
258 |
|
|
256 | 259 |
@Override |
257 | 260 |
public String getDetails() { |
258 | 261 |
return getCorpus().getName(); |
259 | 262 |
} |
260 |
|
|
263 |
|
|
261 | 264 |
/** |
262 | 265 |
* Gets the lines. |
263 | 266 |
* |
... | ... | |
267 | 270 |
* @throws CqiServerError the cqi server error |
268 | 271 |
*/ |
269 | 272 |
public List<Line> getLines() throws CqiClientException, IOException, CqiServerError { |
270 |
return getLines(0,lines.size()); |
|
273 |
return getLines(0, lines.size());
|
|
271 | 274 |
} |
272 |
|
|
275 |
|
|
273 | 276 |
/** |
274 | 277 |
* Gets the lines. |
275 | 278 |
* |
... | ... | |
287 | 290 |
if (to > lines.size()) { |
288 | 291 |
to = lines.size(); |
289 | 292 |
} |
290 |
|
|
291 |
HashMap<Integer, Line> lineswithoutpropvalue = new HashMap<Integer, Line>();
|
|
292 |
|
|
293 |
|
|
294 |
HashMap<Integer, Line> lineswithoutpropvalue = new HashMap<>(); |
|
295 |
|
|
293 | 296 |
AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient(); |
294 |
//build Missing lines |
|
295 |
for(int i = from ; i < to ; i++) { // for each position group
|
|
297 |
// build Missing lines
|
|
298 |
for (int i = from; i < to; i++) { // for each position group
|
|
296 | 299 |
Line l = lines.get(i); |
297 | 300 |
if (l.notcomputed) { |
298 | 301 |
lineswithoutpropvalue.put(l.id, l); |
299 |
|
|
302 |
|
|
300 | 303 |
// get all reference values of all position of the line |
301 |
Map<Property, List<List<String>>> refValues = new HashMap<Property, List<List<String>>>();
|
|
304 |
Map<Property, List<List<String>>> refValues = new HashMap<>(); |
|
302 | 305 |
for (Property property : pPattern) { |
303 | 306 |
refValues.put(property, cqiClient.getData(property, |
304 | 307 |
l.positions, Collections.nCopies(l.positions.size(), 1))); |
305 | 308 |
} |
306 | 309 |
// build the Reference object |
307 |
for (int j = 0 ; j < l.positions.size() ; j++) {
|
|
310 |
for (int j = 0; j < l.positions.size(); j++) {
|
|
308 | 311 |
String propvalue = ""; //$NON-NLS-1$ |
309 | 312 |
for (Property property : pPattern) { |
310 | 313 |
propvalue += refValues.get(property).get(j).get(0) + ", "; //$NON-NLS-1$ |
311 | 314 |
} |
312 |
|
|
313 |
l.addReference(propvalue.substring(0, propvalue.length()-2));
|
|
315 |
|
|
316 |
l.addReference(propvalue.substring(0, propvalue.length() - 2));
|
|
314 | 317 |
} |
315 | 318 |
if (pHierarchicSort) { |
316 | 319 |
l.sortRef(true); |
... | ... | |
321 | 324 |
l.notcomputed = false; |
322 | 325 |
} |
323 | 326 |
} |
324 |
|
|
327 |
|
|
325 | 328 |
// get idx String value |
326 | 329 |
int[] idxwithoutvalues = new int[lineswithoutpropvalue.keySet().size()]; |
327 | 330 |
int count = 0; |
328 |
for(int i : lineswithoutpropvalue.keySet()) { |
|
331 |
for (int i : lineswithoutpropvalue.keySet()) {
|
|
329 | 332 |
idxwithoutvalues[count++] = i; |
330 | 333 |
} |
331 |
|
|
334 |
|
|
332 | 335 |
String[] values = CorpusManager.getCorpusManager().getCqiClient().id2Str(pProperty.getQualifiedName(), idxwithoutvalues); |
333 |
for(int i = 0 ; i < values.length ; i++) {
|
|
336 |
for (int i = 0; i < values.length; i++) {
|
|
334 | 337 |
int id = idxwithoutvalues[i]; |
335 | 338 |
lineswithoutpropvalue.get(id).linepropvalue = values[i]; |
336 | 339 |
} |
337 | 340 |
return lines.subList(from, to); |
338 | 341 |
} |
339 |
|
|
342 |
|
|
340 | 343 |
/** |
341 | 344 |
* Gets the name. |
342 | 345 |
* |
343 | 346 |
* @return the name |
344 | 347 |
*/ |
348 |
@Override |
|
345 | 349 |
public String getName() { |
346 | 350 |
try { |
347 | 351 |
return getCorpus().getName() + ": " + this.getSimpleName(); //$NON-NLS-1$ |
... | ... | |
350 | 354 |
return this.getEmptyName(); |
351 | 355 |
} |
352 | 356 |
} |
353 |
|
|
354 |
|
|
357 |
|
|
358 |
|
|
355 | 359 |
@Override |
356 | 360 |
public String getSimpleName() { |
357 | 361 |
try { |
... | ... | |
361 | 365 |
return this.getEmptyName(); |
362 | 366 |
} |
363 | 367 |
} |
364 |
|
|
365 | 368 |
|
369 |
|
|
366 | 370 |
@Override |
367 | 371 |
public String getComputingStartMessage() { |
368 | 372 |
return TXMCoreMessages.bind(ReferencerCoreMessages.referencesOfP0InTheP1Corpus, this.pQuery, this.getCorpus().getName()); |
369 | 373 |
} |
370 |
|
|
371 | 374 |
|
375 |
|
|
372 | 376 |
@Override |
373 | 377 |
public String getComputingDoneMessage() { |
374 |
if(this.lines == null || this.lines.isEmpty()) {
|
|
378 |
if (this.lines == null || this.lines.isEmpty()) {
|
|
375 | 379 |
return TXMCoreMessages.common_noResults; |
376 | 380 |
} |
377 |
else {
|
|
381 |
else {
|
|
378 | 382 |
return TXMCoreMessages.bind(TXMCoreMessages.common_P0ItemsForP1Occurrences, this.getNLines(), this.getV()); |
379 | 383 |
} |
380 | 384 |
} |
... | ... | |
388 | 392 |
public int getNLines() { |
389 | 393 |
return nlines; |
390 | 394 |
} |
391 |
|
|
395 |
|
|
392 | 396 |
/** |
393 | 397 |
* Gets the pattern. |
394 | 398 |
* |
... | ... | |
397 | 401 |
public List<StructuralUnitProperty> getPattern() { |
398 | 402 |
return pPattern; |
399 | 403 |
} |
400 |
|
|
404 |
|
|
401 | 405 |
/** |
402 | 406 |
* Gets the property. |
403 | 407 |
* |
... | ... | |
406 | 410 |
public Property getProperty() { |
407 | 411 |
return pProperty; |
408 | 412 |
} |
409 |
|
|
413 |
|
|
410 | 414 |
/** |
411 | 415 |
* Gets the query. |
412 | 416 |
* |
... | ... | |
415 | 419 |
public CQLQuery getQuery() { |
416 | 420 |
return pQuery; |
417 | 421 |
} |
418 |
|
|
422 |
|
|
419 | 423 |
/** |
420 | 424 |
* 2nd step. |
421 | 425 |
* |
422 | 426 |
* @return the queryindexes |
423 | 427 |
*/ |
424 |
public boolean getQueryindexes(){ |
|
428 |
public boolean getQueryindexes() {
|
|
425 | 429 |
try { |
426 | 430 |
positions = new int[matches.size()]; |
427 | 431 |
int i = 0; |
428 | 432 |
for (Match m : matches) { |
429 | 433 |
positions[i++] = m.getStart(); |
430 | 434 |
} |
431 |
|
|
432 |
indexes = CorpusManager.getCorpusManager().getCqiClient().cpos2Id(pProperty.getQualifiedName(),positions); |
|
433 |
} catch (Exception e) { |
|
435 |
|
|
436 |
indexes = CorpusManager.getCorpusManager().getCqiClient().cpos2Id(pProperty.getQualifiedName(), positions); |
|
437 |
} |
|
438 |
catch (Exception e) { |
|
434 | 439 |
// TODO Auto-generated catch block |
435 | 440 |
org.txm.utils.logger.Log.printStackTrace(e); |
436 | 441 |
return false; |
437 | 442 |
} |
438 | 443 |
return true; |
439 | 444 |
} |
440 |
|
|
445 |
|
|
441 | 446 |
/** |
442 | 447 |
* 1st step. |
443 | 448 |
* |
444 | 449 |
* @return the query matches |
445 |
* @throws CqiClientException
|
|
450 |
* @throws CqiClientException |
|
446 | 451 |
*/ |
447 |
public boolean getQueryMatches() throws CqiClientException{ |
|
452 |
public boolean getQueryMatches() throws CqiClientException {
|
|
448 | 453 |
result = this.getCorpus().query(pQuery, ReferencerCoreMessages.RESULT_TYPE, false); |
449 | 454 |
if (result.getNMatch() == 0) { |
450 | 455 |
return false; |
... | ... | |
453 | 458 |
result.drop(); |
454 | 459 |
return true; |
455 | 460 |
} |
456 |
|
|
461 |
|
|
457 | 462 |
/** |
458 | 463 |
* Gets the symbol. |
459 | 464 |
* |
... | ... | |
462 | 467 |
public String getSymbol() { |
463 | 468 |
return symbol; |
464 | 469 |
} |
465 |
|
|
470 |
|
|
466 | 471 |
public int getV() { |
467 | 472 |
if (matches == null) { |
468 | 473 |
return 0; |
469 | 474 |
} |
470 | 475 |
return matches.size(); |
471 | 476 |
} |
472 |
|
|
477 |
|
|
473 | 478 |
/** |
474 | 479 |
* 3rd stage. |
475 | 480 |
* |
476 | 481 |
* @return true, if successful |
477 | 482 |
*/ |
478 | 483 |
public boolean groupPositionsbyId() { |
479 |
processedIdx = new HashMap<Integer, Line>();
|
|
480 |
|
|
481 |
lines = new ArrayList<Line>();
|
|
482 |
//System.out.println("indexes "); |
|
483 |
for (int i = 0 ; i < indexes.length ; i++) {
|
|
484 |
processedIdx = new HashMap<>(); |
|
485 |
|
|
486 |
lines = new ArrayList<>(); |
|
487 |
// System.out.println("indexes ");
|
|
488 |
for (int i = 0; i < indexes.length; i++) {
|
|
484 | 489 |
int id = indexes[i]; |
485 |
//System.out.print(" "+id); |
|
486 |
if (!processedIdx.containsKey(id)) {
|
|
487 |
//System.out.println("add idx "+id); |
|
490 |
// System.out.print(" "+id);
|
|
491 |
if (!processedIdx.containsKey(id)) { |
|
492 |
// System.out.println("add idx "+id);
|
|
488 | 493 |
Line l = new Line(id); |
489 | 494 |
processedIdx.put(id, l); |
490 |
|
|
495 |
|
|
491 | 496 |
lines.add(l); |
492 | 497 |
} |
493 | 498 |
processedIdx.get(id).addPosition(positions[i]); |
494 | 499 |
} |
495 |
|
|
500 |
|
|
496 | 501 |
nlines = processedIdx.keySet().size(); |
497 | 502 |
return true; |
498 | 503 |
} |
499 |
|
|
504 |
|
|
500 | 505 |
public void setParameters(CQLQuery query, Property prop, List<StructuralUnitProperty> pattern, Boolean hierarchicSort) { |
501 | 506 |
if (query != null) this.pQuery = query; |
502 | 507 |
if (pattern != null) this.pPattern = pattern; |
... | ... | |
504 | 509 |
if (hierarchicSort != null) this.pHierarchicSort = hierarchicSort; |
505 | 510 |
dirty = true; |
506 | 511 |
} |
507 |
|
|
512 |
|
|
508 | 513 |
@Override |
509 | 514 |
public boolean setParameters(TXMParameters parameters) { |
510 | 515 |
return false; |
511 | 516 |
} |
512 |
|
|
517 |
|
|
513 | 518 |
@Deprecated |
514 | 519 |
public boolean toTxt(File outfile, String encoding) { |
515 | 520 |
return toTxt(outfile, encoding, "\t", ""); //$NON-NLS-1$ //$NON-NLS-2$ |
516 | 521 |
} |
517 |
|
|
522 |
|
|
518 | 523 |
@Override |
519 | 524 |
@Deprecated |
520 | 525 |
public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) { |
521 | 526 |
try { |
522 | 527 |
// NK: writer declared as class attribute to perform a clean if the operation is interrupted |
523 |
this.writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile), encoding));
|
|
528 |
this.writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile), encoding)); |
|
524 | 529 |
// if ("UTF-8".equals(encoding)) writer.write('\ufeff'); // UTF-8 BOM |
525 | 530 |
toTxt(writer, 0, lines.size() - 1, colseparator, txtseparator); |
526 |
} catch (Exception e) { |
|
531 |
} |
|
532 |
catch (Exception e) { |
|
527 | 533 |
Log.severe(TXMCoreMessages.bind(ReferencerCoreMessages.referencerExportFailedColon, Log.toString(e))); |
528 | 534 |
return false; |
529 | 535 |
} |
530 | 536 |
return true; |
531 | 537 |
} |
532 |
|
|
538 |
|
|
533 | 539 |
@Deprecated |
534 | 540 |
public void toTxt(Writer writer, int from, int to, String colseparator, String txtseparator) |
535 | 541 |
throws CqiClientException, IOException { |
... | ... | |
537 | 543 |
getLines(0, 9999999); |
538 | 544 |
writer.write(pProperty.getName() + colseparator + this.pPattern + "\n"); //$NON-NLS-1$ |
539 | 545 |
for (Line line : lines) { |
540 |
writer.write(txtseparator+line.getPropValue().replace(txtseparator, txtseparator+txtseparator)+txtseparator+ colseparator + txtseparator+ line.getReferences().toString().replace(txtseparator, txtseparator+txtseparator)+txtseparator+"\n"); //$NON-NLS-1$ |
|
546 |
writer.write(txtseparator + line.getPropValue().replace(txtseparator, txtseparator + txtseparator) + txtseparator + colseparator + txtseparator + line.getReferences().toString() |
|
547 |
.replace(txtseparator, txtseparator + txtseparator) + txtseparator + "\n"); //$NON-NLS-1$ |
|
541 | 548 |
writer.flush(); |
542 | 549 |
} |
543 |
|
|
550 |
|
|
544 | 551 |
writer.close(); |
545 |
} catch (CqiServerError e) { |
|
552 |
} |
|
553 |
catch (CqiServerError e) { |
|
546 | 554 |
// TODO Auto-generated catch block |
547 | 555 |
org.txm.utils.logger.Log.printStackTrace(e); |
548 | 556 |
} |
549 | 557 |
} |
550 |
|
|
558 |
|
|
551 | 559 |
@Override |
552 | 560 |
public boolean canCompute() { |
553 |
|
|
561 |
|
|
554 | 562 |
if (pQuery == null || pQuery.isEmpty()) { |
555 | 563 |
Log.fine("No query set."); |
556 | 564 |
return false; |
... | ... | |
566 | 574 |
|
567 | 575 |
return true; |
568 | 576 |
} |
569 |
|
|
577 |
|
|
570 | 578 |
@Override |
571 | 579 |
public boolean loadParameters() throws CqiClientException { |
572 |
if(!this.getStringParameterValue(ReferencerPreferences.QUERY).isEmpty()) { |
|
580 |
if (!this.getStringParameterValue(ReferencerPreferences.QUERY).isEmpty()) {
|
|
573 | 581 |
this.pQuery = new CQLQuery(this.getStringParameterValue(ReferencerPreferences.QUERY)); |
574 | 582 |
} |
575 | 583 |
this.pPattern = StructuralUnitProperty.stringToProperties(this.getCorpus(), this.getStringParameterValue(ReferencerPreferences.PATTERN)); |
576 | 584 |
this.pProperty = this.getCorpus().getProperty(this.getStringParameterValue(ReferencerPreferences.UNIT_PROPERTY)); |
577 | 585 |
return true; |
578 | 586 |
} |
579 |
|
|
587 |
|
|
580 | 588 |
@Override |
581 | 589 |
public boolean saveParameters() { |
582 | 590 |
if (this.pQuery != null) { |
583 | 591 |
this.saveParameter(ReferencerPreferences.QUERY, this.pQuery.getQueryString()); |
584 | 592 |
} |
585 |
|
|
593 |
|
|
586 | 594 |
if (this.pPattern != null) { |
587 |
this.saveParameter(ReferencerPreferences.PATTERN, StructuralUnitProperty.propertiesToString(this.pPattern));
|
|
595 |
this.saveParameter(ReferencerPreferences.PATTERN, StructuralUnitProperty.propertiesToString(this.pPattern)); |
|
588 | 596 |
} |
589 |
|
|
597 |
|
|
590 | 598 |
if (this.pProperty != null) { |
591 | 599 |
this.saveParameter(ReferencerPreferences.UNIT_PROPERTY, this.pProperty.getName()); |
592 | 600 |
} |
593 | 601 |
return true; |
594 | 602 |
} |
595 |
|
|
596 |
|
|
597 |
|
|
598 |
|
|
603 |
|
|
604 |
|
|
605 |
|
|
606 |
|
|
599 | 607 |
/** |
600 | 608 |
* The Class Line. |
601 | 609 |
*/ |
602 | 610 |
public class Line { |
603 |
|
|
611 |
|
|
604 | 612 |
/** The id. */ |
605 | 613 |
int id; |
606 |
|
|
614 |
|
|
607 | 615 |
/** The propvalue. */ |
608 | 616 |
String linepropvalue; |
609 |
|
|
617 |
|
|
610 | 618 |
/** The notcomputed. */ |
611 |
boolean notcomputed=true;
|
|
612 |
|
|
619 |
boolean notcomputed = true;
|
|
620 |
|
|
613 | 621 |
/** The positions. */ |
614 | 622 |
ArrayList<Integer> positions; |
615 |
|
|
623 |
|
|
616 | 624 |
/** The references. */ |
617 | 625 |
ArrayList<String> references; |
618 |
|
|
626 |
|
|
619 | 627 |
/** The references counts. */ |
620 |
HashMap<String, Integer> referencesCounts = new HashMap<String, Integer>();
|
|
621 |
|
|
628 |
HashMap<String, Integer> referencesCounts = new HashMap<>(); |
|
629 |
|
|
622 | 630 |
/** |
623 | 631 |
* Instantiates a new line. |
624 | 632 |
* |
... | ... | |
626 | 634 |
*/ |
627 | 635 |
public Line(int i) { |
628 | 636 |
id = i; |
629 |
positions = new ArrayList<Integer>();
|
|
630 |
references = new ArrayList<String>();
|
|
637 |
positions = new ArrayList<>(); |
|
638 |
references = new ArrayList<>(); |
|
631 | 639 |
} |
632 |
|
|
640 |
|
|
633 | 641 |
/** |
634 | 642 |
* Adds the position. |
635 | 643 |
* |
... | ... | |
638 | 646 |
public void addPosition(int i) { |
639 | 647 |
positions.add(i); |
640 | 648 |
} |
641 |
|
|
649 |
|
|
642 | 650 |
/** |
643 | 651 |
* Adds the reference. |
644 | 652 |
* |
... | ... | |
648 | 656 |
if (!referencesCounts.containsKey(string)) { |
649 | 657 |
references.add(string); |
650 | 658 |
referencesCounts.put(string, 1); |
651 |
} else { |
|
652 |
referencesCounts.put(string, referencesCounts.get(string)+1); |
|
653 | 659 |
} |
660 |
else { |
|
661 |
referencesCounts.put(string, referencesCounts.get(string) + 1); |
|
662 |
} |
|
654 | 663 |
} |
655 |
|
|
664 |
|
|
656 | 665 |
/** |
657 | 666 |
* Clear. |
658 | 667 |
*/ |
659 | 668 |
public void clear() { |
660 | 669 |
notcomputed = false; |
661 |
references = new ArrayList<String>();
|
|
670 |
references = new ArrayList<>(); |
|
662 | 671 |
} |
663 |
|
|
672 |
|
|
664 | 673 |
/** |
665 | 674 |
* Gets the count. |
666 | 675 |
* |
... | ... | |
670 | 679 |
public int getCount(String ref) { |
671 | 680 |
return referencesCounts.get(ref); |
672 | 681 |
} |
673 |
|
|
682 |
|
|
674 | 683 |
public HashMap<String, Integer> getCounts() { |
675 | 684 |
return referencesCounts; |
676 | 685 |
} |
677 |
|
|
686 |
|
|
678 | 687 |
/** |
679 | 688 |
* Gets the prop value. |
680 | 689 |
* |
... | ... | |
683 | 692 |
public String getPropValue() { |
684 | 693 |
return linepropvalue; |
685 | 694 |
} |
686 |
|
|
695 |
|
|
687 | 696 |
/** |
688 | 697 |
* Gets the references. |
689 | 698 |
* |
... | ... | |
692 | 701 |
public List<String> getReferences() { |
693 | 702 |
return references; |
694 | 703 |
} |
695 |
|
|
704 |
|
|
696 | 705 |
/** |
697 | 706 |
* Sort alpha. |
698 | 707 |
*/ |
699 | 708 |
public void sortAlpha() { |
700 | 709 |
Collections.sort(references); |
701 | 710 |
} |
702 |
|
|
711 |
|
|
703 | 712 |
/** |
704 | 713 |
* Sort ref. |
705 | 714 |
* |
... | ... | |
707 | 716 |
*/ |
708 | 717 |
public void sortRef(final boolean reverse) { |
709 | 718 |
Collections.sort(references, new Comparator<String>() { |
710 |
|
|
719 |
|
|
711 | 720 |
@Override |
712 | 721 |
public int compare(String arg0, String arg1) { |
713 | 722 |
if (reverse) |
... | ... | |
717 | 726 |
} |
718 | 727 |
}); |
719 | 728 |
} |
720 |
|
|
721 |
/* (non-Javadoc) |
|
729 |
|
|
730 |
/* |
|
731 |
* (non-Javadoc) |
|
722 | 732 |
* @see java.lang.Object#toString() |
723 | 733 |
*/ |
724 | 734 |
@Override |
725 | 735 |
public String toString() { |
726 |
return linepropvalue+" : <"+id+","+pProperty+"> : "+references.toString(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
736 |
return linepropvalue + " : <" + id + "," + pProperty + "> : " + references.toString(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
727 | 737 |
} |
728 | 738 |
} |
729 |
|
|
739 |
|
|
730 | 740 |
public void setQuery(CQLQuery query) { |
731 | 741 |
this.pQuery = query; |
732 | 742 |
} |
733 |
|
|
743 |
|
|
734 | 744 |
public void setProperty(Property property) { |
735 | 745 |
this.pProperty = property; |
736 | 746 |
} |
737 |
|
|
747 |
|
|
738 | 748 |
public void setPattern(List<StructuralUnitProperty> properties) { |
739 | 749 |
this.pPattern = properties; |
740 | 750 |
} |
... | ... | |
748 | 758 |
*/ |
749 | 759 |
public String createQuery(List<Line> lines) { |
750 | 760 |
String query = ""; //$NON-NLS-1$ |
751 |
|
|
761 |
|
|
752 | 762 |
int nbToken = 1; |
753 |
|
|
754 |
|
|
763 |
|
|
764 |
|
|
755 | 765 |
Property prop = this.getProperty(); |
756 |
for (int t = 0; t < nbToken; t++) |
|
757 |
{ |
|
758 |
query += "["+prop + "=\""; //$NON-NLS-1$ //$NON-NLS-2$ |
|
759 |
|
|
766 |
for (int t = 0; t < nbToken; t++) { |
|
767 |
query += "[" + prop + "=\""; //$NON-NLS-1$ //$NON-NLS-2$ |
|
768 |
|
|
760 | 769 |
for (Line line : lines) { |
761 | 770 |
String s = line.getPropValue(); |
762 | 771 |
s = CQLQuery.addBackSlash(s); |
... | ... | |
767 | 776 |
} |
768 | 777 |
query = query.substring(0, query.length() - 1); |
769 | 778 |
return query; |
770 |
|
|
779 |
|
|
771 | 780 |
} |
772 |
|
|
781 |
|
|
773 | 782 |
@Override |
774 | 783 |
public String getResultType() { |
775 | 784 |
return ReferencerCoreMessages.RESULT_TYPE; |
776 | 785 |
} |
777 |
|
|
778 | 786 |
|
779 |
} |
|
787 |
|
|
788 |
} |
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 2619) | ||
---|---|---|
30 | 30 |
import org.txm.statsengine.r.core.RResult; |
31 | 31 |
import org.txm.statsengine.r.core.RWorkspace; |
32 | 32 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
33 |
import org.txm.utils.TXMProgressMonitor; |
|
33 | 34 |
import org.txm.utils.logger.Log; |
34 | 35 |
|
35 | 36 |
/** |
... | ... | |
183 | 184 |
* @param partition |
184 | 185 |
* @throws Exception |
185 | 186 |
*/ |
186 |
protected LexicalTableImpl _computeFromPartition(Partition partition) throws Exception { |
|
187 |
protected LexicalTableImpl _computeFromPartition(Partition partition, TXMProgressMonitor monitor) throws Exception {
|
|
187 | 188 |
|
188 | 189 |
// parts lexicons |
189 | 190 |
List<CQPLexicon> partsLexicons = new ArrayList<>(); |
190 | 191 |
for (int i = 0; i < partition.getPartsCount(); i++) { |
191 |
partsLexicons.add(CQPLexicon.getLexicon(partition.getParts().get(i), this.property, this.splitMonitor(1), false));
|
|
192 |
partsLexicons.add(CQPLexicon.getLexicon(partition.getParts().get(i), this.property, monitor.createNewMonitor(1), false));
|
|
192 | 193 |
} |
193 | 194 |
|
194 | 195 |
// Corpus global lexicon |
195 |
CQPLexicon corpusLexicon = CQPLexicon.getLexicon(partition.getParent(), this.property, this.splitMonitor(1), false);
|
|
196 |
CQPLexicon corpusLexicon = CQPLexicon.getLexicon(partition.getParent(), this.property, monitor.createNewMonitor(1), false);
|
|
196 | 197 |
|
197 | 198 |
ArrayList<String> filteredForms = new ArrayList<>(); |
198 | 199 |
// create a copy and filter line with Fmin; |
... | ... | |
336 | 337 |
|
337 | 338 |
|
338 | 339 |
@Override |
339 |
protected boolean _compute() throws Exception { |
|
340 |
protected boolean _compute(TXMProgressMonitor monitor) throws Exception {
|
|
340 | 341 |
|
341 | 342 |
if (this.pExternData) { |
342 | 343 |
return this.statsData != null; |
... | ... | |
351 | 352 |
|
352 | 353 |
Subcorpus subcorpus = (Subcorpus) this.parent; |
353 | 354 |
CQPCorpus parentCorpus = subcorpus.getCorpusParent(); |
354 |
CQPLexicon l1 = CQPLexicon.getLexicon(parentCorpus, this.property, this.splitMonitor(20), false);
|
|
355 |
CQPLexicon l2 = CQPLexicon.getLexicon(subcorpus, this.property, this.splitMonitor(20), false);
|
|
355 |
CQPLexicon l1 = CQPLexicon.getLexicon(parentCorpus, this.property, monitor.createNewMonitor(20), false);
|
|
356 |
CQPLexicon l2 = CQPLexicon.getLexicon(subcorpus, this.property, monitor.createNewMonitor(20), false);
|
|
356 | 357 |
|
357 | 358 |
this.statsData = new LexicalTableImpl(getNextName(), l1, l2); |
358 | 359 |
} |
359 | 360 |
else if (this.parent instanceof Partition) { |
360 | 361 |
|
361 |
this.statsData = this._computeFromPartition((Partition) this.parent); |
|
362 |
this.statsData = this._computeFromPartition((Partition) this.parent, monitor);
|
|
362 | 363 |
} |
363 | 364 |
else if (this.parent instanceof PartitionIndex) { |
364 | 365 |
|
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 2619) | ||
---|---|---|
310 | 310 |
boolean needInit = (this.chartComposite.getChartComponent() == null) && (this.getResult().getChart() != null); |
311 | 311 |
|
312 | 312 |
// loading chart |
313 |
this.getResult().monitorSetTask(TXMCoreMessages.bind("Loading chart of type {0}...", this.getResult().getResultType())); //$NON-NLS-1$
|
|
313 |
Log.fine(TXMCoreMessages.bind("Loading chart of type {0}...", this.getResult().getResultType())); //$NON-NLS-1$
|
|
314 | 314 |
this.loadChart(); |
315 | 315 |
|
316 | 316 |
|
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/SwingChartComposite.java (revision 2619) | ||
---|---|---|
53 | 53 |
|
54 | 54 |
|
55 | 55 |
// For reducing resize flickering on Windows |
56 |
static {
|
|
56 |
static {
|
|
57 | 57 |
try { |
58 | 58 |
System.setProperty("sun.awt.noerasebackground", "true"); //$NON-NLS-1$ //$NON-NLS-2$ |
59 | 59 |
} |
60 | 60 |
catch (NoSuchMethodError error) { |
61 | 61 |
} |
62 | 62 |
} |
63 |
|
|
64 |
|
|
65 | 63 |
|
64 |
|
|
65 |
|
|
66 | 66 |
protected Frame frame; |
67 | 67 |
|
68 |
//FIXME: tests |
|
69 |
//protected Panel rootPanel; |
|
70 |
//protected JRootPane rootPanel; |
|
68 |
// FIXME: tests
|
|
69 |
// protected Panel rootPanel;
|
|
70 |
// protected JRootPane rootPanel;
|
|
71 | 71 |
protected JPanel rootPanel; |
72 | 72 |
|
73 |
// protected JComponent rootPanel;
|
|
73 |
// protected JComponent rootPanel;
|
|
74 | 74 |
|
75 |
|
|
76 |
|
|
77 | 75 |
|
78 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 | 79 |
/** |
80 | 80 |
* @param chartEditor |
81 | 81 |
* @param parent |
... | ... | |
85 | 85 |
super(chartEditor, parent, style); |
86 | 86 |
|
87 | 87 |
this.frame = SWT_AWT.new_Frame(this); |
88 |
|
|
88 |
|
|
89 | 89 |
// Need to add an AWT/Swing Panel to fix mouse events and mouse cursors changes on AWT/Swing chart component panel (see: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4982522) |
90 | 90 |
this.rootPanel = new JPanel(new BorderLayout()); |
91 | 91 |
this.frame.add(this.rootPanel); |
92 | 92 |
|
93 | 93 |
// FIXME: tests with Applet, see: https://www.eclipse.org/articles/article.php?file=Article-Swing-SWT-Integration/index.html |
94 | 94 |
// NOTE SJ: avec ce code le changement de moteur à la volée ne fonctionne pas sous Mac OS X |
95 |
// final JApplet applet = new JApplet();
|
|
96 |
// this.rootPanel = (JComponent) applet.getRootPane().getContentPane();
|
|
97 |
// this.frame.add(applet);
|
|
98 |
|
|
99 |
// FIXME: SJ: temporary workaround to Linux focus bugs
|
|
100 |
// it breaks all the key events in charts (zoom, pan, selection, etc.) but
|
|
95 |
// final JApplet applet = new JApplet();
|
|
96 |
// this.rootPanel = (JComponent) applet.getRootPane().getContentPane();
|
|
97 |
// this.frame.add(applet);
|
|
98 |
|
|
99 |
// FIXME: SJ: temporary workaround to Linux focus bugs |
|
100 |
// it breaks all the key events in charts (zoom, pan, selection, etc.) but |
|
101 | 101 |
// stops the conflict between AWT and SWT events that freezes the SWT Spinner, TextFields, etc. |
102 | 102 |
// (Progression query, Specificities chart banality, etc.) |
103 | 103 |
// see: http://forge.cbp.ens-lyon.fr/redmine/issues/2548 |
104 |
if(OSDetector.isFamilyUnix()) {
|
|
104 |
if (OSDetector.isFamilyUnix()) {
|
|
105 | 105 |
this.frame.setAutoRequestFocus(false); |
106 | 106 |
} |
107 | 107 |
|
108 | 108 |
|
109 | 109 |
this.frame.setVisible(true); |
110 |
|
|
110 |
|
|
111 | 111 |
this.rootPanel.setBackground(Color.WHITE); |
112 | 112 |
this.rootPanel.setBorder(new LineBorder(Color.WHITE, 1)); |
113 | 113 |
|
114 |
|
|
114 |
|
|
115 | 115 |
// Change the border of the root panel to show to user the chart is focused |
116 | 116 |
this.frame.addWindowFocusListener(new WindowFocusListener() { |
117 | 117 |
|
... | ... | |
123 | 123 |
@Override |
124 | 124 |
public void windowGainedFocus(WindowEvent e) { |
125 | 125 |
((JComponent) rootPanel).setBorder(new LineBorder(Color.GRAY, 1)); |
126 |
|
|
126 |
|
|
127 | 127 |
// FIXME: SJ: SWT/AWT focus bugs thread tests, need to wait to see how SWT/AWT bugs will be fixed before removing this |
128 |
// getDisplay().asyncExec(new Runnable() {
|
|
129 |
// @Override
|
|
130 |
// public void run() {
|
|
131 |
// |
|
132 |
// //SwingChartComposite.this.notifyListeners(SWT.MouseDown, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseDown));
|
|
133 |
//
|
|
134 |
// // FIXME: Debug
|
|
135 |
//// System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mousePressed(...).new Runnable() {...}.run()");
|
|
136 |
// // Activate the editor part on AWT mouse pressed event
|
|
137 |
// //SwingChartComposite.this.chartEditor.activate();
|
|
138 |
// //chartEditor.getShell().setFocus();
|
|
139 |
//// chartEditor.setFocus();
|
|
140 |
// //chartEditor.getParent().setFocus();
|
|
141 |
//// chartEditor.forceFocus();
|
|
142 |
// SwingChartComposite.this.chartEditor.setFocus();
|
|
143 |
// //notifyListeners(SWT.FocusIn, null); // Needed to force the composite listener to handle the focus event
|
|
144 |
// }
|
|
145 |
// });
|
|
146 |
//
|
|
128 |
// getDisplay().asyncExec(new Runnable() {
|
|
129 |
// @Override
|
|
130 |
// public void run() {
|
|
131 |
//
|
|
132 |
// //SwingChartComposite.this.notifyListeners(SWT.MouseDown, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseDown));
|
|
133 |
//
|
|
134 |
// // FIXME: Debug
|
|
135 |
//// System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mousePressed(...).new Runnable() {...}.run()");
|
|
136 |
// // Activate the editor part on AWT mouse pressed event
|
|
137 |
// //SwingChartComposite.this.chartEditor.activate();
|
|
138 |
// //chartEditor.getShell().setFocus();
|
|
139 |
//// chartEditor.setFocus();
|
|
140 |
// //chartEditor.getParent().setFocus();
|
|
141 |
//// chartEditor.forceFocus();
|
|
142 |
// SwingChartComposite.this.chartEditor.setFocus();
|
|
143 |
// //notifyListeners(SWT.FocusIn, null); // Needed to force the composite listener to handle the focus event
|
|
144 |
// }
|
|
145 |
// });
|
|
146 |
//
|
|
147 | 147 |
|
148 | 148 |
|
149 | 149 |
} |
150 | 150 |
}); |
151 | 151 |
|
152 |
|
|
153 |
// FIXME: SJ: temporary workaround to Linux focus bugs
|
|
152 |
|
|
153 |
// FIXME: SJ: temporary workaround to Linux focus bugs |
|
154 | 154 |
// part #1: release the focus at mouse exited on the rootPanel, needed for empty charts, eg. Progression |
155 |
// it breaks all the key events in charts (zoom, pan, selection, etc.) but
|
|
155 |
// it breaks all the key events in charts (zoom, pan, selection, etc.) but |
|
156 | 156 |
// stops the conflict between AWT and SWT events that freezes the SWT Spinner, TextFields, etc. |
157 | 157 |
// (Progression query, Specificities chart banality, etc.) |
158 | 158 |
// see: http://forge.cbp.ens-lyon.fr/redmine/issues/2548 |
159 | 159 |
if (OSDetector.isFamilyUnix()) { |
160 | 160 |
this.rootPanel.addMouseListener(new MouseListener() { |
161 |
|
|
161 |
|
|
162 | 162 |
@Override |
163 | 163 |
public void mouseReleased(MouseEvent e) { |
164 | 164 |
// TODO Auto-generated method stub |
165 |
|
|
165 |
|
|
166 | 166 |
} |
167 |
|
|
167 |
|
|
168 | 168 |
@Override |
169 | 169 |
public void mousePressed(MouseEvent e) { |
170 | 170 |
// TODO Auto-generated method stub |
171 |
|
|
171 |
|
|
172 | 172 |
} |
173 |
|
|
173 |
|
|
174 | 174 |
@Override |
175 | 175 |
public void mouseExited(MouseEvent e) { |
176 | 176 |
// FIXME: SJ: temporary workaround to Linux focus bugs |
... | ... | |
184 | 184 |
// Log.finest("SwingChartComposite.initEventsListeners().new MouseListener() |
185 | 185 |
// {...}.mouseExited()"); |
186 | 186 |
frame.setVisible(true); |
187 |
|
|
187 |
|
|
188 | 188 |
Display.getDefault().asyncExec(new Runnable() { |
189 |
|
|
189 |
|
|
190 | 190 |
@Override |
191 | 191 |
public void run() { |
192 | 192 |
SwingChartComposite.this.chartEditor.getShell().forceActive(); |
193 | 193 |
} |
194 | 194 |
}); |
195 |
|
|
195 |
|
|
196 | 196 |
} |
197 | 197 |
} |
198 |
|
|
198 |
|
|
199 | 199 |
@Override |
200 | 200 |
public void mouseEntered(MouseEvent e) { |
201 | 201 |
// TODO Auto-generated method stub |
202 |
|
|
202 |
|
|
203 | 203 |
} |
204 |
|
|
204 |
|
|
205 | 205 |
@Override |
206 | 206 |
public void mouseClicked(MouseEvent e) { |
207 | 207 |
// TODO Auto-generated method stub |
208 |
|
|
208 |
|
|
209 | 209 |
} |
210 | 210 |
}); |
211 | 211 |
} |
212 | 212 |
|
213 | 213 |
|
214 | 214 |
} |
215 |
|
|
216 | 215 |
|
217 | 216 |
|
217 |
|
|
218 | 218 |
@Override |
219 | 219 |
public boolean setFocus() { |
220 |
|
|
220 |
|
|
221 | 221 |
if (this.isDisposed()) { |
222 | 222 |
System.out.println("SwingChartComposite.setFocus(): is disposed."); |
223 | 223 |
return false; |
... | ... | |
226 | 226 |
// Debug |
227 | 227 |
Log.finest("SwingChartComposite.setFocus(): trying to give focus to SWT composite and AWT component..."); //$NON-NLS-1$ |
228 | 228 |
|
229 |
//boolean focusState = super.setFocus(); |
|
229 |
// boolean focusState = super.setFocus();
|
|
230 | 230 |
boolean focusState = false; |
231 | 231 |
|
232 | 232 |
// Debug |
... | ... | |
242 | 242 |
/** |
243 | 243 |
* Requests the focus in chart component. |
244 | 244 |
*/ |
245 |
public void requestFocusInChartComponent() {
|
|
245 |
public void requestFocusInChartComponent() {
|
|
246 | 246 |
|
247 | 247 |
|
248 |
if(chartComponent != null) { |
|
249 |
|
|
250 |
// try { |
|
251 |
SwingUtilities.invokeLater(new Runnable () { |
|
252 |
public void run () { |
|
253 |
// if(!((Component) chartComponent).isFocusOwner()) { |
|
254 |
|
|
255 |
//((Component) chartComponent).requestFocus(); |
|
256 |
((JComponent) chartComponent).grabFocus(); |
|
257 |
boolean focusState = ((Component) chartComponent).requestFocusInWindow(); |
|
258 |
|
|
259 |
// Debug |
|
260 |
//Log.finest(TXMCoreMessages.bind("SwingChartComposite.requestFocusInChartComponent(): AWT component focus given state = {0}.", ((Component) chartComponent).isFocusOwner())); //$NON-NLS-1$ |
|
261 |
Log.finest(TXMCoreMessages.bind("SwingChartComposite.requestFocusInChartComponent(): AWT component focus given state = {0}.", focusState)); //$NON-NLS-1$ |
|
262 |
|
|
263 |
|
|
264 |
|
|
265 |
// } |
|
248 |
if (chartComponent != null) { |
|
249 |
|
|
250 |
// try { |
|
251 |
SwingUtilities.invokeLater(new Runnable() { |
|
252 |
|
|
253 |
@Override |
|
254 |
public void run() { |
|
255 |
// if(!((Component) chartComponent).isFocusOwner()) { |
|
256 |
|
|
257 |
// ((Component) chartComponent).requestFocus(); |
|
258 |
((JComponent) chartComponent).grabFocus(); |
|
259 |
boolean focusState = ((Component) chartComponent).requestFocusInWindow(); |
|
260 |
|
|
261 |
// Debug |
|
262 |
// Log.finest(TXMCoreMessages.bind("SwingChartComposite.requestFocusInChartComponent(): AWT component focus given state = {0}.", ((Component) chartComponent).isFocusOwner())); |
|
263 |
// //$NON-NLS-1$ |
|
264 |
Log.finest(TXMCoreMessages.bind("SwingChartComposite.requestFocusInChartComponent(): AWT component focus given state = {0}.", focusState)); //$NON-NLS-1$ |
|
265 |
|
|
266 |
|
|
267 |
|
|
268 |
// } |
|
266 | 269 |
} |
267 | 270 |
}); |
268 |
// }
|
|
269 |
// catch (InvocationTargetException e) {
|
|
270 |
// // TODO Auto-generated catch block
|
|
271 |
// e.printStackTrace();
|
|
272 |
// }
|
|
273 |
// catch (InterruptedException e) {
|
|
274 |
// // TODO Auto-generated catch block
|
|
275 |
// e.printStackTrace();
|
|
276 |
// }
|
|
277 |
|
|
271 |
// }
|
|
272 |
// catch (InvocationTargetException e) {
|
|
273 |
// // TODO Auto-generated catch block
|
|
274 |
// e.printStackTrace();
|
|
275 |
// }
|
|
276 |
// catch (InterruptedException e) {
|
|
277 |
// // TODO Auto-generated catch block
|
|
278 |
// e.printStackTrace();
|
|
279 |
// }
|
|
280 |
|
|
278 | 281 |
} |
279 | 282 |
} |
280 |
|
|
281 |
@Override |
|
282 |
public void initEventsListeners() { |
|
283 |
|
|
284 | 283 |
|
284 |
@Override |
|
285 |
public void initEventsListeners() { |
|
285 | 286 |
|
286 |
// // AWT to SWT |
|
287 |
// ((Component) getChartComponent()).addMouseMotionListener(new MouseMotionListener() { |
|
288 |
// |
|
289 |
// @Override |
|
290 |
// public void mouseMoved(final MouseEvent e) { |
|
291 |
// if(!isDisposed()) { |
|
292 |
// getDisplay().asyncExec(new Runnable () { |
|
293 |
// public void run() { |
|
294 |
// notifyListeners(SWT.MouseMove, SwingChartComposite.swingEventToSWT(SwingChartComposite.this, ((JComponent) getChartComponent()), e, SWT.MouseMove)); |
|
295 |
// } |
|
296 |
// }); |
|
297 |
// } |
|
298 |
// } |
|
299 |
// |
|
300 |
// @Override |
|
301 |
// public void mouseDragged(MouseEvent e) { |
|
302 |
// // TODO Auto-generated method stub |
|
303 |
// |
|
304 |
// } |
|
305 |
// }); |
|
306 |
|
|
287 |
|
|
288 |
|
|
289 |
// // AWT to SWT |
|
290 |
// ((Component) getChartComponent()).addMouseMotionListener(new MouseMotionListener() { |
|
291 |
// |
|
292 |
// @Override |
|
293 |
// public void mouseMoved(final MouseEvent e) { |
|
294 |
// if(!isDisposed()) { |
|
295 |
// getDisplay().asyncExec(new Runnable () { |
|
296 |
// public void run() { |
|
297 |
// notifyListeners(SWT.MouseMove, SwingChartComposite.swingEventToSWT(SwingChartComposite.this, ((JComponent) getChartComponent()), e, SWT.MouseMove)); |
|
298 |
// } |
|
299 |
// }); |
|
300 |
// } |
|
301 |
// } |
|
302 |
// |
|
303 |
// @Override |
|
304 |
// public void mouseDragged(MouseEvent e) { |
|
305 |
// // TODO Auto-generated method stub |
|
306 |
// |
|
307 |
// } |
|
308 |
// }); |
|
309 |
|
|
307 | 310 |
((Component) getChartComponent()).addMouseListener(new MouseListener() { |
308 |
|
|
311 |
|
|
309 | 312 |
@Override |
310 | 313 |
public void mouseReleased(final MouseEvent e) { |
311 |
if(!isDisposed()) { |
|
312 |
getDisplay().asyncExec(new Runnable () { |
|
313 |
public void run() { |
|
314 |
if (!isDisposed()) { |
|
315 |
getDisplay().asyncExec(new Runnable() { |
|
314 | 316 |
|
315 |
// FIXME: context menu |
|
316 |
if( |
|
317 |
|
|
318 |
e.getButton() == MouseEvent.BUTTON3 |
|
319 |
//e.isPopupTrigger() |
|
320 |
) { |
|
321 |
|
|
322 |
//System.err.println("SWTChartsComponentsProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mouseReleased(...).new Runnable() {...}.run(): AWT popup trigger detected"); |
|
317 |
@Override |
|
318 |
public void run() { |
|
323 | 319 |
|
324 |
|
|
320 |
// FIXME: context menu |
|
321 |
if ( |
|
325 | 322 |
|
Formats disponibles : Unified diff