yaz/commit
reconcile directly in page request
author | Michiel Hildebrand |
---|---|
Wed Feb 9 19:59:05 2011 +0100 | |
committer | Michiel Hildebrand |
Wed Feb 9 19:59:05 2011 +0100 | |
commit | a8508b163f37f1a453db491fda0eac4090069d35 |
tree | 6494b889aabee3b4ec44453e15922da509bbf990 |
parent | 3053d0946a9072e08ed07345c3761ca9f5c0d5d7 |
Diff style: patch stat
diff --git a/applications/yaz_cgarden.pl b/applications/yaz_cgarden.pl index e473956..452c684 100644 --- a/applications/yaz_cgarden.pl +++ b/applications/yaz_cgarden.pl @@ -68,56 +68,53 @@ http_yaz_cgarden(Request) :- user(User), interval(Interval) ], - create_user_process(CurrentUser, [rdf:type=pprime:'mgarden', + create_user_process(CurrentUser, [rdf:type=pprime:'cgarden', opmv:used=Video - ], _Process), + ], _GardenProcess), video_annotations(Video, As0, Options), sort_by_arg(As0, 2, As), + rdf_equal(skos:inScheme,Inscheme), + rdf_equal(gtaa:'GTAA',GTAA), + link_tags_to_concepts(As, [Inscheme-GTAA], Annotations), + html_video_page(Process, Video, CurrentUser, Annotations, 0, Options). - tag_matches(As, User, Process, Interval, Annotations), - html_video_page(Video, CurrentUser, Annotations, 0, Options). - -%% link_to_concept(+Annotations, -Annotations1) +%% link_tags_to_concepts(+Annotations, -Annotations1) % % Add candidate concepts. -link_to_concepts([A0|As], [A|Rest]) :- - A0 = annotation(Value,Start,End,Entries), - A = annotation(Value,Start,End,Entries,Concepts), - reconcile(Value, 5, _, [], Hits), +link_tags_to_concepts([], _, []). +link_tags_to_concepts([A0|As], Ps, [A|Rest]) :- + A0 = annotation(literal(Tag),Start,End,Entries), + A = annotation(literal(Tag),Start,End,Entries,Score,Concepts), + yaz_mgarden:tag_score(Entries, Score), + ( reconcile(Tag, 3, [], Ps, Hits) + -> maplist(hit_concept, Hits, Concepts) + ; Concepts = [] + ), maplist(hit_concept, Hits, Concepts), - link_to_concepts(As, Rest). - -hit_concept(hit(_,C,_,_), C). + link_tags_to_concepts(As, Ps, Rest). - -tag_matches([], _, _, _, []). -tag_matches([A0|As], User, Process, Interval, [A|Rest]) :- - A0 = annotation(Value,Start,End,Entries), - A = annotation(Value,Start,End,Entries,Match), - ( existing_match(Entries, Match) +hit_concept(hit(_,URI,_,Label), concept(URI,Label,Alt,Desc)) :- + ( rdf_has(URI, rdfs:label, Lit), + literal_text(Lit, Alt), + \+ Alt == Label -> true - ; Match = @false + ; Alt = '' ), - tag_matches(As, User, Process, Interval, Rest). -%tag_matches([_|As], User, Process, Interval, Rest) :- -% tag_matches(As, User, Process, Interval, Rest). - -existing_match(Entries, Match) :- - findall(S, (member(i(E,_), Entries), - rdf(E, pprime:score, literal(S)) - ), - Ss), - max_list(Ss, Score), - Match = match(exact, Score). + ( rdf_has(URI,skos:scopeNote,Txt) + -> literal_text(Txt,Desc) + ; rdf_has(URI, skos:definition,Txt) + -> literal_text(Txt,Desc) + ; Desc = '' + ). -%% html_video_page(+Video, +User, +Annotations, +StartTime, +%% html_video_page(+Game, +Video, +User, +Annotations, +StartTime, %% +Options) % % Emit an HTML page with a video player and a tag carousel. -html_video_page(Video, User, Annotations, StartTime, Options) :- +html_video_page(Game, Video, User, Annotations, StartTime, Options) :- reply_html_page(yaz, [ title(['YAZ - ', Video]) ], @@ -126,7 +123,7 @@ html_video_page(Video, User, Annotations, StartTime, Options) :- div(class('video-results'), \html_video_page_containers(Video, Options)), script(type('text/javascript'), - \html_video_page_yui(Video, User, Annotations, StartTime, Options)) + \html_video_page_yui(Game, Video, User, Annotations, StartTime, Options)) ]). html_video_page_containers(Video, _Options) --> @@ -139,13 +136,13 @@ html_video_page_containers(Video, _Options) --> ]) ]). -html_video_page_yui(Video, User, Annotations, StartTime, _Options) --> +html_video_page_yui(Game, Video, User, Annotations, StartTime, _Options) --> { video_source(Video, Src), http_absolute_location(js('videoplayer/'), FilePath, []), http_absolute_location(js('videoplayer/videoplayer.js'), VideoPlayer, []), http_absolute_location(js('tagcarousel/tagcarousel.js'), TagCarousel, []), %setting(request_interval, RequestInterval), - http_location_by_id(http_reconcile, ReconcileServer), + %http_location_by_id(http_reconcile, ReconcileServer), annotation_to_json(Annotations, JSONTags) }, html_requires(js('videoplayer/swfobject.js')), @@ -171,26 +168,29 @@ html_video_page_yui(Video, User, Annotations, StartTime, _Options) --> 'Y.mazzle.TagCarousel'({tags:JSONTags, height:480, width:200, - info:true + concept:symbol(true), + topIndent:symbol(false) + %info:true })), 'var oldTime;\n', \js_call('videoPlayer.render'('#videoplayer')), \js_call('tagCarousel.render'('#tagplayer')), - \js_yui3_on(tagCarousel, itemSelect, \js_tag_select), + %\js_yui3_on(tagCarousel, itemSelect, \js_tag_select), \js_yui3_on(tagCarousel, itemConfirm, \js_confirm(User)), - \js_support_functions(User), + \js_support_functions(Game, User) %\js_call('tagCarousel.reconcile'('http://standard-reconcile.freebaseapps.com/reconcile')) - \js_call('tagCarousel.reconcile'(ReconcileServer)) + %\js_call('tagCarousel.reconcile'(ReconcileServer)) /*\js_call('Y.later'(RequestInterval, symbol('Y'), symbol(fetchData), symbol({}), symbol(true)))*/ ]). -js_support_functions(User) --> - { http_location_by_id(http_yaz_api_mgarden_data, DataServer) +js_support_functions(Game, User) --> + { http_location_by_id(http_yaz_api_cgarden_data, DataServer) }, - js_function_decl(fetchData, [], + js_function_decl(fetchData, [e], \[ -' var data = {user:"',User,'"}; +' var data = {user:"',User,'", + game:"',Game,'"}; Y.io("',DataServer,'", {data: data, on: {success:handleResponse} });\n' diff --git a/lib/yaz_util.pl b/lib/yaz_util.pl index 180aa8e..090f30f 100644 --- a/lib/yaz_util.pl +++ b/lib/yaz_util.pl @@ -337,7 +337,8 @@ http:convert_parameter(jsonresource, Atom, Term) :- annotation(tag:_, startTime:number, endTime:number, annotations:list), annotation(tag:_, startTime:number, endTime:number, annotations:list, score:number, match:_), match(type:atom, score:_), - match(type:atom, score:_, uri:_, value:_). + match(type:atom, score:_, uri:_, value:_), + concept(uri:_, label:atom, altlabel:atom, desc:atom). diff --git a/web/js/tagcarousel/tagcarousel.js b/web/js/tagcarousel/tagcarousel.js index 574f765..aa4135f 100644 --- a/web/js/tagcarousel/tagcarousel.js +++ b/web/js/tagcarousel/tagcarousel.js @@ -43,6 +43,9 @@ YUI.add('tag-carousel', function(Y) { confirm: { value: false }, + concept: { + value: false + }, suggest: { value: null }, @@ -177,6 +180,20 @@ YUI.add('tag-carousel', function(Y) { +'</div></div>'; } } + if(this.get("concept")&&(match&&Lang.isArray(match))) { + for (var i=0; i < match.length; i++) { + var concept = match[i], + altlabel = concept.altlabel?concept.altlabel:'', + desc = concept.desc?concept.desc:''; + html += '<div class="match">' + +'<div class="label" title="'+desc+'">' + +concept.label+' '+altlabel+'</div>' + +'<div class="score hidden"></div>' + +'<div class="confirm" title="'+i+'">' + +'<a class="accept" href="javascript:{}"></a>' + +'</div></div>'; + } + } if(item.uri) { return '<a href="javascript:{}">'+html+'</a>';