Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / scripts / RegexCounter.groovy @ 479

History | View | Annotate | Download (1.5 kB)

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

    
31
/**
32
 * TODO.
33
 *
34
 * @param sourcedir the sourcedir
35
 * @param regex the regex
36
 * @author mdecorde
37
 */
38
class RegexCounter {
39
        public RegexCounter(File sourcedir, String encoding, String regex)
40
        {
41
                String text = sourcedir.getText(encoding);
42
                java.util.regex.Matcher m = text =~ regex;
43
                println m.count;
44
        }
45
        
46
        public static void main(String[] args) {
47
                new RegexCounter(new File("/home/mdecorde/xml/discours/01_DeGaulle.cnr"), "UTF-8", "je")
48
        }
49
}