:- module(vumix_exp, [user_annotated_target/2, user_sessions/3, target_annotation/3 ]). :- use_module(library(semweb/rdf_db)). :- rdf_meta target_annotation(r,+,-). time_table(User) :- ( user_annotated_target(User, Target), rdf(Session, opmv:used, Target), rdf(Session, opmv:wasControlledBy, User), rdf(Session, opmv:wasStartedAt, literal(StartTime)), rdf(Session, opmv:wasEndedAt, literal(EndTime)), format('~w ~w ~w ~n', [Target, StartTime, EndTime]), fail ; true ). average_table(User) :- ( user_annotated_target(User, Target), findall(A, target_annotation(Target, User, A), As0), sort(As0, As), annotation_with_tag(As, Target, Matched), rdf(Target, dc:id, literal(Id)), length(As, AnnotationCount), length(Matched, MatchedCount), format('~w~n', [%Id, %AnnotationCount, MatchedCount ]), fail ; true ). annotation_with_tag([], _, []). annotation_with_tag([A|As], Target, [A|Rest]) :- tag_match(Target, A, _TagEntry), !, annotation_with_tag(As, Target, Rest). annotation_with_tag([_A|As], Target, Rest) :- annotation_with_tag(As, Target, Rest). annotation_list(User) :- user_annotated_target(User, T), rdf_global_id(_:Id, T), format('~n~w~n', Id), ( target_annotation(T, User, A), A = annotation(FieldURI, BodyURI, Label), rdf_global_id(_:Field, FieldURI), rdf_global_id(_:Body, BodyURI), format('[~w ~w ~w], ', [Field,Body,Label]), findall(TagEntry, tag_match(T, A, TagEntry), TagEntries), length(TagEntries, TagCount), format('~w~n', TagCount), fail ; true ). tag_match(Target, Annotation, TagEntry) :- Annotation = annotation(_,_,Label), string_match(Label, TagEntry), rdf(Target, pprime:hasAnnotation, TagEntry). string_match(Label, TagEntry) :- rdf(TagEntry,rdf:value,literal(exact(Label),_)). string_match(Label, TagEntry) :- snowball(dutch, Label, Stem), rdf(TagEntry,rdf:value,literal(prefix(Stem),_)). user_annotated_target(User, Target) :- findall(Target, ( rdf(A,oac:hasTarget,Target), rdf(A,dcterms:creator,User) ), Ts), sort(Ts, Targets), member(Target, Targets). user_sessions(User, Target, Sessions) :- findall(Start-End, ( rdf(P,opmv:used,Target), rdf(P,opmv:wasControlledBy,User), rdf(P,opmv:wasStartedAt,Start), rdf(P,opmv:wasEndedAt,End) ), Sessions). target_annotation(Target, User, Annotation) :- Annotation = annotation(Field,Body,Label), rdf(A,oac:hasTarget,Target), rdf(A,dcterms:creator,User), rdf(A,an:annotationField,Field), rdf(A,oac:hasBody,Body), rdf(A,dcterms:title,literal(Label)).