8 |
8 |
import org.txm.utils.logger.*
|
9 |
9 |
|
10 |
10 |
@Field @Option(name="metadataFile", usage="Tableau des metadonnées de sections", widget="FileOpen", required=true, def="")
|
11 |
|
File metadataFile;
|
|
11 |
File metadataFile;
|
12 |
12 |
|
13 |
13 |
@Field @Option(name="trsDirectory", usage="Dossier qui contient les fichiers TRS", widget="Folder", required=true, def="")
|
14 |
|
File trsDirectory;
|
|
14 |
File trsDirectory;
|
15 |
15 |
|
16 |
16 |
@Field @Option(name="joinTRSColumn", usage="Colonne de jointure de transcription", widget="String", required=true, def="Lien notice principale")
|
17 |
|
def joinTRSColumn
|
|
17 |
def joinTRSColumn
|
18 |
18 |
|
19 |
19 |
@Field @Option(name="startTimeColumn", usage="Colonne de timing de début de section", widget="String", required=true, def="antract_debut")
|
20 |
|
def startTimeColumn = "antract_debut"
|
|
20 |
def startTimeColumn = "antract_debut"
|
21 |
21 |
|
22 |
22 |
@Field @Option(name="endTimeColumn", usage="Colonne de timing de fin de section", widget="String", required=true, def="antract_fin")
|
23 |
|
def endTimeColumn = "antract_fin"
|
|
23 |
def endTimeColumn = "antract_fin"
|
24 |
24 |
|
25 |
25 |
@Field @Option(name="typeColumns", usage="Colonnes des métadonnées de type de section", widget="String", required=true, def="Titre propre")
|
26 |
|
def typeColumns
|
|
26 |
def typeColumns
|
27 |
27 |
|
28 |
28 |
@Field @Option(name="topicColumns", usage="Colonnes des métadonnées de topic de section", widget="String", required=true, def="Date de diffusion")
|
29 |
|
def topicColumns
|
|
29 |
def topicColumns
|
30 |
30 |
|
31 |
31 |
@Field @Option(name="metadataColumns", usage="Colonnes de metadonnées de section", widget="String", required=true, def="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.)")
|
32 |
|
def metadataColumns
|
|
32 |
def metadataColumns
|
33 |
33 |
|
34 |
34 |
@Field @Option(name="metadataColumnsGroups", usage="Colonnes des gruopes de metadonnées de section", widget="String", required=true, def="metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;secondary;secondary;secondary;secondary;secondary;secondary;secondary;text;text;text;text")
|
35 |
|
def metadataColumnsGroups
|
|
35 |
def metadataColumnsGroups
|
36 |
36 |
|
37 |
37 |
@Field @Option(name="debug", usage="show debug messages", widget="String", required=true, def="false")
|
38 |
|
def debug
|
|
38 |
def debug
|
39 |
39 |
|
40 |
40 |
if (!ParametersDialog.open(this)) return;
|
|
41 |
debug = "true".equals(debug);
|
|
42 |
|
41 |
43 |
typeColumns = typeColumns.split(";")
|
42 |
44 |
topicColumns = topicColumns.split(";")
|
43 |
45 |
metadataColumns = metadataColumns.split(";")
|
... | ... | |
163 |
165 |
|
164 |
166 |
ConsoleProgressBar cpb = new ConsoleProgressBar(sectionGroupsToInsert.keySet().size())
|
165 |
167 |
for (String id : sectionGroupsToInsert.keySet()) {
|
166 |
|
if (debug) println "== $id =="
|
167 |
|
else cpb.tick()
|
168 |
|
|
|
168 |
|
|
169 |
|
169 |
170 |
File trsFile = new File(trsDirectory, id+".trs")
|
170 |
171 |
if (!trsFile.exists()) {
|
|
172 |
cpb.tick()
|
171 |
173 |
continue
|
172 |
174 |
}
|
|
175 |
|
|
176 |
if (debug) println "== $id =="
|
|
177 |
else cpb.tick()
|
|
178 |
|
173 |
179 |
//println "Processing $id..."
|
174 |
180 |
def sections = sectionGroupsToInsert[id]
|
175 |
181 |
sections = sections.sort() { a, b -> a[0] <=> b[0] ?: a[1] <=> b[1] }
|
... | ... | |
198 |
204 |
def currentSection = null
|
199 |
205 |
def currentNode = null
|
200 |
206 |
|
201 |
|
for (def turn : turns) {
|
|
207 |
for (int iTurn = 0 ; iTurn < turns.size() ; iTurn++) {
|
|
208 |
|
|
209 |
def turn = turns[iTurn]
|
202 |
210 |
def start = Float.parseFloat(turn.@startTime)
|
203 |
211 |
def end = Float.parseFloat(turn.@endTime)
|
|
212 |
//println "Turn: $iTurn ($start, $end)"
|
204 |
213 |
|
205 |
214 |
def found = null;
|
206 |
215 |
for (int i = iSection ; i < sections.size() ; i++) {
|
... | ... | |
233 |
242 |
}
|
234 |
243 |
trsSection.remove(turn)
|
235 |
244 |
currentNode.append(turn)
|
|
245 |
|
|
246 |
|
|
247 |
if (found) {
|
|
248 |
def children = turn.children()
|
|
249 |
Node newTurnKaNode = null;//new Node(trsEpisode, "Turn", currentSection[2])
|
|
250 |
//println "Cut the last turn if necessary"
|
|
251 |
for (int iChildren = 0 ; iChildren < children.size() ; iChildren++) {
|
|
252 |
def c = children[iChildren]
|
|
253 |
if (newTurnKaNode != null) {
|
|
254 |
turn.remove(c)
|
|
255 |
newTurnKaNode.append(c)
|
|
256 |
if (debug) c.@moved="yes"
|
|
257 |
iChildren--
|
|
258 |
} else {
|
|
259 |
if ("w".equals(c.name())) {
|
|
260 |
def start2 = Float.parseFloat(c.@startTime)
|
|
261 |
def end2 = Float.parseFloat(c.@endTime)
|
|
262 |
|
|
263 |
if (start2 > sections[iSection][1] && Math.abs(start2 - sections[iSection][1]) > 0.1) {
|
|
264 |
if (debug) println "cut with w at [$start2, $end2] for section "+sections[iSection][1]
|
|
265 |
newTurnKaNode = new Node(trsSection, "Turn", ["startTime":""+start2, "endTime":""+turn.@endTime, "speaker":turn.@speaker])
|
|
266 |
if (debug) newTurnKaNode.@created = "yes"
|
|
267 |
turn.@endTime = ""+start2;
|
|
268 |
turn.remove(c)
|
|
269 |
newTurnKaNode.append(c)
|
|
270 |
if (debug) c.@moved="yes"
|
|
271 |
turns.add(iTurn+1, newTurnKaNode)
|
|
272 |
iChildren--
|
|
273 |
}
|
|
274 |
} else if ("Sync".equals(c.name())) {
|
|
275 |
def start2 = Float.parseFloat(c.@time)
|
|
276 |
def end2 = Float.parseFloat(c.@time)
|
|
277 |
|
|
278 |
if (start2 > sections[iSection][1] && Math.abs(start2 - sections[iSection][1]) > 0.1) {
|
|
279 |
if (debug) println "cut with Sync at [$start2, $end2] for section "+sections[iSection][1]
|
|
280 |
newTurnKaNode = new Node(trsSection, "Turn", ["startTime":""+start2, "endTime":""+turn.@endTime, "speaker":turn.@speaker])
|
|
281 |
if (debug) newTurnKaNode.@created = "yes"
|
|
282 |
turn.@endTime = ""+start2;
|
|
283 |
turn.remove(c)
|
|
284 |
if (debug) c.@moved="yes"
|
|
285 |
newTurnKaNode.append(c)
|
|
286 |
turns.add(iTurn+1, newTurnKaNode)
|
|
287 |
iChildren--
|
|
288 |
}
|
|
289 |
} else {
|
|
290 |
// no time to check
|
|
291 |
}
|
|
292 |
}
|
|
293 |
}
|
|
294 |
}
|
236 |
295 |
}
|
237 |
296 |
|
238 |
297 |
//remove the initial section
|