Statistics
| Revision:

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

History | View | Annotate | Download (1.4 kB)

1 671 mdecorde
// Copyright © 2016 ENS de Lyon, CNRS, University of Franche-Comté
2 671 mdecorde
// Licensed under the terms of the GNU General Public License (http://www.gnu.org/licenses)
3 671 mdecorde
// @author mdecorde
4 671 mdecorde
// @author sheiden
5 671 mdecorde
// STANDARD DECLARATIONS
6 1217 mdecorde
package org.txm.macro.urs.misc
7 671 mdecorde
8 671 mdecorde
import org.kohsuke.args4j.*
9 671 mdecorde
import groovy.transform.Field
10 671 mdecorde
import org.txm.rcp.swt.widget.parameters.*
11 1217 mdecorde
import org.txm.annotation.urs.*
12 671 mdecorde
import org.txm.searchengine.cqp.corpus.*
13 671 mdecorde
14 671 mdecorde
if (!(corpusViewSelection instanceof MainCorpus)) {
15 671 mdecorde
        println "Corpora selection is not a Corpus"
16 671 mdecorde
        return;
17 671 mdecorde
}
18 671 mdecorde
19 671 mdecorde
// BEGINNING OF PARAMETERS
20 671 mdecorde
@Field @Option(name="schema_type",usage="", widget="String", required=true, def="Coréférence")
21 671 mdecorde
String schema_type
22 671 mdecorde
23 671 mdecorde
if (!ParametersDialog.open(this)) return;
24 671 mdecorde
25 671 mdecorde
MainCorpus corpus = corpusViewSelection
26 1217 mdecorde
def analecCorpus = URSCorpora.getCorpus(corpus);
27 671 mdecorde
def map = new HashMap()
28 671 mdecorde
def unitesInSchema = []
29 671 mdecorde
def n = 0
30 671 mdecorde
for (def schema : analecCorpus.getSchemas(schema_type)) {
31 671 mdecorde
        def unites = schema.getUnitesSousjacentes()
32 671 mdecorde
        unitesInSchema.addAll(unites)
33 671 mdecorde
        n += unites.size()
34 671 mdecorde
}
35 671 mdecorde
36 671 mdecorde
def counts = unitesInSchema.countBy() { it };
37 671 mdecorde
for (def c : counts.keySet()) {
38 671 mdecorde
        if (counts[c] > 1) println "ERROR UNIT IN MULTIPLE SCHEMA["+c.getDeb()+", "+c.getFin()+"]="+c.getProps()+" in "+c.getSchemas().collect() {it.getProps()}
39 671 mdecorde
}
40 671 mdecorde
41 671 mdecorde
def set = new HashSet()
42 671 mdecorde
set.addAll(unitesInSchema)
43 671 mdecorde
for (def s : set.collect { it.getType() }) {
44 671 mdecorde
        if (!map.containsKey(s)) map[s] = 0;
45 671 mdecorde
        map[s] = map[s] +1
46 671 mdecorde
}
47 671 mdecorde
48 671 mdecorde
println "Unites types: "+map.sort() { it -> map[it]}