Statistics
| Revision:

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

History | View | Annotate | Download (2.2 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", usage="A Full TIGERSearch query", widget="Text", required=true, def="[]")
29
                String tiger_query
30
@Field @Option(name="count_sub_matches", usage="A Full TIGERSearch query", widget="Boolean", required=true, def="true")
31
                def count_sub_matches
32
@Field @Option(name="debug", usage="Show internal variable content", widget="StringArray", metaVar="OFF        ON        ALL        REALLY ALL", required=true, def="OFF")
33
                debug
34
if (!ParametersDialog.open(this)) return        
35
if (debug == "OFF") debug = 0; else if (debug == "ON") debug = 1; else if (debug == "ALL") debug = 2 else if (debug == "REALLY ALL") debug = 3
36

    
37
TIGERSearchEngine tse = SearchEnginesManager.getTIGERSearchEngine()
38

    
39
println "\t"+selection.join("\t")
40
print "F"
41

    
42
def results = new LinkedHashMap()
43
for (def corpus : selection) {
44

    
45
def root = corpus.getRootCorpusBuild();
46
File buildDirectory = new File(root.getProjectDirectory(), "tiger");
47

    
48
        if (!tse.hasIndexes(corpus)) {
49
                println "Warning: skipping $corpus: no TIGERSearch indexes found."
50
                continue;
51
        }
52
        
53
        def tcorpus = tse.getTSCorpus(corpus);
54
        def sentences_min_max = tse.getSentMinMax(corpus);
55
        def mresult = tcorpus.manager.processQuery(tiger_query, sentences_min_max[0], sentences_min_max[1], 9999999);
56
        int size = 0;
57
        if (count_sub_matches) {
58
                size = mresult.submatchSize();
59
        } else {
60
                size = mresult.size();
61
        }
62
        results[corpus] = size
63
        print "\t"+size
64
}
65
println ""
66

    
67
println "Done."
68

    
69
return results