Statistics
| Revision:

root / tmp / org.txm.tigersearch.rcp / groovy / org / txm / macro / tiger / exploit / TIGERRatioMacro.groovy @ 2346

History | View | Annotate | Download (2.4 kB)

1
// Copyright © 2019 ENS de Lyon, CNRS, University of Franche-Comté
2
// Licensed under the terms of the GNU General Public License (http://www.gnu.org/licenses)
3
// @author mdecorde
4
// STANDARD DECLARATIONS
5
package org.txm.macro.tiger.exploit
6

    
7
import groovy.transform.Field
8

    
9
import org.txm.searchengine.core.SearchEnginesManager
10
import org.txm.searchengine.cqp.corpus.*
11
import org.txm.searchengine.ts.TIGERSearchEngine
12

    
13
def scriptName = this.class.getSimpleName()
14

    
15
def selection = []
16
for (def s : corpusViewSelections) {
17
        if (s instanceof CQPCorpus) selection << s
18
        else if (s instanceof Partition) selection.addAll(s.getParts())
19
}
20

    
21
if (selection.size() == 0) {
22
        println "** $scriptName: please select a Corpus or a Partition in the Corpus view: "+corpusViewSelections
23
        return false
24
} else {
25
        for (def c : selection) c.compute(false)
26
}
27

    
28
@Field @Option(name="tiger_query_A", usage="A Full TIGERSearch query", widget="Text", required=true, def="[]")
29
                String tiger_query_A
30
                @Field @Option(name="tiger_query_B", usage="A Full TIGERSearch query", widget="Text", required=true, def="[]")
31
                String tiger_query_B
32
@Field @Option(name="count_sub_matches", usage="A Full TIGERSearch query", widget="Boolean", required=true, def="true")
33
                def count_sub_matches
34
@Field @Option(name="debug", usage="Show internal variable content", widget="StringArray", metaVar="OFF        ON        ALL        REALLY ALL", required=true, def="OFF")
35
                debug
36
if (!ParametersDialog.open(this)) return        
37
if (debug == "OFF") debug = 0; else if (debug == "ON") debug = 1; else if (debug == "ALL") debug = 2 else if (debug == "REALLY ALL") debug = 3
38

    
39

    
40
def results_A = gse.run(TIGERSummaryMacro, ["args":["tiger_query":tiger_query_A, "count_sub_matches":count_sub_matches, "debug":debug],
41
        "selection":selection,
42
        "selections":selections,
43
        "corpusViewSelection":corpusViewSelection,
44
        "corpusViewSelections":corpusViewSelections,
45
        "monitor":monitor])
46

    
47
def results_B = gse.run(TIGERSummaryMacro, ["args":["tiger_query":tiger_query_B, "count_sub_matches":count_sub_matches, "debug":debug],
48
        "selection":selection,
49
        "selections":selections,
50
        "corpusViewSelection":corpusViewSelection,
51
        "corpusViewSelections":corpusViewSelections,
52
        "monitor":monitor])
53

    
54
println results_A
55
println results_B
56
for (def corpus : selection) {
57
        def coef = results_A[corpus] / results_B[corpus]
58
        println "R = ${results_A[corpus]} / ${results_B[corpus]} = "+String.format( "%.2f", coef)
59
}
60
println "Done."