yaz/commit
store reconciled tags
author | Michiel Hildebrand |
---|---|
Sun Jul 10 18:00:41 2011 +0200 | |
committer | Michiel Hildebrand |
Sun Jul 10 18:00:41 2011 +0200 | |
commit | 3dd83db3d5dc8e7fc56334544cfc97798019a336 |
tree | 4b04c20058fba3f32a4335a6a97e21d01533f474 |
parent | 054114b394f6ae68638496f1f35fb085e94175c1 |
Diff style: patch stat
diff --git a/api/reconcile.pl b/api/reconcile.pl index f99e16c..a91aba7 100644 --- a/api/reconcile.pl +++ b/api/reconcile.pl @@ -96,7 +96,7 @@ reply(Callback, JSON) :- reconcile_list([], _, _, _, []). reconcile_list([Key=json(Obj)|Ts], Max, Type, Properties, [Key=json([result=Results])|Rs]) :- - memberchk([query=Query], Obj), + memberchk(query=Query, Obj), reconcile(Query, Max, Type, Properties, Hits), hits_to_json_results(Hits, Results), reconcile_list(Ts, Max, Type, Properties, Rs). @@ -172,7 +172,7 @@ type_filter_([Type|Ts], R) :- ). property_filter([], _). -property_filter([P-V|Ps], R) :- +property_filter([json([P=V])|Ps], R) :- rdf_has(R, P, V), property_filter(Ps, R). @@ -186,19 +186,39 @@ hits_to_json_results([], []). hits_to_json_results([Hit|Hs], [Result|Rs]) :- Hit = hit(Distance,URI,_Property,Label), type_list(URI, Types), + skos_desc(URI, Desc), Result = json([id=URI, name=Label, type=Types, + desc=Desc, score=Distance, match=false % we're not certain ]), hits_to_json_results(Hs, Rs). type_list(URI, Types) :- - findall(T, rdf(URI, rdf:type, T), Ts0), + findall(T, concept_type(URI,T), Ts0), sort(Ts0, Ts), resource_json_object(Ts, Types). +concept_type(URI, Type) :- + rdf(URI, skos:inScheme, 'http://purl.org/vocabularies/cornetto'), + rdf(URI, cornetto:hasHyperonym, Type), + !. +concept_type(URI, Scheme) :- + rdf(URI, skos:inScheme, gtaa:'GTAA'), + !, + rdf(URI, skos:inScheme, Scheme), + \+ rdf_equal(Scheme, gtaa:'GTAA'). +concept_type(URI, Type) :- + rdf(URI, rdf:type, Type). + +skos_desc(URI, Desc) :- + ( rdf_has(URI, skos:scopeNote, Desc0) + -> literal_text(Desc0, Desc) + ; Desc = '' + ). + resource_json_object([], []). resource_json_object([R|Rs], [JSONObj|Os]) :- JSONObj = json([id(R), name(Label)]), diff --git a/applications/yaz_garden.pl b/applications/yaz_garden.pl index dba14e9..dc669a3 100644 --- a/applications/yaz_garden.pl +++ b/applications/yaz_garden.pl @@ -34,8 +34,15 @@ reconcile_source(cornetto, 'Cornetto', Server, - '') :- + '&type=http://purl.org/vocabularies/cornetto/Synset') :- http_location_by_id(http_reconcile, Server). +reconcile_source(gtaa, + 'GTAA', + Server, + Params) :- + http_location_by_id(http_reconcile, Server), + www_form_encode('[{"http://www.w3.org/2004/02/skos/core#inScheme":"http://data.beeldengeluid.nl/gtaa/GTAA"}]',Ps), + atom_concat('&properties=',Ps,Params). reconcile_source(geogname, 'Geonames', 'http://api.kasabi.com/api/reconciliation-api-geonames', @@ -223,7 +230,7 @@ html_video_page_yui(Video, Annotations, Groups, ReconcileSources, Options) --> js_tag_select --> js_function([e], - \[ + \['console.log(e);\n', ' var tag = e.tag, uri = tag.tag.value, entry = tag.annotations[0], @@ -231,7 +238,8 @@ js_tag_select --> reconciled = Y.reconciled;\n', ' videoPlayer.setTime(time, true); videoFrames.set("frames", tag.annotations);\n', -' var items = (reconciled&&reconciled[uri]) ? reconciled[uri].result : []; +' Y.currentTagNode = e.li; + var items = (reconciled&&reconciled[uri]) ? reconciled[uri].result : []; tagLinker.set("items", items);' ]). @@ -277,8 +285,12 @@ js_apply_select(Video) --> { data: {video:"',Video,'", uri:o.item.id, entries:entries - }, - on: { success: function(e) {console.log(e)}}, + },\n', +' on: { success: function(e,o) { + Y.currentTagNode.one(".score").setContent("c"); + var annotations = Y.JSON.parse(o.responseText); + videoFrames.set("frames", annotations); + }}, });\n' ]). @@ -310,8 +322,13 @@ http_data_reconcile_entries(Request) :- reply_json(Updated). reconcile_entries([], _, []). -reconcile_entries([Entry|Es], URI, [json([entry=Entry, tag=NewTag])|Rest]) :- - reconcile_entry(Entry, URI, NewTag), +reconcile_entries([Entry|Es], URI, [json([entry=Entry, tag=NewTag, startTime=Time])|Rest]) :- + reconcile_entry(Entry, URI), + NewTag = json([value=URI, label=Label]), + rdf(Entry, pprime:videoPlayhead, Time0), + literal_to_number(Time0, Time), + rdf_display_label(URI, Label), reconcile_entries(Es, URI, Rest). -reconcile_entry(_E, URI, URI). +reconcile_entry(Entry, URI) :- + rdf_assert(Entry, pprime:reconciled, URI). diff --git a/config-available/yaz.pl b/config-available/yaz.pl index 8a879fc..cf55769 100644 --- a/config-available/yaz.pl +++ b/config-available/yaz.pl @@ -35,13 +35,13 @@ :- use_module(applications(yaz_game)). :- use_module(applications(yaz_player)). :- use_module(applications(yaz_fplayer)). -:- use_module(applications(yaz_game_recap)). -:- use_module(applications(yaz_tag_garden)). -:- use_module(applications(yaz_sgarden)). -:- use_module(applications(yaz_mgarden)). -:- use_module(applications(yaz_cgarden)). +%:- use_module(applications(yaz_game_recap)). +%:- use_module(applications(yaz_tag_garden)). +%:- use_module(applications(yaz_sgarden)). +%:- use_module(applications(yaz_mgarden)). +:- use_module(applications(yaz_garden)). :- use_module(applications(yaz_video_stats)). -:- use_module(applications(yaz_new_user)). +%:- use_module(applications(yaz_new_user)). % http path and handlers http:location(yaz, cliopatria(yaz), []). diff --git a/web/css/garden.css b/web/css/garden.css index b1cc10c..582e95b 100644 --- a/web/css/garden.css +++ b/web/css/garden.css @@ -169,6 +169,11 @@ .yui3-tag-linker li .type { padding: 0 2px; } +.yui3-tag-linker li .desc { + padding-left: 20px; + font-size: 95%; + color: #888; +} .yui3-tag-linker .controls { border-top: 1px solid #CCCCCC; padding-top: 2px; diff --git a/web/js/tagplayer/tagLinker.js b/web/js/tagplayer/tagLinker.js index 7243e7a..3e726a4 100644 --- a/web/js/tagplayer/tagLinker.js +++ b/web/js/tagplayer/tagLinker.js @@ -99,8 +99,11 @@ YUI.add('tag-linker', function(Y) { html += "<div class='types'>"; for (var i=0; i < types.length; i++) { html += "<span class='type'>"+types[i].name+"</span>"; - }; + } html += "</div>"; + if(item.desc) { + html += "<div class='desc'>"+item.desc+"</div>"; + } return html; } })