Statistics
| Revision:

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

History | View | Annotate | Download (1.4 kB)

1
package org.txm.test
2

    
3
println "Pre-balisage du discours direct"
4

    
5
List<String> containers = ["p","ab"]; // elements qui contiennent des <s>
6

    
7
File infile = new File(System.getProperty("user.home"), "TXM-SRC/quote-orig/perceval2.xml")
8
File outfile = new File(System.getProperty("user.home"), "TXM-SRC/quote-orig/perceval2-q.xml")
9

    
10
def doc = new XmlParser().parse (infile)
11
List<Node> nodesToInspect = doc.text.body.div
12
// nodesToInspect << doc.text.body.div // on en rajoute
13

    
14
/*************************/
15
new org.txm.importer.EncodeTEIQuotes(nodesToInspect, containers, "\"", "pon");
16

    
17
//copy the doc in "outfile" File  
18
String encoding = "UTF-8"
19
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(outfile) , encoding);
20
//writer.write("<?xml version=\"1.0\" encoding=\""+encoding+"\"?>");
21
//writer.write ("<?xml-stylesheet type=\"text/css\" href=\"tei-graal.css\"?>\n")
22
def pwriter = new PrintWriter(writer, true)
23
XmlNodePrinter xmlwriter = new XmlNodePrinter(pwriter)
24
xmlwriter.setPreserveWhitespace(false)
25
xmlwriter.print(doc)
26
pwriter.close()
27
writer.close()
28
xmlwriter = null
29
//println "write output file "+outfile
30

    
31
//update counts
32
if(outfile.exists())
33
{
34
        String txtid = org.txm.importer.WordCounter.findTextId(infile, "s"); // retrouve l'id du text qui a été concaténé aux id des S originels (ex : s19_12 >> 19)
35
        new org.txm.importer.WordCounter(outfile, "s", txtid);
36
        new org.txm.importer.WordCounter(outfile, "q", txtid);
37
}