Révision 3482
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/cqp/CQL2PartitionMacro.groovy (revision 3482) | ||
---|---|---|
1 |
// Copyright © 2022 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 sheiden |
|
4 |
|
|
5 |
package org.txm.macro.commands |
|
6 |
|
|
7 |
// STANDARD DECLARATIONS |
|
8 |
import org.txm.rcpapplication.swt.widget.parameters.* |
|
9 |
import org.txm.searchengine.cqp.corpus.* |
|
10 |
import org.txm.rcp.views.corpora.CorporaView |
|
11 |
|
|
12 |
@Field @Option(name="partitionName", usage="partition name", widget="String", required=true, def="partition1") |
|
13 |
def partitionName |
|
14 |
|
|
15 |
@Field @Option(name="partNames", usage="one name per line", widget="Text", required=true, def="") |
|
16 |
def partNames |
|
17 |
|
|
18 |
/* |
|
19 |
4-GEN-referenced-verses |
|
20 |
6-RNT-referenced-verses |
|
21 |
7-DOT-referenced-verses |
|
22 |
8-KJB-referenced-verses |
|
23 |
*/ |
|
24 |
|
|
25 |
@Field @Option(name="queries", usage="one query per line", widget="Text", required=true, def="") |
|
26 |
def queries |
|
27 |
|
|
28 |
/* |
|
29 |
undump "/home/sheiden/Documents/projet-dth/références-bibliques/matches-2022-06-15/4-GEN-cqp-matches.tsv"; |
|
30 |
undump "/home/sheiden/Documents/projet-dth/références-bibliques/matches-2022-06-15/6-RNT-cqp-matches.tsv"; |
|
31 |
undump "/home/sheiden/Documents/projet-dth/références-bibliques/matches-2022-06-15/7-DOT-cqp-matches.tsv"; |
|
32 |
undump "/home/sheiden/Documents/projet-dth/références-bibliques/matches-2022-06-15/8-KJB-cqp-matches.tsv"; |
|
33 |
*/ |
|
34 |
|
|
35 |
def scriptName = this.class.getSimpleName() |
|
36 |
|
|
37 |
// Open the parameters input dialog box |
|
38 |
if (!ParametersDialog.open(this)) return false |
|
39 |
|
|
40 |
if (!(corpusViewSelection instanceof CQPCorpus)) { |
|
41 |
println "** $scriptName: please select a Corpus in the Corpus view." |
|
42 |
return 0 |
|
43 |
} |
|
44 |
|
|
45 |
corpus = corpusViewSelection |
|
46 |
|
|
47 |
// end of PARAMETERS |
|
48 |
|
|
49 |
// BODY |
|
50 |
|
|
51 |
partNames = partNames.tokenize('\n') |
|
52 |
queries = queries.tokenize('\n') |
|
53 |
|
|
54 |
if (queries.size() == partNames.size()) { |
|
55 |
|
|
56 |
def partition |
|
57 |
|
|
58 |
println "Building partition on $corpus (size = "+(corpus.getSize())+")." |
|
59 |
|
|
60 |
partition = new Partition(corpus) |
|
61 |
partition.setParameters(partitionName, queries, partNames) |
|
62 |
partition.compute() |
|
63 |
|
|
64 |
def list = Arrays.asList(partition.getPartSizes()) |
|
65 |
|
|
66 |
println "'$partitionName' partition created, parts sizes = "+list+", Σ(parts) = "+list.sum()+"." |
|
67 |
|
|
68 |
// println "Total size: "+list.sum()+" - is equal to (sub)corpus size : "+(list.sum() == partition.getCorpus().getSize()) |
|
69 |
|
|
70 |
monitor.syncExec(new Runnable() { |
|
71 |
public void run() { |
|
72 |
CorporaView.refresh() |
|
73 |
CorporaView.expand(partition.getParent()) |
|
74 |
} |
|
75 |
}) |
|
76 |
} else { |
|
77 |
println "** $scriptName: partNames.size() != queries.size(), ("+partNames.size()+" != "+queries.size()+")." |
|
78 |
return 0 |
|
79 |
} |
|
80 |
|
Formats disponibles : Unified diff