Révision 3966
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/prototypes/SelectBanal.groovy (revision 3966) | ||
---|---|---|
1 |
package org.txm.macroproto; |
|
2 |
import org.txm.Toolbox |
|
3 |
import org.txm.searchengine.cqp.clientExceptions.* |
|
4 |
import org.txm.searchengine.cqp.corpus.* |
|
5 |
import org.txm.searchengine.cqp.corpus.query.* |
|
6 |
import org.txm.statsengine.r.core.RWorkspace |
|
7 |
import org.txm.specificities.core.functions.Specificities |
|
8 |
import org.kohsuke.args4j.* |
|
9 |
import groovy.transform.Field |
|
10 |
import org.txm.rcp.swt.widget.parameters.* |
|
11 |
|
|
12 |
if (!(corpusViewSelection instanceof Specificities)) { |
|
13 |
println "Selection if not a Specificites Result" |
|
14 |
return; |
|
15 |
} |
|
16 |
|
|
17 |
// PARAMETERS |
|
18 |
@Field @Option(name="outfile", usage="CSV result file ", widget="File", required=true, def="result.csv") |
|
19 |
def outfile;// = new File("/home/mdecorde/Bureau/test.csv") |
|
20 |
|
|
21 |
@Field @Option(name="MAX", usage="score limit", widget="Integer", required=false, def="1") |
|
22 |
def MAX;// = 1.0 |
|
23 |
|
|
24 |
@Field @Option(name="suseSum", usage="Use the row sums : y/n", widget="String", required=false, def="n") |
|
25 |
String suseSum;// = false |
|
26 |
|
|
27 |
// END OF PARAMETERS |
|
28 |
if (!ParametersDialog.open(this)) return; |
|
29 |
|
|
30 |
if (suseSum == null || suseSum.length() == 0) suseSum = "n" |
|
31 |
boolean useSum = suseSum.toLowerCase().charAt(0) == "y" |
|
32 |
println "useSum $useSum" |
|
33 |
|
|
34 |
def writer = outfile.newWriter("UTF-8") |
|
35 |
def specif = corpusViewSelection |
|
36 |
def indices = specif.getSpecificitesIndex() |
|
37 |
def freqs = specif.getFrequency() |
|
38 |
def rownames = specif.getTypeNames(); |
|
39 |
def colnames = specif.getPartShortNames() ; |
|
40 |
|
|
41 |
def selected = [] |
|
42 |
|
|
43 |
writer.print "unit" |
|
44 |
writer.print "\tF" |
|
45 |
for (int j = 0; j < colnames.size() ; j++) { |
|
46 |
writer.print "\t"+colnames[j] |
|
47 |
writer.print "\tscore" |
|
48 |
} |
|
49 |
writer.println "" |
|
50 |
|
|
51 |
for (int i = 0; i < rownames.length ; i++) { |
|
52 |
boolean add = true |
|
53 |
def totF = 0; |
|
54 |
def totscore = 0.0 |
|
55 |
|
|
56 |
for (int j = 0; j < colnames.size() ; j++) { |
|
57 |
if (Math.abs(indices[i][j]) >= MAX) add = false |
|
58 |
totF += freqs[i][j] |
|
59 |
totscore += Math.abs(indices[i][j]) |
|
60 |
} |
|
61 |
|
|
62 |
if (useSum) { |
|
63 |
if (totscore >= MAX) add = false |
|
64 |
else add = true |
|
65 |
} |
|
66 |
|
|
67 |
if (add) { |
|
68 |
selected << rownames[i] |
|
69 |
writer.print rownames[i] |
|
70 |
writer.print "\t$totF" |
|
71 |
for (int j = 0; j < colnames.size() ; j++) { |
|
72 |
writer.print "\t"+freqs[i][j] |
|
73 |
writer.print "\t"+indices[i][j] |
|
74 |
} |
|
75 |
writer.println "" |
|
76 |
} |
|
77 |
} |
|
78 |
println selected |
|
79 |
println "Saved in $outfile" |
|
80 |
writer.close() |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/prototypes/commands/CreateResultAPIMacro.groovy (revision 3966) | ||
---|---|---|
1 |
import org.kohsuke.args4j.* |
|
2 |
import groovy.transform.Field |
|
3 |
import org.txm.rcp.swt.widget.parameters.* |
|
4 |
import org.txm.searchengine.cqp.corpus.* |
|
5 |
import org.txm.concordance.core.functions.Concordance |
|
6 |
|
|
7 |
|
|
8 |
println "corpora selection: "+corpusViewSelection |
|
9 |
if (corpusViewSelection == null) return; |
|
10 |
if (!(corpusViewSelection instanceof CQPCorpus)) return; |
|
11 |
|
|
12 |
def conc = new Concordance(corpusViewSelection) |
|
13 |
conc.saveParameter("query", "je") |
|
14 |
conc.autoLoadParametersFromAnnotations() |
|
15 |
conc.loadParameters() |
|
16 |
conc.compute() |
|
17 |
|
|
18 |
println conc |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/prototypes/SelectSpecifMacro.groovy (revision 3966) | ||
---|---|---|
14 | 14 |
return; |
15 | 15 |
} |
16 | 16 |
|
17 |
@Field @Option(name="seuil", usage="score limit", widget="Integer", required=false, def="2.0")
|
|
17 |
@Field @Option(name="seuil", usage="score limit", widget="Integer", required=false, def="2") |
|
18 | 18 |
def seuil;// = 1.0 |
19 | 19 |
|
20 | 20 |
@Field @Option(name="NombreDeMots", usage="Use the row sums : y/n", widget="Integer", required=false, def="10") |
... | ... | |
32 | 32 |
|
33 | 33 |
|
34 | 34 |
def specif = corpusViewSelection |
35 |
def indices = specif.getSpecificitesIndex()
|
|
36 |
def rownames = specif.getTypeNames();
|
|
37 |
def colnames = specif.getPartShortNames() ;
|
|
35 |
def indices = specif.getSpecificitesIndices()
|
|
36 |
def rownames = specif.getRowNames();
|
|
37 |
def colnames = specif.getColumnsNames() ;
|
|
38 | 38 |
|
39 | 39 |
def result = new HashSet<String>(); |
40 | 40 |
|
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/stats/BasicVocabularyMacro.groovy (revision 3966) | ||
---|---|---|
68 | 68 |
def output = new File(outputDirectory.toString()+"/"+outputFile) |
69 | 69 |
def writer = output.newWriter("UTF-8") |
70 | 70 |
Specificities specif = corpusViewSelection |
71 |
def indices = specif.getSpecificitesIndex()
|
|
71 |
def indices = specif.getSpecificitesIndices()
|
|
72 | 72 |
def freqs = specif.getFrequencies() |
73 |
def rownames = specif.getTypeNames()
|
|
73 |
def rownames = specif.getRowNames()
|
|
74 | 74 |
def colnames = specif.getColumnsNames() |
75 | 75 |
|
76 | 76 |
def selected = [] |
TXM/trunk/bundles/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/functions/Cooccurrence.java (revision 3966) | ||
---|---|---|
1552 | 1552 |
|
1553 | 1553 |
SpecificitiesR specif = new SpecificitiesR(lt); |
1554 | 1554 |
// System.out.println("Specif N part: "+specif.getNbrPart()); //$NON-NLS-1$ |
1555 |
// System.out.println("Specif N lines number: "+specif.getSpecificitesIndex().length); //$NON-NLS-1$
|
|
1555 |
// System.out.println("Specif N lines number: "+specif.getSpecificitesIndices().length); //$NON-NLS-1$
|
|
1556 | 1556 |
// System.out.println("T specif e: "+(System.currentTimeMillis()- time)); //$NON-NLS-1$ |
1557 | 1557 |
// specif.toTxt(new File("~/Bureau/coocresults/specif Cooc")); //$NON-NLS-1$ |
1558 | 1558 |
String[] specifrownames = specif.getRowNames().asStringsArray(); |
1559 | 1559 |
double[][] scores = specif.getScores(); |
1560 |
// System.out.println("Nb specif result: "+specif.getSpecificitesIndex().length);
|
|
1560 |
// System.out.println("Nb specif result: "+specif.getSpecificitesIndices().length);
|
|
1561 | 1561 |
|
1562 | 1562 |
int iimax = Math.min(specifrownames.length, scores.length); |
1563 | 1563 |
for (int ii = 0; ii < iimax; ii++) { // counts.keySet()) |
TXM/trunk/bundles/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java (revision 3966) | ||
---|---|---|
990 | 990 |
public Partition getPartition(String name) { |
991 | 991 |
List<Partition> partitions = getChildren(Partition.class); |
992 | 992 |
for (Partition p : partitions) |
993 |
if (p.getName().equals(name)) |
|
993 |
if (p.getUserName().equals(name))
|
|
994 | 994 |
return p; |
995 | 995 |
return null; |
996 | 996 |
} |
Formats disponibles : Unified diff