Statistics
| Revision:

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

History | View | Annotate | Download (2.7 kB)

1
/**
2
 * Main.
3
 *
4
 * @param args the args
5
 */
6
// Copyright © 2010-2013 ENS de Lyon.
7
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
8
// Lyon 2, University of Franche-Comté, University of Nice
9
// Sophia Antipolis, University of Paris 3.
10
// 
11
// The TXM platform is free software: you can redistribute it
12
// and/or modify it under the terms of the GNU General Public
13
// License as published by the Free Software Foundation,
14
// either version 2 of the License, or (at your option) any
15
// later version.
16
// 
17
// The TXM platform is distributed in the hope that it will be
18
// useful, but WITHOUT ANY WARRANTY; without even the implied
19
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20
// PURPOSE. See the GNU General Public License for more
21
// details.
22
// 
23
// You should have received a copy of the GNU General
24
// Public License along with the TXM platform. If not, see
25
// http://www.gnu.org/licenses.
26
// 
27
// 
28
// 
29
// $LastChangedDate: 2016-08-30 09:45:56 +0200 (mar. 30 août 2016) $
30
// $LastChangedRevision: 3283 $
31
// $LastChangedBy: mdecorde $ 
32
//
33
package org.txm.test
34

    
35
// imports des fonctions que l'on va utiliser
36
import org.txm.Toolbox
37
import org.txm.searchengine.cqp.corpus.*
38
import org.txm.searchengine.cqp.corpus.query.*
39
import org.txm.functions.index.*
40
// TODO: Auto-generated Javadoc
41

    
42
/* (non-Javadoc)
43
 * @see groovy.lang.Script#run()
44
 */
45
boolean manualInit = false
46
if(!org.txm.Toolbox.isInitialized())
47
{
48
        manualInit = true
49
        org.txm.Toolbox.initialize(new File(System.getProperty("user.home")+"/TXM/install.prefs"))
50
}
51
        // on récupère le corpus DISCOURS
52
        MainCorpus discours = CorpusManager.getCorpusManager().getCorpus("DISCOURS")
53
        Partition discours_dates = discours.createPartition( discours.getStructuralUnit("text"), discours.getStructuralUnit("text").getProperty("date"))
54
        println discours
55
        
56
        // on récupère ses propriétés
57
        Property pos = discours.getProperty("pos")
58
        Property word = discours.getProperty("word")
59
        
60
        // on créé une Query, ici "[]"
61
        Query query = new Query(Query.fixQuery("[word=\"j.*\"]"))
62
        
63
        List<Property> props = [pos,word]
64
        
65
        // on exécute la commande
66
        def time = System.currentTimeMillis()
67
        println(""+discours+"\t"+query+"\t"+props)
68
        IndexSample index = new IndexSample(discours_dates, query, props )
69
        println("execution time : "+(System.currentTimeMillis()-time)+" ms")
70
        
71
        //sort
72
        //index.sortLines(LineComparator.SortMode.FREQUNIT)
73
        
74
        //get some infos
75
        println("V : "+index.getV())
76
        println("T : "+index.getT())
77
        
78
        //filter
79
        index.filterLines(2,3000)
80
        println("V after: "+index.getV())
81
        println("T after: "+index.getT())
82
        
83
        //on écrit tout dans un fichier
84
        File file = new File("voc.txt")
85
        index.toTxt(file)
86
        println("index file : "+ file.getAbsolutePath())
87

    
88
        
89
if(manualInit)
90
        org.txm.Toolbox.shutdown()