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
// 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.misc
7

    
8
import org.kohsuke.args4j.*
9
import groovy.transform.Field
10
import org.txm.rcp.swt.widget.parameters.*
11
import org.txm.annotation.urs.*
12
import org.txm.searchengine.cqp.corpus.*
13

    
14
if (!(corpusViewSelection instanceof MainCorpus)) {
15
        println "Corpora selection is not a Corpus"
16
        return;
17
}
18

    
19
// BEGINNING OF PARAMETERS
20
@Field @Option(name="schema_type",usage="", widget="String", required=true, def="Coréférence")
21
String schema_type
22

    
23
if (!ParametersDialog.open(this)) return;
24

    
25
MainCorpus corpus = corpusViewSelection
26
def analecCorpus = URSCorpora.getCorpus(corpus);
27
def map = new HashMap()
28
def unitesInSchema = []
29
def n = 0
30
for (def schema : analecCorpus.getSchemas(schema_type)) {
31
        def unites = schema.getUnitesSousjacentes()
32
        unitesInSchema.addAll(unites)
33
        n += unites.size()
34
}
35

    
36
def counts = unitesInSchema.countBy() { it };
37
for (def c : counts.keySet()) {
38
        if (counts[c] > 1) println "ERROR UNIT IN MULTIPLE SCHEMA["+c.getDeb()+", "+c.getFin()+"]="+c.getProps()+" in "+c.getSchemas().collect() {it.getProps()}
39
}
40

    
41
def set = new HashSet()
42
set.addAll(unitesInSchema)
43
for (def s : set.collect { it.getType() }) {
44
        if (!map.containsKey(s)) map[s] = 0;
45
        map[s] = map[s] +1
46
}
47

    
48
println "Unites types: "+map.sort() { it -> map[it]}