Statistics
| Revision:

root / tmp / org.txm.core / src / groovy / org / txm / export / ExportLT.groovy @ 148

History | View | Annotate | Download (1.3 kB)

1
package org.txm.export
2
import org.txm.Toolbox
3
import org.txm.searchengine.cqp.corpus.*
4
import org.txm.searchengine.cqp.corpus.query.*
5
import org.txm.stat.data.*;
6
import org.txm.functions.cooccurrences.*
7

    
8

    
9
def corpus = CorpusManager.getCorpusManager().getCorpus("DISCOURS") // mettre le nom du corpus en Majuscules ici
10
def partition = corpus.getPartition("types");
11

    
12
int NTable = 1;
13
for (Object o : partition.getResults()) {
14
//        if (o instanceof LexicalTable) {
15
                File outfile = new File("lt${NTable}.txt")
16
                println "export LT of $partition in "+outfile.getAbsolutePath();
17
                NTable++;
18
                outfile.withWriter{writer->
19
                def lt = o;
20
                println "found lexical table: "+lt.getName()
21
                println "n col: "+lt.getNColumns()
22
                println "n line: "+lt.getNRows()
23
                def cols = lt.getColNames().asStringsArray();
24
                String strline = "unit\t";
25
                for (int i = 0 ; i < cols.length ; i++) {
26
                        strline += cols[i]+"\t"
27
                        
28
                }
29
                writer.println(strline.substring(0, strline.length()-1));
30
                
31
                def rows = lt.getRowNames().asStringsArray();
32
                for (int i = 0 ; i < rows.length ; i++) {
33
                        strline = "";
34
                        strline += rows[i]+"\t";
35
                        def line = lt.getRow(i).asIntArray();
36
                        for (int j = 0 ; j < line.length ; j++)
37
                                strline += line[j]+"\t";
38
                        writer.println(strline.substring(0, strline.length()-1));
39
                }
40
                
41
                writer.close();
42
                }
43
//        }
44
}