Statistics
| Revision:

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

History | View | Annotate | Download (1.8 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
@Field @Option(name="values_file", usage="txt file", widget="File", required=true, def="C:\\Users\\Fanny\\Desktop\\values.txt")
23
def values_file
24

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

    
28
@Field @Option(name="expand_struct", usage="expand_struct", widget="String", required=true, def="question")
29
def expand_struct = "question"
30

    
31
// Open the parameters input dialog box
32
if (!ParametersDialog.open(this)) return;
33

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

    
36
def domain = []
37
for (def s :  values_file.getText("UTF-8").split("\n")) domain << s.trim()
38

    
39
def uniq_domain = new HashSet(domain).sort() 
40
println "domain size "+domain.size()
41
println "uniq domain size "+uniq_domain.size()
42

    
43
def names = []
44
def queries = []
45

    
46
for (def d : uniq_domain) {
47
        queries <<  "[_.text_"+property+"=\"$d\"] expand to $expand_struct"
48
        names << d        
49
}
50

    
51
corpus.createPartition(property+"_non_balanced", queries, names);
52

    
53
println queries
54
println names
55

    
56
//display the graphic
57
monitor.syncExec(new Runnable() {
58
        @Override
59
        public void run() {        
60
        org.txm.rcp.commands.RestartTXM.reloadViews();
61
        }
62
});