Révision 2185

tmp/org.txm.tigersearch.rcp/groovy/org/txm/macro/tiger/exploit/TIGERMatchesMacro.groovy (revision 2185)
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_subgraph", usage="A Full TIGERSearch query", widget="Boolean", required=true, def="true")
31
		def count_subgraph
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
println tse
39

  
40

  
41
println "\t"+selection.join("\t")
42
print "F"
43

  
44
def results = new LinkedHashMap()
45
for (def corpus : selection) {
46

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

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

  
69
println "Done."
70

  
71
return results
tmp/org.txm.tigersearch.rcp/groovy/org/txm/macro/tiger/exploit/TIGERSummaryMacro.groovy (revision 2185)
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_subgraph", usage="A Full TIGERSearch query", widget="Boolean", required=true, def="true")
31
		def count_subgraph
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
println tse
39

  
40

  
41
println "\t"+selection.join("\t")
42
print "F"
43

  
44
def results = new LinkedHashMap()
45
for (def corpus : selection) {
46

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

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

  
69
println "Done."
70

  
71
return results

Formats disponibles : Unified diff