Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / scripts / filters / eliminateNAttributes / eliminateNAttributes.groovy @ 1000

History | View | Annotate | Download (2 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:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.scripts.filters.eliminateNAttributes;
29

    
30
import org.txm.importer.scripts.filters.*;
31

    
32
// TODO: Auto-generated Javadoc
33
/**
34
 * The Class eliminatingNAttributes.
35
 */
36
class eliminatingNAttributes extends Filter {
37
        
38
        /** The counter. */
39
        int counter;
40
        
41
        /** The old. */
42
        def old;
43

    
44
        /* (non-Javadoc)
45
         * @see org.txm.importer.filters.Filter#SetUsedParam(java.lang.Object)
46
         */
47
        void SetUsedParam(Object args) {
48

    
49
        }
50

    
51
        /* (non-Javadoc)
52
         * @see org.txm.importer.filters.Filter#before()
53
         */
54
        boolean before() {
55
                counter = 0;
56
        }
57

    
58
        /* (non-Javadoc)
59
         * @see org.txm.importer.filters.Filter#after()
60
         */
61
        void after()
62
        {
63
                println "Deleted $counter PART='N' attributes\n";
64
        }
65

    
66
        /* (non-Javadoc)
67
         * @see org.txm.importer.filters.Filter#filter()
68
         */
69
        void filter()
70
        {
71
                def m;
72
                def segment;
73
                // Write your code here, but don't forget to write in the output
74
                // ex : output.write("TheStringToWrite " + line );
75
                // in the var line is the current line
76
                old = line;
77
                line = (line =~ / part=["']N['"]/).replaceAll("");
78
                
79
                if( old != line)
80
                        counter++;
81
                
82
                output.write(line+lineSeparator);
83
                // End
84
        }
85
}