Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / macroproto / partition / CreateCrossedPartitionByMetadataMacro.groovy @ 499

History | View | Annotate | Download (2 kB)

1
// STANDARD DECLARATIONS
2
package org.txm.macroproto.partition
3

    
4
import org.kohsuke.args4j.*
5

    
6
import groovy.transform.Field
7

    
8
import org.txm.rcp.swt.widget.parameters.*
9
import org.txm.searchengine.cqp.corpus.*
10
import org.txm.utils.logger.Log;
11
import org.txm.rcp.views.*
12
import org.txm.statsengine.r.core.RWorkspace
13
import org.txm.Toolbox
14

    
15
//BEGINNING OF PARAMETERS
16
def corpus = corpusViewSelection
17
if (!(corpus instanceof Corpus)) {
18
        println "Error: this macro should be run with a Corpus selected"
19
        return
20
}
21

    
22
def struct_property2 = "survey_type"
23
def struct_property_values = ["t1","t2","t3","t4"]
24

    
25
@Field @Option(name="values_file", usage="txt file", widget="File", required=true, def="C:\\Users\\Fanny\\Desktop\\values.txt")
26
def values_file
27

    
28
@Field @Option(name="property", usage="the structural Unit properties list separated with commas", widget="String", required=true, def="emotionalfeelingthe911")
29
def property = "emotionalfeelingthe911"
30

    
31

    
32

    
33
@Field @Option(name="expand_struct", usage="expand_struct", widget="String", required=true, def="question")
34
def expand_struct = "question"
35

    
36
// Open the parameters input dialog box
37
if (!ParametersDialog.open(this)) return;
38

    
39
println "Partition du corpus '$corpus' à partir de la métadonnée '$property' "
40

    
41
def domain = []
42
for (def s :  values_file.getText("UTF-8").split("\n")) domain << s.trim()
43

    
44
def uniq_domain = new HashSet(domain).sort() 
45
println "domain size "+domain.size()
46
println "uniq domain size "+uniq_domain.size()
47

    
48
def names = []
49
def queries = []
50
for (def d2 : struct_property_values) {
51
        for (def d : uniq_domain) {
52
                queries <<  "[_."+struct_property2+"=\"$d2\" & _.text_"+property+"=\"$d\"] expand to $expand_struct"
53
                names << d2+"_"+d        
54
        }
55
}
56
corpus.createPartition(struct_property2+" x "+property+"_non_balanced", queries, names);
57

    
58
println queries
59
println names
60

    
61
//display the graphic
62
monitor.syncExec(new Runnable() {
63
        @Override
64
        public void run() {        
65
        org.txm.rcp.commands.RestartTXM.reloadViews();
66
        }
67
});