accurator/commit
Added code for exporting annotations based on specified domain.
author | Chris Dijkshoorn |
---|---|
Thu Apr 28 21:06:30 2016 +0200 | |
committer | Chris Dijkshoorn |
Thu Apr 28 21:06:30 2016 +0200 | |
commit | e24c82a6d65ef98f0f1b2b15125c0cf5dd66a7d1 |
tree | d4414223d6bdac7774a572658cdd77f1f140961c |
parent | 815416a87e99fb2bc4cd9e8cc5518175bf286a96 |
Diff style: patch stat
diff --git a/lib/accurator/annotation.pl b/lib/accurator/annotation.pl index a07c507..ebd8092 100644 --- a/lib/accurator/annotation.pl +++ b/lib/accurator/annotation.pl @@ -123,7 +123,10 @@ extract_literal(_Locale, literal(Literal), Literal) :- % % Get all annotations and subjects attached to a Uri, get all % annotations a user made, or get all annotations of which the body -% are of in specified concept scheme. +% are of in specified concept scheme or domain. +% annotations(domain,'http://accurator.nl/fashion/jewelry#domain', Annotations). annotations(concept_scheme, +% 'http://purl.org/vocab/nl/ubvu/BiblePageConceptScheme', Annotations). + annotations(object, Uri, Annotations) :- findall(annotation{ field:FieldLabel, @@ -137,6 +140,7 @@ annotations(object, Uri, Annotations) :- FoundAnnotations), get_title(Uri, DisplayTitle), Annotations = annotations{title:DisplayTitle, annotations:FoundAnnotations}. + annotations(user, UserUri, ObjectUris) :- setof(Object, AnnotationHash^ ( rdf_has(AnnotationHash, oa:annotatedBy, UserUri), @@ -145,7 +149,13 @@ annotations(user, UserUri, ObjectUris) :- ObjectUris), !. annotations(user, _UserUri, []). -% annotations(concept_scheme, 'http://purl.org/vocab/nl/ubvu/BiblePageConceptScheme', Annotations). +annotations(domain, Domain, Annotations) :- + findall(AnnotationHash, + ( rdf(AnnotationHash, oa:hasTarget, Work), + rdf(Work, rdf:type, Target), + rdf(Domain, 'http://accurator.nl/schema#hasTarget', Target)), + Annotations). + annotations(concept_scheme, ConceptScheme, Annotations) :- findall(AnnotationHash, ( rdf(AnnotationHash, oa:hasBody, AnnotationBody), @@ -159,7 +169,6 @@ annotations(concept_scheme, ConceptScheme, Annotations, Graph) :- rdf(AnnotationBody, skos:inScheme, ConceptScheme)), Annotations). - get_annotation(Uri, AnnotationBody, AnnotationHash) :- rdf(AnnotationHash, oa:hasTarget, Uri), rdf(AnnotationHash, oa:hasBody, AnnotationBody). diff --git a/lib/accurator/review.pl b/lib/accurator/review.pl index 64b7f1b..8810c92 100644 --- a/lib/accurator/review.pl +++ b/lib/accurator/review.pl @@ -1,8 +1,9 @@ :- module(review, [ - review/3, - reviews/3, - process_annotations/2, - agreeable_annotations/0]). + review/4, + reviews/4, + process_annotations/3, + agreeable_annotations/2 + ]). :- use_module(library(oa_annotation)). :- use_module(library(semweb/rdf_db)). @@ -10,9 +11,9 @@ :- use_module(library(semweb/rdf_turtle_write)). :- rdf_meta - review(r, -, r). + review(r, -, r, -). -%% reviews(+Uris, +User, +Uris) +%% reviews(+Uris, +User, +Uris, +Graph) % % Add a list of reviews. % @@ -20,13 +21,13 @@ % % reviews(agree,'http://accurator.nl/user#r', ['http://localhost/annotation/instances/id_28d9b294881ca09b72c6d0a1eeaa25015d50f860','http://localhost/annotation/instances/id_897ed7aa0034be64512cb1091504dcf7910ddb46']). -reviews(Judgement, User, Uris) :- - maplist(review(Judgement, User), Uris). +reviews(Judgement, User, Uris, Graph) :- + maplist(review(Judgement, User, Graph), Uris). -%% review(+Judgement, +User, +Uri) +%% review(+Judgement, +User, +Uri, +Graph) % % Add a review annotation with a judgement by a specified user. -review(Judgement, User, Uri) :- +review(Judgement, User, Graph, Uri) :- member(Judgement, [agree,disagree,unsure]), !,% verify value atom_string(Judgement, JudgementString), atom_string(Uri, UriString), @@ -35,7 +36,8 @@ review(Judgement, User, Uri) :- label(Judgement), body(_{'@value':JudgementString}), user(User), - motivatedBy('http://www.w3.org/ns/oa#moderating') + motivatedBy('http://www.w3.org/ns/oa#moderating'), + graph(Graph) ], debug(review, 'Add review: ~p', [Options]), rdf_add_annotation(Options, _Annotation). @@ -44,9 +46,9 @@ review(Judgement, User, Uri) :- % % Retrieves and saves selection of annotations based on the given % concept scheme and reviewer -% process_annotations('http://purl.org/vocab/nl/ubvu/BiblePageConceptScheme','http://accurator.nl/user#rasvaan'). -process_annotations(ConceptScheme, Reviewer) :- - select_annotations(ConceptScheme, Reviewer, Annotations), +% process_annotations(domain, 'http://accurator.nl/fashion/jewelry#domain','http://accurator.nl/user#rasvaan'). +process_annotations(Type, Uri, Reviewer) :- + select_annotations(Type, Uri, Reviewer, Annotations), generate_graph_name(Annotations, Graph), export_annotations(Graph, Annotations). @@ -58,12 +60,12 @@ generate_graph_name(UriList, Hash) :- sort(UriList, SortedUris), variant_sha1(SortedUris, Hash). -%% select_annotations(+ConceptScheme, +User, -Annotations) +%% select_annotations(+Type, +ConceptScheme, +User, -Annotations) % % Select a list of annotations based upon given User and % ConceptScheme. -% select_annotations('http://purl.org/vocab/nl/ubvu/BiblePageConceptScheme','http://accurator.nl/user#rasvaan',Annotations). -select_annotations(ConceptScheme, User, Annotations) :- +% select_annotations(conceptScheme,'http://purl.org/vocab/nl/ubvu/BiblePageConceptScheme','http://accurator.nl/user#rasvaan',Annotations). +select_annotations(conceptScheme, ConceptScheme, User, Annotations) :- setof(Annotation, Review^BlankReviewNode^AnnotationBody^ ( rdf(Review, oa:annotatedBy, User), rdf(Review, oa:hasBody, BlankReviewNode), @@ -75,6 +77,18 @@ select_annotations(ConceptScheme, User, Annotations) :- length(Annotations, Number), format('Selected ~p annotations.', [Number]). +select_annotations(domain, Domain, User, Annotations) :- + setof(Annotation, Review^BlankReviewNode^Work^Target^ + ( rdf(Review, oa:annotatedBy, User), + rdf(Review, oa:hasBody, BlankReviewNode), + rdf(BlankReviewNode, cnt:chars, literal('agree')), + rdf(Review, oa:hasTarget, Annotation), + rdf(Annotation, oa:hasTarget, Work), + rdf(Work, rdf:type, Target), + rdf(Domain, 'http://accurator.nl/schema#hasTarget', Target)), + Annotations), + length(Annotations, Number), + format('Selected ~p annotations.', [Number]). %% export_annotations(Annotations) % @@ -96,12 +110,23 @@ add_annotation(Graph, Annotation) :- assert_tiple(Graph, triple(Subject, Predicate, Object)) :- rdf_assert(Subject, Predicate, Object, Graph). -%% agreeable_annotations +%% agreeable_annotations(+Type, ConceptScheme) % % Agree on an agreeable set of annotations -agreeable_annotations :- - % get annotations ubvu based on conceptscheme - annotations(concept_scheme, 'http://purl.org/vocab/nl/ubvu/BiblePageConceptScheme', Annotations), +% agreeable_annotations(conceptScheme,'http://purl.org/vocab/nl/ubvu/BiblePageConceptScheme'). +% agreeable_annotations(domain,'http://accurator.nl/fashion/jewelry#domain'). +agreeable_annotations(conceptScheme, ConceptScheme) :- + % get annotations based on conceptscheme + annotations(concept_scheme, ConceptScheme, Annotations), length(Annotations, Number), + atomic_list_concat([ConceptScheme, 'Reviews'], Graph), format('~p Annotations are being agreed upon', [Number]), - reviews(agree,'http://accurator.nl/user#rasvaan', Annotations). + reviews(agree,'http://accurator.nl/user#rasvaan', Annotations, Graph). + +agreeable_annotations(domain, Domain) :- + % get annotations in a specified domain + annotations(domain, Domain, Annotations), + length(Annotations, Number), + atomic_list_concat([Domain, 'Reviews'], Graph), + format('~p Annotations are being agreed upon, added to ~p', [Number, Graph]), + reviews(agree,'http://accurator.nl/user#rasvaan', Annotations, Graph).