Statistics
| Revision:

root / tmp / org.txm.core / src / groovy / org / txm / macro / misc / TXM2CoNLL2009Macro.groovy @ 187

History | View | Annotate | Download (1.8 kB)

1
package org.txm.macro.misc
2
import org.txm.export.conll2009.ToCoNLL2009
3

    
4
import java.io.File;
5
import org.txm.searchengine.cqp.corpus.*
6
import org.kohsuke.args4j.*
7
import groovy.transform.Field
8
import org.txm.rcpapplication.swt.widget.parameters.*
9

    
10
if (!(corpusViewSelection instanceof Corpus)) {
11
        println "Select a corpus or a sub-corpus"
12
        return;
13
}
14
def corpus = corpusViewSelection
15

    
16
@Field @Option(name="outputFile", usage="an example file", widget="File", required=true, def="conn_export.tsv")
17
File outputFile = new File("conn_export.tsv")
18
@Field @Option(name="encoding", usage="sentenceProperty", widget="String", required=true, def="UTF-8")
19
String encoding = "UTF-8"
20

    
21
@Field @Option(name="sentenceProperty", usage="sentenceProperty", widget="String", required=true, def="s_id")
22
String sentenceProperty = "s_id"
23
@Field @Option(name="posProperty", usage="sentenceProperty", widget="String", required=true, def="pos")
24
String posProperty = "frpos"
25
@Field @Option(name="lemmaProperty", usage="sentenceProperty", widget="String", required=true, def="lemma")
26
String lemmaProperty = "frlemma"
27

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

    
30
def split = sentenceProperty.split("_", 2)
31
StructuralUnitProperty s = corpus.getStructuralUnit(split[0]).getProperty(split[1])
32
Property word = corpus.getProperty("word")
33
Property lemma = corpus.getProperty(lemmaProperty)
34
Property pos = corpus.getProperty(posProperty)
35

    
36
if (s == null) { println "Error sentence property: $sentenceProperty"; return}
37
if (word == null) { println "Error no word property"; return}
38
if (pos == null) { println "Error pos property: $posProperty"; return}
39
if (lemma == null) { println "Error lemma property: $lemmaProperty"; return}
40

    
41

    
42
ToCoNLL2009 processor = new ToCoNLL2009()
43
processor.process(outputFile, corpus, s, word, lemma, pos, encoding)