Statistics
| Revision:

root / tmp / org.txm.analec.rcp / src / org / txm / macro / analec / UnitTypesNotInSchemaMacro.groovy @ 1166

History | View | Annotate | Download (1.3 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.analec
7

    
8
import org.kohsuke.args4j.*
9
import groovy.transform.Field
10
import org.txm.rcp.swt.widget.parameters.*
11
import org.txm.analec.*
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
if (!ParametersDialog.open(this)) return;
23

    
24
MainCorpus corpus = corpusViewSelection
25
def analecCorpus = AnalecCorpora.getCorpus(corpus);
26

    
27
def unitesInSchema = new HashSet()
28
for (def schema : analecCorpus.getSchemas(schema_type)) {
29
        unitesInSchema.addAll(schema.getUnitesSousjacentes())
30
}
31
println "unites: "+analecCorpus.getToutesUnites().size()
32
println "unites in schema: "+unitesInSchema.size()
33

    
34
def set = new HashMap()
35
for (def u : analecCorpus.getToutesUnites()) {
36
        if (unitesInSchema.contains(u)) continue;
37
        
38
        if (!set.containsKey(u.getType())) set[u.getType()] = 0;
39
        set[u.getType()] = set[u.getType()] +1
40
}
41

    
42
println "unites not in schema: "+set.sort() { it -> set[it]}