Statistics
| Revision:

root / tmp / org.txm.core / src / groovy / filters / OneTagPerLine / OneTagPerLine.groovy @ 187

History | View | Annotate | Download (2.3 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 filters.OneTagPerLine;
29

    
30
//Pre-processing extra-word tags (1)
31
import org.txm.importer.filters.*;
32
import java.util.regex.*;
33
import org.txm.tokenizer.TokenizerClasses;
34

    
35
// TODO: Auto-generated Javadoc
36
/**
37
 * The Class OneTagPerLine.
38
 */
39
class OneTagPerLine extends Filter {
40
        
41
        /** The tag_all. */
42
        String tag_all = TokenizerClasses.tag_all;
43
        
44
        /** The counterreg1. */
45
        int counterreg1 = 0;
46
        
47
        /** The counterreg2. */
48
        int counterreg2 = 0;
49

    
50
        /* (non-Javadoc)
51
         * @see org.txm.importer.filters.Filter#SetUsedParam(java.lang.Object)
52
         */
53
        void SetUsedParam(Object args) {
54

    
55
        }
56

    
57
        /* (non-Javadoc)
58
         * @see org.txm.importer.filters.Filter#before()
59
         */
60
        boolean before() {
61

    
62
        }
63

    
64
        /* (non-Javadoc)
65
         * @see org.txm.importer.filters.Filter#after()
66
         */
67
        void after() {
68

    
69
        }
70

    
71
        /* (non-Javadoc)
72
         * @see org.txm.importer.filters.Filter#filter()
73
         */
74
        void filter()
75
        {
76
                def m;
77
                boolean firstTest = true;
78

    
79
                while(!(line ==~ /\A\s*\Z/))
80
                {
81
                        if (( m = line =~ /^([^<]+)(.*)$/) )// trucs(<balise>
82
                        {
83
                                if(firstTest)
84
                                {
85
                                        output.write(lineSeparator);
86
                                        firstTest=false;
87
                                }
88
                                output.write(m[0][1]);
89
                                line = m[0][2];
90
                        }
91
                        else if ((m = line =~ /^($tag_all)(.*)$/)) {//
92
                                firstTest=false;
93
                                output.write("\n"+m[0][1]);
94
                                line = m[0][2];
95
                        }
96
                        else
97
                        {
98
                                println "Error in "+ line;
99
                                line = " ";
100
                        }
101
                }
102
                // End
103
        }
104
}