Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / test / CooccurencesAndReferenceCorpus.groovy @ 479

History | View | Annotate | Download (2.3 kB)

1
package org.txm.test
2
import org.txm.Toolbox
3
import org.txm.searchengine.cqp.corpus.*
4
import org.txm.searchengine.cqp.corpus.query.*
5
import org.txm.cooccurrence.core.functions.Cooccurrence
6
import org.txm.cooccurrence.core.functions.comparators.OccComparator
7
import org.txm.functions.cooccurrences.*
8
import org.txm.statsengine.r.core.RWorkspace;
9
import org.txm.stat.engine.r.data.*;
10
import org.txm.functions.cooccurrences.comparators.*;
11

    
12
/////////////////PARAMS/////////////////////
13

    
14
def corpusname = "DANS16FRANTEXT"
15
def PROP = "word"
16
def QUERY ="""
17
[type="expFound"]
18
"""
19

    
20
def minleft = 0
21
def maxleft = 10
22
def minright = 0
23
def maxright = 10
24

    
25
def minf = 1
26
def mincof = 1
27
def minscore = 0
28

    
29
File refFile = new File("/home/mdecorde/TEMP/lexiqueFrantext16.txt");
30
def file = new File("/home/mdecorde/TEMP/cooc_dans_ref.tsv")
31

    
32
///////////////////////////////////////////
33

    
34
minleft++
35
maxleft++
36
minright++
37
maxright++
38
if (!refFile.exists()) { println "ref file does not exists: $refFile"; return;}
39
QUERY = QUERY.trim();
40
MainCorpus corpus = CorpusManager.getCorpusManager().getCorpus(corpusname)
41
Property property = corpus.getProperty(PROP)
42

    
43
// Build the reference corpus
44
println "building reference corpus."
45
def ref_lt = LexicalTableImpl.createLexicalTableImpl(refFile);
46

    
47
// Build the cooccurrences
48
def limit = null
49
def query = new Query(Query.fixQuery(QUERY))
50
print "building cooc"
51
def cooccurrence = new Cooccurrence(corpus, query, [property], limit, maxleft, minleft, minright, maxright, minf, mincof, minscore, false)
52
System.out.println("cooc: "+corpus+" "+query+" "+[property]+" "+null+" "+maxleft+" "+minleft+" "+minright+" "+maxright+" "+minf+" "+mincof+" "+minscore+" "+false);
53
print "."
54
if (refFile != null)
55
        cooccurrence.setReferenceCorpus(ref_lt.getSymbol()) // SET THE REFERENCE CORPUS
56
print "."
57
cooccurrence.stepQueryLimits();
58
print "."
59
cooccurrence.stepGetMatches();
60
print "."
61
cooccurrence.stepBuildSignatures();
62
print "."
63
cooccurrence.stepCount();
64
print "."
65
cooccurrence.stepBuildLexicalTable();
66
print "."
67
cooccurrence.stepGetScores();
68
print "."
69
cooccurrence.getLines();
70
cooccurrence.sort(new OccComparator())
71
println ""
72

    
73
println "exporting."
74
cooccurrence.toTxt(file, "UTF-8", "\t", "")
75
println "printed cooccurrents in "+file.getAbsolutePath()