Statistics
| Revision:

root / tmp / org.txm.analec.rcp / src / org / txm / macro / urs / UnitsMacro.groovy @ 1217

History | View | Annotate | Download (1.6 kB)

1
// Copyright © 2016 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
// @author sheiden
5
// STANDARD DECLARATIONS
6
package org.txm.macro.urs
7

    
8
import org.apache.commons.lang.StringUtils;
9
import org.kohsuke.args4j.*
10
import groovy.transform.Field
11
import org.txm.Toolbox;
12
import org.txm.rcp.swt.widget.parameters.*
13
import org.txm.annotation.urs.*
14
import org.txm.searchengine.cqp.AbstractCqiClient;
15
import org.txm.searchengine.cqp.CQPSearchEngine
16
import org.txm.searchengine.cqp.corpus.*
17
import visuAnalec.donnees.Structure;
18
import visuAnalec.elements.Unite;
19

    
20
if (!(corpusViewSelection instanceof MainCorpus)) {
21
        println "Corpora selection is not a Corpus"
22
        return;
23
}
24

    
25
// BEGINNING OF PARAMETERS
26
@Field @Option(name="unit_type",usage="", widget="String", required=true, def="MENTION")
27
String unit_type
28

    
29
if (!ParametersDialog.open(this)) return;
30

    
31
MainCorpus corpus = corpusViewSelection
32
AbstractCqiClient CQI = CQPSearchEngine.getCqiClient();
33
def word = corpus.getWordProperty()
34
def analecCorpus = URSCorpora.getCorpus(corpus);
35

    
36
int n = 1;
37
def units = analecCorpus.getUnites(unit_type)
38
units.sort() { a, b -> a.getDeb() <=> b.getDeb() ?: a.getFin() <=> b.getFin() }
39
for (Unite unit : units) {
40
        int[] pos = null
41
        if (unit.getDeb() == unit.getFin()) pos = [unit.getDeb()]
42
        else pos = (unit.getDeb()..unit.getFin())
43
        def form = StringUtils.join(CQI.cpos2Str(word.getQualifiedName(), pos), " ")
44
        
45
        def props = unit.getProps().sort();
46
        println "$n - ${unit.getDeb()} -> ${unit.getFin()} - $props : $form"
47
        n++
48
}