Révision 3
projets/CMC2ELAN/src/test/TRS2EAF.java (revision 3) | ||
---|---|---|
1 |
package test; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
import java.util.Vector; |
|
6 |
|
|
7 |
import mpi.eudico.client.annotator.SaveAs27Preferences; |
|
8 |
import mpi.eudico.server.corpora.clom.Transcription; |
|
9 |
import mpi.eudico.server.corpora.clom.TranscriptionStore; |
|
10 |
import mpi.eudico.server.corpora.clomimpl.abstr.TierImpl; |
|
11 |
import mpi.eudico.server.corpora.clomimpl.abstr.TranscriptionImpl; |
|
12 |
import mpi.eudico.server.corpora.clomimpl.dobes.ACMTranscriptionStore; |
|
13 |
|
|
14 |
public class TRS2EAF { |
|
15 |
|
|
16 |
public static boolean convert(String path, String outpath) { |
|
17 |
try { |
|
18 |
Transcription transcription = new TranscriptionImpl(new File(path).getAbsolutePath()); |
|
19 |
transcription.setChanged(); |
|
20 |
|
|
21 |
TranscriptionStore eafTranscriptionStore = ACMTranscriptionStore.getCurrentTranscriptionStore(); |
|
22 |
int saveAsType = SaveAs27Preferences.saveAsType(transcription); |
|
23 |
|
|
24 |
// for the moment, don't deal with visible tiers |
|
25 |
try { |
|
26 |
eafTranscriptionStore.storeTranscription(transcription, null, new Vector<TierImpl>(0), outpath, |
|
27 |
saveAsType); |
|
28 |
transcription.setUnchanged(); |
|
29 |
} catch (IOException ioe) { |
|
30 |
ioe.printStackTrace(); |
|
31 |
} |
|
32 |
|
|
33 |
} catch (Exception e) { |
|
34 |
e.printStackTrace(); |
|
35 |
return false; |
|
36 |
} |
|
37 |
return true; |
|
38 |
} |
|
39 |
public static void main(String[] args) { |
|
40 |
File trsDir = new File("/home/mdecorde/xml/comere/forElan"); |
|
41 |
File outDir = new File("/home/mdecorde/xml/comere/EAFforElan"); |
|
42 |
outDir.mkdir(); |
|
43 |
|
|
44 |
System.out.println("Start converting..."); |
|
45 |
for (File f : trsDir.listFiles()) { |
|
46 |
if (!f.getName().endsWith(".trs")) continue; |
|
47 |
System.out.println("Converting "+f); |
|
48 |
TRS2EAF.convert(f.getAbsolutePath(), outDir +"/"+ f.getName()+".eaf"); |
|
49 |
} |
|
50 |
System.out.println("Done."); |
|
51 |
} |
|
52 |
} |
Formats disponibles : Unified diff