xmlrdf/commit
Speedup in examining vocabularies for unique terms
author | Jan Wielemaker |
---|---|
Tue Feb 28 11:54:28 2012 +0100 | |
committer | Jan Wielemaker |
Tue Feb 28 11:54:28 2012 +0100 | |
commit | 7c24cbc5bc0866f8ab144bae7f97d6b3d04d01a2 |
tree | 47327836ad6df88df7dce14331e0f90fe151a39f |
parent | c5e219e133ab1432dfbb5a0ee32124594792f29d |
Diff style: patch stat
diff --git a/lib/xmlrdf/cvt_vocabulary.pl b/lib/xmlrdf/cvt_vocabulary.pl index 6fdd254..6f86341 100644 --- a/lib/xmlrdf/cvt_vocabulary.pl +++ b/lib/xmlrdf/cvt_vocabulary.pl @@ -3,9 +3,11 @@ find_in_vocabulary/3 % +Schema, +Root, +Literal, -Resource ]). :- use_module(library(semweb/rdf_db)). +:- use_module(library(count)). :- rdf_meta - find_in_vocabulary(r, +, -). + find_in_vocabulary(r, +, -), + in_vocabulary(r, r, r, o, r). %% find_in_vocabulary(?Scheme, ?Root, +Literal, -Resource) is semidet. % @@ -19,24 +21,24 @@ find_in_vocabulary(Root, Name, Resource) :- find_in_vocabulary(_, Root, Name, Resource). find_in_vocabulary(Scheme, Root, Name, Resource) :- - to_seach(Name, Literal), - rdf_has(Resource, skos:prefLabel, Literal), + to_search(Name, Literal), + in_vocabulary(Scheme, Root, skos:prefLabel, Literal, Resource). +find_in_vocabulary(Scheme, Root, Name, Resource) :- + to_search(Name, Literal), + unique_solution(in_vocabulary(Scheme, Root, rdfs:label, Literal, Resource), + Resource). + +in_vocabulary(Scheme, Root, LabelPred, Literal, Resource) :- + rdf_has(Resource, LabelPred, Literal), in_scheme(Resource, Scheme), has_root(Resource, Root). -find_in_vocabulary(Scheme, Root, Name, Resource) :- - to_seach(Name, Literal), - findall(R, ( rdf_has(R, rdfs:label, Literal), - in_scheme(R, Scheme), - has_root(R, Root) - ), - List), - List = [Resource]. - -to_seach(X, X) :- + + +to_search(X, X) :- var(X), !. -to_seach(X, X) :- +to_search(X, X) :- X = literal(_), !. -to_seach(A, literal(A)). +to_search(A, literal(A)). in_scheme(R, Scheme) :- ( var(Scheme) @@ -58,5 +60,3 @@ find_root(R, Root) :- *-> find_root(B, Root) ; Root = R ). - -