-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextendmoviescript.m
More file actions
executable file
·57 lines (55 loc) · 2.15 KB
/
extendmoviescript.m
File metadata and controls
executable file
·57 lines (55 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function extendmoviescript(scrfname,extfname,results_folder)
scrfname=fullfile([results_folder '/' scrfname]);
extfname=fullfile([results_folder '/' extfname]);
mscr=loadmoviescript(scrfname);
for i=1:length(mscr.items)
if (strcmp(mscr.items(i).tagname,'description') | strcmp(mscr.items(i).tagname,'monologue')) & isequal(mscr.items(i).end_time,[0 0 0]')==0
mscr.items(mscr.dind(mscr.dind<i))=arrayfun(@(x) setfield(x,'end_time',mscr.items(i).begin_time),mscr.items(mscr.dind(mscr.dind<i)));
mscr.items(mscr.dind(mscr.dind<i))=arrayfun(@(x) setfield(x,'ascore',mscr.items(i).ascore),mscr.items(mscr.dind(mscr.dind<i)));
break;
end
end
for i=1:length(mscr.items)
if strcmp(mscr.items(i).tagname,'speaker')
for j=i:length(mscr.items)
if strcmp(mscr.items(j).tagname,'monologue')
mscr.items(i).begin_time=mscr.items(j).begin_time;
mscr.items(i).end_time=mscr.items(j).end_time;
mscr.items(i).ascore=mscr.items(j).ascore;
break;
end
end
end
if strcmp(mscr.items(i).tagname,'scene')
flag_first=0;
for j=i:length(mscr.items)
if isequal(mscr.items(j).end_time,[-1 -1 -1])==0 & isequal(mscr.items(j).end_time,[0 0 0]')==0
if flag_first==0
mscr.items(i).begin_time=mscr.items(j).begin_time;
mscr.items(i).ascore=mscr.items(j).ascore;
flag_first=1;
end
mscr.items(i).end_time=mscr.items(j).end_time;
end
if flag_first==1 & strcmp(mscr.items(j).tagname,'scene')
break;
end
end
end
if strcmp(mscr.items(i).tagname,'unknown')
for j=i:length(mscr.items)
if isequal(mscr.items(j).end_time,[-1 -1 -1])==0 & isequal(mscr.items(j).end_time,[0 0 0]')==0
mscr.items(i).begin_time=mscr.items(j).begin_time;
mscr.items(i).end_time=mscr.items(j).end_time;
mscr.items(i).ascore=mscr.items(j).ascore;
break;
end
end
end
end
if isequal(mscr.items(end).end_time,[0 0 0]') | isequal(mscr.items(end).end_time,[-1 -1 -1])
mscr.items(end).begin_time=mscr.items(end-1).begin_time;
mscr.items(end).end_time=mscr.items(end-1).end_time;
end
savemoviescript(mscr,extfname);
end