Statistics
| Revision:

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

History | View | Annotate | Download (2.2 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

    
34
package org.txm.test
35

    
36
// imports des fonctions que l'on va utiliser
37
import org.txm.Toolbox
38
import org.txm.index.core.functions.Index
39
import org.txm.searchengine.cqp.corpus.*
40
import org.txm.searchengine.cqp.corpus.query.*
41

    
42
// on récupère le corpus DISCOURS
43
MainCorpus discours = CorpusManager.getCorpusManager().getCorpus("BFM")
44
println discours
45

    
46
// on récupère ses propriétés
47
Property pos = discours.getProperty("ttpos")
48
Property word = discours.getProperty("word")
49

    
50
// on créé une Query, ici "[]"
51
Query query = new Query(Query.fixQuery("[word=\"je\"]"))
52

    
53
List<Property> props = [pos,word]
54

    
55
// on exécute la commande
56
def time = System.currentTimeMillis()
57
println(""+discours+"\t"+query+"\t"+props)
58
Index index = new Index(discours, query, props )
59
println("execution time : "+(System.currentTimeMillis()-time)+" ms")
60

    
61
//sort
62
//index.sortLines(LineComparator.SortMode.FREQUNIT)
63

    
64
//get some infos
65
println("V : "+index.getV())
66
println("T : "+index.getT())
67

    
68
//filter
69
index.filterLines(2,3000)
70
println("V after: "+index.getV())
71
println("T after: "+index.getT())
72

    
73
//on écrit tout dans un fichier
74
File file = new File("voc.txt")
75
index.toTxt(file, "'", "\t", "UTF-8")
76
println("index file : "+ file.getAbsolutePath())