Created
September 6, 2022 22:56
-
-
Save RubenVerborgh/7de2d57ddd2860bfb3d4058bdc898208 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PREFIX e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#> | |
PREFIX ex: <https://example.org/tmp#> | |
PREFIX foaf: <http://xmlns.com/foaf/0.1/> | |
PREFIX list: <http://www.w3.org/2000/10/swap/list#> | |
PREFIX schema: <http://schema.org/> | |
# Profile document | |
<https://ruben.verborgh.org/profile/#me> | |
a foaf:Person; | |
foaf:nick "RV"; | |
foaf:givenName "Ruben"; | |
foaf:name "Ruben Verborgh". | |
# Default greeting preference | |
ex:defaultGreetingPreference a ex:PredicatePreference; | |
# Ordered preference of predicates | |
ex:preferredPredicates ( | |
foaf:nick | |
foaf:givenName | |
foaf:name | |
schema:givenName | |
); | |
# Name of the predicate into which the result is put | |
ex:resultPredicate ex:preferredGreeting. | |
# Apply predicate preferences | |
{ | |
# Load the applicable preference | |
?predicatePreference | |
ex:preferredPredicates ?predicates; | |
ex:resultPredicate ?resultPredicate. | |
# Find all subjects that use predicates occurring in the preference | |
?predicates list:member ?selectedPredicate. | |
?subject ?selectedPredicate ?preferredValue. | |
# Ensure no better match exists earlier in the preference list | |
(?head ?after) list:append ?predicates. | |
(?before (?selectedPredicate)) list:append ?head. | |
?scope e:findall ( | |
?candidate | |
{ | |
?candidate list:in ?before. | |
?subject ?candidate ?value. | |
} | |
() | |
). | |
} | |
=> | |
{ | |
?subject ?resultPredicate ?preferredValue. | |
}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment