Semantic Web Company
Menu
Open
Close
Menu
  • Home01
  • Solutions02
    • backSolutions
    • Search & Analytics02
    • Recommender Systems02
    • Digital Transformation02
  • Products03
    • backProducts
    • PoolParty Semantic Suite03
    • PoolParty PowerTagging03
  • Company04
    • backCompany
    • About us04
    • Leadership Team04
    • Partners04
  • Careers05
  • Learn more06
    • backLearn more
    • Research06
    • PoolParty Academy06
    • SEMANTiCS Conference06
    • Company News06
  • Legal07
    • backLegal
    • Imprint07
    • Privacy07
    • Terms of use07
  • Contact us08

Learn more

  • Jun 26, 2015

Using SPARQL clause VALUES in PoolParty

  • Miscellaneous, Semantic Web Applications, SPARQL, Uncategorized, Vocabularies & Languages

connect-sparqlSince PoolParty fully supports SPARQL 1.1 functionalities you can use clauses like VALUES. The VALUES clause can be used to provide an unordered solution sequence that is joined with the results of the query evaluation. From my perspective it is a convenience of filtering variables and an increase in readability of queries.

E.g. when you want to know which cocktails you can create with Gin and a highball glass you can go to http://vocabulary.semantic-web.at/PoolParty/sparql/cocktails and fire this query:

PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
PREFIX co: <http://vocabulary.semantic-web.at/cocktail-ontology/>
SELECT ?cocktailLabel
WHERE {
  ?cocktail co:consists-of ?ingredient ;
    co:uses ?drinkware ;
    skos:prefLabel ?cocktailLabel .
  ?ingredient skos:prefLabel ?ingredientLabel .
  ?drinkware skos:prefLabel ?drinkwareLabel .
  FILTER (?ingredientLabel = "Gin"@en && ?drinkwareLabel = "Highball glass"@en )
}

When you want to add additional pairs of ingredients and drink ware you want to filter in combination the query gets quite clumsy. Wrongly placed braces can break the syntax. In addition, when writing complicated queries you easily insert errors, e.g. by mixing boolean operators which results in wrong results…

...
FILTER ((?ingredientLabel = "Gin"@en && ?drinkwareLabel = "Highball glass"@en ) ||
     (?ingredientLabel = "Vodka"@en && ?drinkwareLabel ="Old Fashioned glass"@en ))
}

Using VALUES can help in this situation. For example this query shows you how to filter both pairs Gin+Highball glass and Vodka+Old Fashioned glass in a neat way:

PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
PREFIX co: <http://vocabulary.semantic-web.at/cocktail-ontology/>
SELECT ?cocktailLabel
WHERE {
  ?cocktail co:consists-of ?ingredient ;
    co:uses ?drinkware ;
    skos:prefLabel ?cocktailLabel .
  ?ingredient skos:prefLabel ?ingredientLabel .
  ?drinkware skos:prefLabel ?drinkwareLabel .
}
VALUES ( ?ingredientLabel ?drinkwareLabel )
{
  ("Gin"@en "Highball glass"@en)
  ("Vodka"@en "Old Fashioned glass"@en)
}

Especially when you create SPARQL code automatically, e.g. generated by a form, this clause can be very useful.

 

Share on twitter
Share on linkedin
Share on whatsapp
Share on email
PrevPrevious post
Next postNext
ALL POSTS

Twitter

@semwebcompany

RT @ontotext: Come join us on May 12 for Ontotext Demo Day - a mix... Read More

Apr 27 2022, 9:47 am
@semwebcompany

RT @PoolParty_Team: We had a great webinar last week with @factorfirm about #DigitalTransformation projects, and... Read More

Apr 21 2022, 2:16 pm
@semwebcompany

Read More

Apr 14 2022, 12:08 pm
More
  • Twitter
  • Linkedin
  • Youtube
  • Xing
Scroll Top

2022 © Semantic Web Company