Commit bd743749 by Alex Baines

hmmlib-js: multiple guests/annotators/co-hosts update

parent f23eceac
......@@ -3,19 +3,16 @@ function HMML_parse(contents) {
var state = {
line: 0,
annos: [],
meta: {},
meta: {
annotators: [],
guests: [],
co_hosts: []
},
an: {
line: 0,
time: "",
text: "",
author: "",
references: [],
markers: [],
quote: {
id: 0,
author: ""
},
is_quote: false
},
ref: {},
first: true
......@@ -27,13 +24,6 @@ function HMML_parse(contents) {
do {
r = l.next();
} while (!r);
state.annos.forEach(function(a) {
if (!a.is_quote) {
delete a.quote;
}
if (a.author === "") delete a.author;
delete a.is_quote;
});
return {
metadata: state.meta,
annotations: state.annos
......
......@@ -49,16 +49,9 @@
if(!yy.first) yy.annos.push(yy.an);
yy.an = {
line: yy.line,
time: "",
text: "",
author: "",
references: [],
markers: [],
quote: {
id: 0,
author: ""
},
is_quote: false
};
yy.an.line = yy.line;
yy.first = false;
......@@ -82,6 +75,7 @@ RB \]
%s VIDEO
%s V_ATTR
%s V2_ATTR
%s ANNOTATION
%s TEXT_START
%s TEXT
......@@ -110,9 +104,9 @@ RB \]
<VIDEO>title{S}\= { yy.attr = "title"; yy_.begin("V_ATTR"); }
<VIDEO>vod_platform{S}\= { yy.attr = "vod_platform"; yy_.begin("V_ATTR"); }
<VIDEO>id{S}\= { yy.attr = "id"; yy_.begin("V_ATTR"); }
<VIDEO>co_host{S}\= { yy.attr = "co_host" yy_.begin("V_ATTR"); }
<VIDEO>guest{S}\= { yy.attr = "guest" yy_.begin("V_ATTR"); }
<VIDEO>annotator{S}\= { yy.attr = "annotator"; yy_.begin("V_ATTR"); }
<VIDEO>co\-host{S}\= { yy.attr = "co_hosts" yy_.begin("V2_ATTR"); }
<VIDEO>guest{S}\= { yy.attr = "guests" yy_.begin("V2_ATTR"); }
<VIDEO>annotator{S}\= { yy.attr = "annotators"; yy_.begin("V2_ATTR"); }
<VIDEO>\] { yy_.begin("ANNOTATION"); };
<VIDEO>. { ERR(yy, "Invalid char '"+ yytext +"' in video tag."); }
......@@ -121,6 +115,11 @@ RB \]
<V_ATTR>{ATTR_QUOTED} { yy.meta[yy.attr] = UNQUOTE(yy, yytext.substr(1, yyleng-2)); yy_.begin("VIDEO"); }
<V_ATTR>\] { yy_.less(0); yy_.begin("VIDEO"); }
<V2_ATTR>{SP} { yy_.begin("VIDEO"); }
<V2_ATTR>{ATTR_SIMPLE} { yy.meta[yy.attr].push(yytext); yy_.begin("VIDEO"); }
<V2_ATTR>{ATTR_QUOTED} { yy.meta[yy.attr].push(UNQUOTE(yy, yytext.substr(1, yyleng-2))); yy_.begin("VIDEO"); }
<V2_ATTR>\] { yy_.less(0); yy_.begin("VIDEO"); }
<ANNOTATION>\[\/video\] { NEWANNO(yy); return 1; }
<ANNOTATION>{TIMECODE}{LB}\@ { NEWANNO(yy); yy.an.time = yytext.substr(1, yyleng-4); yy_.begin("AUTHOR"); }
<ANNOTATION>{TIMECODE} { NEWANNO(yy); yy.an.time = yytext.substr(1, yyleng-2); yy_.begin("TEXT_START"); }
......@@ -203,7 +202,7 @@ RB \]
<CATEGORIES>. { ERR(yy, "Unexpected character in category tag: " + yytext); }
<QUOTES>{SP} {}
<QUOTES>[0-9]+{S}\] { yy.an.is_quote = true; yy.an.quote.id = parseInt(yytext); yy_.begin("ANNOTATION"); }
<QUOTES>[0-9]+{S}\] { yy.an.quote = { author: "", id: parseInt(yytext) }; yy_.begin("ANNOTATION"); }
<QUOTES>{ATTR_ALNUM} { yy.an.quote.author += yytext; }
<QUOTES>. { ERR(yy, "Unexpected character in quotes tag: " + yytext); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment