vumix/commit
fix linking
author | Michiel Hildebrand |
---|---|
Tue May 8 01:52:07 2012 +0200 | |
committer | Michiel Hildebrand |
Tue May 8 01:52:07 2012 +0200 | |
commit | d18adbefc84fdba9d4ec12d30e58cdddf02b5271 |
tree | 4754f823c0af759324e2db2c9cd941176832e059 |
parent | ed2166fd17c3cf97674960f79dc571276d3cbdd2 |
Diff style: patch stat
diff --git a/lib/beng_xml.pl b/lib/beng_xml.pl index 064aba1..8f930e9 100644 --- a/lib/beng_xml.pl +++ b/lib/beng_xml.pl @@ -20,17 +20,39 @@ reeks('357006'). reeks('357007'). +beng_stats(WaisdaTaggedFragments) :- + findall(R, reeks(R), Reeksen), + maplist(beng_selections, Reeksen, Expressies0), + append(Expressies0, Expressies), + findall(S, (member(expressie(_,_,Ss),Expressies), member(S,Ss)), Selecties), + link_beng_waisda(Expressies, WaisdaFragments0), + keysort(WaisdaFragments0, WaisdaFragments), + filter_waisda_tags(WaisdaFragments, WaisdaTaggedFragments), + + length(Expressies, ExpressieCount), + length(Selecties, SelectieCount), + length(WaisdaFragments, WaisdaFragmentCount), + length(WaisdaTaggedFragments, WaisdaTaggedFragmentCount), + format('expressies, ~w~n', [ExpressieCount]), + format('selecties, ~w~n', [SelectieCount]), + format('waisda fragments, ~w~n', [WaisdaFragmentCount]), + format('waisda tagged fragments, ~w~n', [WaisdaTaggedFragmentCount]). + beng_waisda(Pairs) :- findall(R, reeks(R), Reeksen), maplist(beng_selections, Reeksen, Selections), - maplist(link_beng_waisda, Selections, Linked), - flatten(Linked, Pairs). + %maplist(link_beng_waisda, Selections, Linked), + flatten(Selections, Pairs). + %flatten(Linked, Pairs). filter_waisda_tags([], []). filter_waisda_tags([F-S|T], [F-S|Rest]) :- - number(F), - atom_number(FA, F), - rdf(_Video, dc:id, literal(FA)), + %number(F), + %atom_number(FA, F), + rdf(Video, dc:id, literal(F)), + findall(E,rdf(Video, pprime:hasAnnotation, E),Es), + length(Es,Count), + Count > 100, !, filter_waisda_tags(T, Rest). filter_waisda_tags([_|T], Rest) :- @@ -47,7 +69,7 @@ assert_beng_selections :- assert_expressies([expressie(Dir,Date,Selections)|T]) :- */ -%% link_beng_waisda(+Expressies, [Fragment-Selection]) +%% link_beng_waisda(+Expressies, -list([Fragment-Selection])) % % we assume that sorting on the ids of the fragments and the % filenames of Selections provides the right order. Thus, the @@ -62,20 +84,20 @@ link_beng_waisda([expressie(Dir,Date0,Ss)|T], Linked) :- length(Fragments, FN), length(Selections, SN), ( Fragments = [] - -> debug(beng_link, 'no fragments found: ~w ~w', [Dir, Date0]) + -> debug(beng_link, 'no fragments found: ~w ~w', [Dir, Date0]), + Pairs = [] ; FN == SN -> debug(beng_link, 'linked: ~w ~w', [Dir, Date0]), - pairs_keys_values(Pairs, Fragments, Selections), - Linked = [Pairs|Rest] + pairs_keys_values(Pairs, Fragments, Selections) ; FN is SN-1 % last item seems to be missing (ons kent ons) -> debug(beng_link, 'removed last element: ~w ~w', [Dir, Date0]), append(Selections1, [_], Selections), - pairs_keys_values(Pairs, Fragments, Selections1), - Linked = [Pairs|Rest] + pairs_keys_values(Pairs, Fragments, Selections1) ; debug(beng_link, 'unmatching count: ~w ~w ~w ~w', [Dir, Date0, FN, SN]), - Linked = Rest + Pairs = [] ), - link_beng_waisda(T, Rest). + link_beng_waisda(T, Rest), + append(Pairs,Rest,Linked). flip_date(Date1, Date2) :- concat_atom([D,M,Y], '-', Date1), @@ -157,13 +179,14 @@ assert_fragments([Row|Rows]) :- pprime_frags_by_year(FragsByYear) :- - findall(Id, rdf(_V,dc:id,literal(Id)), Vs), + findall(Id, (rdf(V,rdf:type,pprime:'Video'),rdf(V,dc:id,literal(Id))), Vs), maplist(fragment_year, Vs, Pairs), keysort(Pairs, Sorted), group_pairs_by_key(Sorted, Groups), pairs_sort_by_value_count(Groups, FragsByYear). fragment_year(Id, Year-Id) :- - atom_number(Id, N), + %atom_number(Id, N), + Id = N, fragment(N, Date), concat_atom([Year,_,_], '-', Date).