vumix/commit

processing baseline data

authorMichiel Hildebrand
Fri Mar 30 09:39:54 2012 +0200
committerMichiel Hildebrand
Fri Mar 30 09:39:54 2012 +0200
commitf7a08e32d324f221386634c2368f80b2ed5799b2
tree3146722fc2f6e7b97ae3e4e145362cd16bebd19c
parent1b2a6b2992cfb6cb74480b1288d3498deaf9d825
Diff style: patch stat
diff --git a/applications/vumix.pl b/applications/vumix.pl
index 4b6a280..cdb7a8e 100644
--- a/applications/vumix.pl
+++ b/applications/vumix.pl
@@ -196,7 +196,7 @@ video_source(_R, @null).
 
 html_annotation_fields([]) --> !.
 html_annotation_fields([URI|T]) -->
-	html(div(class('annotate-field'),
+	html(div(class('annotate-field suggest-field'),
 		 \html_annotation_field(URI))),
 	html_annotation_fields(T).
 
diff --git a/lib/experiment.pl b/lib/experiment.pl
new file mode 100644
index 0000000..a8a7de0
--- /dev/null
+++ b/lib/experiment.pl
@@ -0,0 +1,91 @@
+:- module(vumix_exp,
+	  [user_annotated_target/2,
+	   user_sessions/3,
+	   target_annotation/3
+	  ]).
+
+:- use_module(library(semweb/rdf_db)).
+
+:- rdf_meta
+	target_annotation(r,+,-).
+
+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)).
diff --git a/rdf/mbh_example.ttl b/rdf/mbh_example.ttl
index 23fadfe..25b37b5 100644
--- a/rdf/mbh_example.ttl
+++ b/rdf/mbh_example.ttl
@@ -19,23 +19,27 @@ pprime:personAnnotation
     a :AnnotationField ;
     rdfs:label "Persoonsnamen"@nl ;
     dc:comment "voeg namen van personen toe"@nl ;
+    :scheme <http://data.beeldengeluid.nl/gtaa/Persoonsnamen> ;
     :source "/api/autocomplete?q={query}&filter={\"scheme\":\"http://data.beeldengeluid.nl/gtaa/Persoonsnamen\"}" .
 
 pprime:nameAnnotation
     a :AnnotationField ;
     rdfs:label "Namen"@nl ;
     dc:comment "voeg namen van organisaties, events, karakters toe"@nl ;
+    :scheme <http://data.beeldengeluid.nl/gtaa/Namen> ;
     :source "/api/autocomplete?q={query}&filter={\"scheme\":\"http://data.beeldengeluid.nl/gtaa/Namen\"}" .
 
 pprime:placeAnnotation
     a :annotationField ;
     rdfs:label "Geografische namen"@nl ;
     dc:comment "voeg namen van geografische plaatsen toe"@nl ;
+    :scheme <http://data.beeldengeluid.nl/gtaa/GeografischeNamen> ;
     :source "/api/autocomplete?q={query}&filter={\"scheme\":\"http://data.beeldengeluid.nl/gtaa/GeografischeNamen\"}" .
 
 pprime:subjectAnnotation
     a :annotationField ;
     rdfs:label "Onderwerp"@nl ;
     dc:comment "voeg subject termen toe toe"@nl ;
+    :scheme <http://data.beeldengeluid.nl/gtaa/OnderwerpenBenG> ;
     :source "/api/autocomplete?q={query}&filter={\"scheme\":\"http://data.beeldengeluid.nl/gtaa/OnderwerpenBenG\"}" .
 
diff --git a/web/css/vumix.css b/web/css/vumix.css
index 86df8ba..048e452 100644
--- a/web/css/vumix.css
+++ b/web/css/vumix.css
@@ -13,6 +13,22 @@
 	width: 100%;
 }
 
+/* suggest */
+.suggest-field input {
+	
+}
+.suggest {
+	height: 100px;
+	overflow: auto;
+}
+.suggest ul {
+	padding: 0;
+	margin: 0;
+}
+.suggest li {
+	list-style-type: none;
+}	
+
 /* editable title field */
 #title {
 	background-color: #EEE;