Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / macro / projects / antract / PrepareAFVOIXOFFCorpusMacro.groovy @ 3082

History | View | Annotate | Download (3.5 kB)

1
package org.txm.macro.projects.antract
2

    
3
import org.txm.utils.io.IOUtils
4
import groovy.transform.Field
5
import org.txm.rcp.swt.widget.parameters.*
6

    
7
import org.txm.macro.transcription.*
8
import org.txm.utils.io.FileCopy
9
import org.txm.macro.projects.antract.BuildAFMetadataMacro
10
import org.txm.macro.projects.antract.BuildAFMetadataMacro
11

    
12
@Field @Option(name="tableFile", usage="Tableau des metadonnées de sections", widget="FileOpen", required=true, def="all.xlsx") // /home/mdecorde/TEMP/ANTRACT/AF/all.xlsx
13
File tableFile;
14

    
15
@Field @Option(name="trsDirectory", usage="Dossier qui contient les fichiers TRS à corriger", widget="Folder", required=true, def="AF")
16
def trsDirectory
17

    
18
@Field @Option(name="debug", usage="Show debug level messages", widget="Boolean", required=true, def="false")
19
def debug
20

    
21
if (!ParametersDialog.open(this)) return;
22

    
23
File workingDirectory = tableFile.getParentFile()
24

    
25
// extract infos for sujets and emissions from the main table file
26
gse.runMacro(BuildAFMetadataMacro, ["tableFile":tableFile, 
27
                                "buildSujetsMetadata": true,
28
                                "buildEmissionsMetadata": true])
29

    
30
File emissionsFile = new File(workingDirectory, "emissions.xlsx")
31
File sujetsFile = new File(workingDirectory, "sujets.xlsx")
32

    
33
// fix TRS files in the trsDirectory directory
34
gse.runMacro(FixINATRSMacro, ["trsDirectory":trsDirectory])
35

    
36
// insert the section in the TRS files
37
gse.runMacro(AddSectionsFromTableMacro, ["metadataFile": sujetsFile
38
        , "trsDirectory": trsDirectory
39
        , "joinTRSColumn": "Lien notice principale"
40
        , "startTimeColumn": "antract_debut"
41
        , "endTimeColumn": "antract_fin"
42
        , "typeColumns": "Titre propre"
43
        , "topicColumns": "Date de diffusion"
44
        , "metadataColumns": "id;Titre propre;Date de diffusion;Identifiant de la notice;Notes du titre;Type de date;Durée;Genre;Langue VO / VE;Nature de production;Producteurs (Aff.);Thématique;Nom fichier segmenté (info);antract_video;antract_debut;antract_fin;antract_duree;antract_tc_type;antract_tc_date;Résumé;Séquences;Descripteurs (Aff. Lig.);Générique (Aff. Lig.)"
45
        , "metadataColumnsGroups": "secondary;metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;secondary;secondary;secondary;secondary;secondary;secondary;secondary;text;text;text;text"
46
        , "debug":debug])
47

    
48
//copy the emissions file in the source directory
49
FileCopy.copy(emissionsFile, new File(new File(trsDirectory, "out"), "metadata.xlsx"))
50

    
51
File paramFile = new File(new File(trsDirectory, "out"), "parameters/CorpusCommandPreferences.prefs")
52
paramFile.getParentFile().mkdirs()
53

    
54
// create the corpus parameters file
55
String content = """backtomedia/backtomedia_endproperty=end
56
backtomedia/backtomedia_startproperty=start
57
backtomedia/backtomedia_structure=sp
58
backtomedia/backtomedia_time_property=time
59
backtomedia/media_auth=true
60
backtomedia/media_auth_login=
61
backtomedia/media_extension=mp4
62
backtomedia/media_path_prefix=https\\://{0}\\:{1}@okapi.ina.fr/antract/Media/AF/
63
backtomedia/name=backtomedia
64
backtomedia/sync_mode=Structure
65
concordance/context_limits=text
66
concordance/context_limits_type=list
67
concordance/view_reference_pattern={"format"\\:"%s, %s, %s","properties"\\:["text_date-de-diffusion-tri","u_time","div_identifiant-de-la-notice"]}
68
concordance/sort_reference_pattern={"format"\\:"","properties"\\:["text_date-de-diffusion-tri","u_time","div_identifiant-de-la-notice"]}
69
concordance/name=concordance
70
eclipse.preferences.version=1"""
71

    
72
IOUtils.write(paramFile, content);
73

    
74
//done \o/
75
println "Done: finalize the corpus using the "+new File(trsDirectory, "out")+" source directory and the XML-TRS import module."
76