Statistics
| Revision:

root / tmp / org.txm.index.core / groovy / org / txm / test / IndexSample.groovy @ 141

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 (Tue, 30 Aug 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.functions.index.Index
38
import org.txm.searchengine.cqp.corpus.*
39
import org.txm.searchengine.cqp.corpus.query.*
40

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

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

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

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

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

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

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

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

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