Statistics
| Revision:

ccc / projets / CMC2ELAN / src / Main.groovy @ 2

History | View | Annotate | Download (1.7 kB)

1
File inputFile = new File("/home/mdecorde/xml/comere/ismael-textchat.xml")
2
File outputDir = new File("/home/mdecorde/xml/comere/forElan")
3
File splitDir = new File("/home/mdecorde/xml/comere/split")
4
File xsltfile = new File("/home/mdecorde/xsl/cmc2trs.xsl")
5

    
6
outputDir.deleteDir()
7
outputDir.mkdirs()
8
splitDir.deleteDir()
9
splitDir.mkdirs()
10

    
11
println "Split $inputFile per locutor"
12
XPathResult xpathProcessor = new XPathResult(inputFile);
13
def dates = xpathProcessor.getXpathResponses("//tei:dateline/tei:date/text()")
14
def locs = xpathProcessor.getXpathResponses("//tei:listPerson/tei:person/@xml:id")
15

    
16
dates = new HashSet(dates)
17
dates = new ArrayList(dates)
18
println dates.sort()
19
println locs
20

    
21
def p = new TEICMCPerLocPerDate(inputFile, splitDir)
22
println p.processDatesAndLocs(dates, locs)
23

    
24
def singleCMCFiles = splitDir.listFiles()
25
if (singleCMCFiles == null || singleCMCFiles.size() == 0) {
26
        println "no singleCMCFile produced by $inputFile"
27
        return;
28
}
29

    
30
println "Converting XML-TEI-CMC to XML-TRS from : "+splitDir
31
for (File singleCMCFile : singleCMCFiles) {
32
        println " Processing: "+singleCMCFile
33
        String name = singleCMCFile.getName();
34
        int idx = name.indexOf(".")
35
        if (idx > 0) name = name.substring(0, idx)
36

    
37
        File outputFile = new File(outputDir, name+"-brokentimes.trs")
38
        File outputFixedFile = new File(outputDir, name+".trs")
39

    
40

    
41
        XPathResult xpathProcessor2 = new XPathResult(singleCMCFile);
42
        def loc = xpathProcessor2.getXpathResponse("//tei:posting/@who")
43

    
44
        def p1 = new TEICMC2TRS(singleCMCFile, loc)
45
        def p2 = new FixMissingTimings(outputFile, outputFixedFile)
46

    
47
        if (p1.process(outputFile) && p2.process()) {
48
                outputFile.delete()
49
                println " Result saved in: $outputFixedFile"
50
        } else {
51
                println " Failed to convert $singleCMCFile to TRS"
52
        }
53
}