Révision 1390
| tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 1390) | ||
|---|---|---|
| 354 | 354 |
|
| 355 | 355 |
Subcorpus subcorpus = (Subcorpus) this.parent; |
| 356 | 356 |
CQPCorpus parentCorpus = subcorpus.getMainCorpus(); |
| 357 |
Lexicon l1 = new Lexicon(parentCorpus); |
|
| 358 |
l1.setProperty(property); |
|
| 359 |
l1.compute(this.monitor); |
|
| 360 |
Lexicon l2 = new Lexicon(subcorpus); |
|
| 361 |
l2.setProperty(property); |
|
| 362 |
l2.compute(this.monitor); |
|
| 357 |
Lexicon l1 = Lexicon.findLexiconForParameter(parentCorpus, property); |
|
| 358 |
Lexicon l2 = Lexicon.findLexiconForParameter(subcorpus, property); |
|
| 359 |
|
|
| 363 | 360 |
this.statsData = new LexicalTableImpl(getNextName(), l1, l2); |
| 364 | 361 |
} |
| 365 | 362 |
else if (this.parent instanceof Partition) {
|
| ... | ... | |
| 381 | 378 |
|
| 382 | 379 |
// FIXME SJ: new version, to validate |
| 383 | 380 |
this.statsData.filter(this.vMaxFilter, this.fMinFilter); |
| 381 |
|
|
| 382 |
|
|
| 384 | 383 |
// FIXME SJ: old version |
| 385 | 384 |
//this.statsData.cut(this.vMaxFilter); |
| 386 | 385 |
|
| tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1390) | ||
|---|---|---|
| 91 | 91 |
* like after updating parameters |
| 92 | 92 |
*/ |
| 93 | 93 |
protected boolean dirty = true; |
| 94 |
|
|
| 95 |
/** |
|
| 96 |
* if frozen, the result is not updated when computed |
|
| 97 |
*/ |
|
| 98 |
protected boolean frozen = false; |
|
| 94 | 99 |
|
| 95 | 100 |
/** |
| 96 | 101 |
* The result parent. Should not be null except for roots TXMResult |
| ... | ... | |
| 142 | 147 |
*/ |
| 143 | 148 |
protected boolean userPersistable; |
| 144 | 149 |
|
| 145 |
|
|
| 146 |
|
|
| 147 | 150 |
/** |
| 148 | 151 |
* The visibility state. |
| 149 | 152 |
*/ |
| ... | ... | |
| 283 | 286 |
this.userName = name; |
| 284 | 287 |
} |
| 285 | 288 |
|
| 289 |
/** |
|
| 290 |
* Froze the result -> cannot be recomputed |
|
| 291 |
*/ |
|
| 292 |
public void froze() {
|
|
| 293 |
this.frozen = true; |
|
| 294 |
} |
|
| 295 |
|
|
| 296 |
/** |
|
| 297 |
* Un-Froze the result -> can be recomputed |
|
| 298 |
*/ |
|
| 299 |
public void unfroze() {
|
|
| 300 |
this.frozen = false; |
|
| 301 |
} |
|
| 286 | 302 |
|
| 287 | 303 |
/** |
| 304 |
* Froze/Un-Froze the result |
|
| 305 |
*/ |
|
| 306 |
public void setFrozen(boolean frozen) {
|
|
| 307 |
this.frozen = frozen; |
|
| 308 |
} |
|
| 309 |
|
|
| 310 |
/** |
|
| 311 |
* @return true if the resutl is frozen |
|
| 312 |
*/ |
|
| 313 |
public boolean isFrozen() {
|
|
| 314 |
return this.frozen; |
|
| 315 |
} |
|
| 316 |
|
|
| 317 |
/** |
|
| 288 | 318 |
* Creates an UUID dedicated to persistence of this result. |
| 289 | 319 |
* @return |
| 290 | 320 |
*/ |
| ... | ... | |
| 1862 | 1892 |
*/ |
| 1863 | 1893 |
protected boolean compute(IProgressMonitor monitor, boolean deepComputing) {
|
| 1864 | 1894 |
|
| 1895 |
if (hasBeenComputedOnce && frozen) return true; // no changes to do |
|
| 1896 |
|
|
| 1865 | 1897 |
try {
|
| 1866 | 1898 |
|
| 1867 |
|
|
| 1868 | 1899 |
Log.finest("*** TXMResult.compute(): " + this.getClass().getSimpleName() + ": starting computing process...");
|
| 1869 | 1900 |
|
| 1870 | 1901 |
// FIXME: see if this skipComputing tests is still useful? is it possible to directly return instead? |
| tmp/org.txm.index.core/src/org/txm/index/core/functions/Lexicon.java (revision 1390) | ||
|---|---|---|
| 35 | 35 |
import java.io.UnsupportedEncodingException; |
| 36 | 36 |
import java.util.ArrayList; |
| 37 | 37 |
import java.util.Arrays; |
| 38 |
import java.util.List; |
|
| 38 | 39 |
import java.util.Map; |
| 39 | 40 |
|
| 40 | 41 |
import org.eclipse.core.runtime.IProgressMonitor; |
| ... | ... | |
| 240 | 241 |
//long start = System.currentTimeMillis(); |
| 241 | 242 |
int[][] fdist = null; |
| 242 | 243 |
AbstractCqiClient cqi = CorpusManager.getCorpusManager().getCqiClient(); |
| 243 |
String tmp = "S" + corpus.getNextSubcorpusCounter();
|
|
| 244 |
String tmp = "TMP" + CQPCorpus.getNextSubcorpusCounter();
|
|
| 244 | 245 |
String qtmp = corpus.getMainCorpus().getQualifiedCqpId()+":"+tmp; |
| 245 | 246 |
try {
|
| 246 | 247 |
this.subTask("Computing lexicon frequencies...");
|
| 248 |
System.out.println("subcorpus: "+corpus.getQualifiedCqpId());
|
|
| 249 |
System.out.println("query subcorpus: "+qtmp);
|
|
| 247 | 250 |
cqi.cqpQuery(corpus.getQualifiedCqpId(), tmp, "[]"); |
| 248 | 251 |
fdist = CorpusManager.getCorpusManager().getCqiClient().fdist1(qtmp, 0, ICqiClient.CQI_CONST_FIELD_MATCH, property.getName()); |
| 249 | 252 |
//System.out.println("nb lines: "+fdist.length);
|
| ... | ... | |
| 298 | 301 |
// if (freqs[i] != 1) System.out.println(freqs[i]); |
| 299 | 302 |
} |
| 300 | 303 |
} |
| 304 |
|
|
| 305 |
public static Lexicon findLexiconForParameter(CQPCorpus corpus, Property prop) {
|
|
| 306 |
List<Lexicon> lexicons = (List<Lexicon>) corpus.getChildren(Lexicon.class); |
|
| 307 |
for (Lexicon l : lexicons) {
|
|
| 308 |
if (l.getProperty().equals(prop)) {
|
|
| 309 |
return l; |
|
| 310 |
} |
|
| 311 |
} |
|
| 312 |
|
|
| 313 |
Lexicon newL = new Lexicon(corpus); |
|
| 314 |
newL.setProperty(prop); |
|
| 315 |
newL.compute(); |
|
| 316 |
return newL; |
|
| 317 |
|
|
| 318 |
} |
|
| 301 | 319 |
|
| 302 | 320 |
/** |
| 303 | 321 |
* Dump lexicon forms and frequencies in a String. |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java (revision 1390) | ||
|---|---|---|
| 31 | 31 |
import java.util.ArrayList; |
| 32 | 32 |
import java.util.Collection; |
| 33 | 33 |
import java.util.Collections; |
| 34 |
import java.util.Comparator; |
|
| 34 | 35 |
import java.util.HashMap; |
| 35 | 36 |
import java.util.HashSet; |
| 36 | 37 |
import java.util.List; |
| ... | ... | |
| 254 | 255 |
long start = System.currentTimeMillis(); |
| 255 | 256 |
try {
|
| 256 | 257 |
CorpusManager.getCorpusManager().getCqiClient().cqpQuery( |
| 257 |
this.getQualifiedCqpId(), subcorpusCqpId, |
|
| 258 |
query.getQueryString()); |
|
| 258 |
this.getQualifiedCqpId(), subcorpusCqpId, query.getQueryString()); |
|
| 259 | 259 |
//System.out.println("SUBCORPUS: "+subcorpusCqpId+" q="+query.getQueryString());
|
| 260 | 260 |
subcorpus = new Subcorpus(this); |
| 261 | 261 |
subcorpus.setParameters(subcorpusCqpId, subcorpusName, query); |
| ... | ... | |
| 581 | 581 |
return this.userName; |
| 582 | 582 |
} |
| 583 | 583 |
|
| 584 |
|
|
| 585 |
public static final Comparator<WordProperty> wordFirstComparator = new Comparator<WordProperty>() {
|
|
| 586 |
@Override |
|
| 587 |
public int compare(WordProperty o1, WordProperty o2) {
|
|
| 588 |
if (o1.getName().equals("word")) return -1;
|
|
| 589 |
if (o2.getName().equals("word")) return 1;
|
|
| 590 |
return o1.compareTo(o2); |
|
| 591 |
} |
|
| 592 |
}; |
|
| 593 |
|
|
| 584 | 594 |
/** |
| 585 | 595 |
* Get the ordered properties (by name). |
| 586 | 596 |
* |
| ... | ... | |
| 590 | 600 |
@SuppressWarnings("unchecked") //$NON-NLS-1$
|
| 591 | 601 |
public List<WordProperty> getOrderedProperties() throws CqiClientException {
|
| 592 | 602 |
List<WordProperty> props = this.getProperties(); |
| 593 |
Collections.sort(props); |
|
| 603 |
Collections.sort(props, wordFirstComparator);
|
|
| 594 | 604 |
return props; |
| 595 | 605 |
} |
| 596 | 606 |
|
| tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/r/function/SpecificitiesR.java (revision 1390) | ||
|---|---|---|
| 80 | 80 |
public SpecificitiesR(ILexicalTable lt) throws StatException {
|
| 81 | 81 |
super(prefixR+(specif_counter++)); |
| 82 | 82 |
|
| 83 |
// Create a set of the existing types |
|
| 84 |
String[] rownames = lt.getRowNames().asStringsArray(); |
|
| 85 |
String[] colnames = lt.getColNames().asStringsArray(); |
|
| 86 |
|
|
| 87 | 83 |
//System.out.println("Av specif ");
|
| 88 |
specIndex = compute(symbol, lt, rownames, colnames);
|
|
| 84 |
specIndex = compute(symbol, lt, null, null);
|
|
| 89 | 85 |
} |
| 90 | 86 |
|
| 91 | 87 |
/** |
| ... | ... | |
| 136 | 132 |
// TODO Auto-generated catch block |
| 137 | 133 |
e1.printStackTrace(); |
| 138 | 134 |
} |
| 139 |
REXP r = rw.callFunction("specificities", new QuantitativeDataStructure[] { table, row, column }, symbol); //$NON-NLS-1$
|
|
| 140 | 135 |
|
| 136 |
|
|
| 141 | 137 |
double[][] res; |
| 142 |
try {
|
|
| 143 |
res = r.asDoubleMatrix(); |
|
| 144 |
} catch (Exception e) {
|
|
| 145 |
throw new StatException(TXMCoreMessages.bind(SpecificitiesCoreMessages.failedToGetTheSpecificitesColon, e.getMessage()), e); |
|
| 138 |
if (table.getNRows() > 1 && table.getNColumns() > 1) {
|
|
| 139 |
REXP r = rw.callFunction("specificities", new QuantitativeDataStructure[] { table, row, column }, symbol); //$NON-NLS-1$
|
|
| 140 |
|
|
| 141 |
try {
|
|
| 142 |
res = r.asDoubleMatrix(); |
|
| 143 |
} catch (Exception e) {
|
|
| 144 |
throw new StatException(TXMCoreMessages.bind(SpecificitiesCoreMessages.failedToGetTheSpecificitesColon, e.getMessage()), e); |
|
| 145 |
} |
|
| 146 |
Log.finest(TXMCoreMessages.bind(SpecificitiesCoreMessages.specificityIndexComputed, (res.length * res[0].length))); |
|
| 147 |
} else {
|
|
| 148 |
res = new double[table.getNRows()][table.getNColumns()]; |
|
| 146 | 149 |
} |
| 147 |
Log.finest(TXMCoreMessages.bind(SpecificitiesCoreMessages.specificityIndexComputed, (res.length * res[0].length))); |
|
| 148 |
|
|
| 149 | 150 |
return res; |
| 150 | 151 |
} |
| 151 | 152 |
|
| tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 1390) | ||
|---|---|---|
| 44 | 44 |
import org.txm.core.results.TXMResult; |
| 45 | 45 |
import org.txm.index.core.functions.Lexicon; |
| 46 | 46 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
| 47 |
import org.txm.lexicaltable.core.statsengine.data.ILexicalTable; |
|
| 47 | 48 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 48 | 49 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| 49 | 50 |
import org.txm.searchengine.cqp.corpus.Partition; |
| ... | ... | |
| 184 | 185 |
this.deleteChildren(SpecificitiesSelection.class); |
| 185 | 186 |
} |
| 186 | 187 |
|
| 187 |
if (this.lexicalTable.hasBeenComputedOnce()) {
|
|
| 188 |
SpecificitiesR rSpecificities = new SpecificitiesR(this.lexicalTable.getData()); |
|
| 188 |
//if (this.lexicalTable.hasBeenComputedOnce()) { // LT should have been computed one because of TXMResult.compute
|
|
| 189 |
|
|
| 190 |
ILexicalTable data = this.lexicalTable.getData(); |
|
| 191 |
|
|
| 192 |
SpecificitiesR rSpecificities = new SpecificitiesR(data); |
|
| 189 | 193 |
double[][] specIndex = rSpecificities.getScores(); |
| 190 | 194 |
|
| 191 | 195 |
String sname = null; |
| ... | ... | |
| 200 | 204 |
} else {
|
| 201 | 205 |
init(rSpecificities.getSymbol(), specIndex, sname); //$NON-NLS-1$ |
| 202 | 206 |
} |
| 203 |
} |
|
| 207 |
//}
|
|
| 204 | 208 |
|
| 205 | 209 |
return true; |
| 206 | 210 |
} |
Formats disponibles : Unified diff