Statistics
| Revision:

root / tmp / org.txm.analec.rcp / src / org / txm / macro / urs / democrat / BuildSectionsMacro.groovy @ 2167

History | View | Annotate | Download (1.8 kB)

1
package org.txm.macro.urs.democrat
2

    
3
import org.txm.searchengine.cqp.corpus.*
4
import org.txm.rcpapplication.views.*
5
import org.txm.searchengine.cqp.corpus.query.*
6
import org.txm.Toolbox
7

    
8
def scriptName = this.class.getSimpleName()
9
def utils = new org.txm.macro.urs.exploit.CQPUtils()
10

    
11
// Création des 4 sous-corpus de chapitres
12

    
13
[1, 2, 3, 4].each { chapitre ->
14
        res = gse.run(SubCorpusMacro, ["args":["name":"Chapitre "+chapitre, "query":"[_.div_n1=\""+chapitre+"\"] expand to div1" ],
15
                                "selection":selection,
16
                                "selections":selections,
17
                                "corpusViewSelection":corpusViewSelection,
18
                                "corpusViewSelections":corpusViewSelections,
19
                                "monitor":monitor])
20
        if (!res) println "** problem calling SubCorpusMacro."
21
}
22

    
23

    
24
// Définition des paragraphes dans les 4 chapitres
25

    
26
def para = [
27
[1, 14, 17, 22],
28
[2, 29, 44, 46],
29
[3, 53, 63, 66],
30
[4, 74, 75, 79]
31
]
32

    
33
// get the CQP corpus
34
if (!(corpusViewSelection instanceof CQPCorpus)) {
35
        println "Corpus view selection is no a corpus: $corpusViewSelection"
36
        return false;
37
}
38
def corpus = corpusViewSelection
39
if (corpus.getName() != "DIDEROTESSAIS") {
40
        println "Warning: this macro was made to work for the DIDEROTESSAIS corpus"
41
}
42
        
43
para.each { chapitre ->
44

    
45
        println chapitre
46

    
47
        def subcorpus = corpus.getSubcorpusByName("Chapitre "+chapitre[0])
48

    
49
        println "chap = "+subcorpus
50

    
51
        [1, 2, 3].each { num ->
52

    
53
                def p = chapitre[num]
54

    
55
                println "p = "+p
56

    
57
                name = "p "+p
58
                query = '[_.p_n=\"'+p+'\"] expand to p'
59

    
60
                res = gse.run(SubCorpusMacro, ["args":[ "name":name, "query":query ],
61
                                "corpusViewSelections":[subcorpus],
62
                                                                "corpusViewSelection":subcorpus,
63
                                "monitor":monitor])
64
                
65

    
66
        } // [1, 2, 3].each
67

    
68
} // para.each