Skip to content

Latest commit

 

History

History
59 lines (48 loc) · 2.59 KB

6.md

File metadata and controls

59 lines (48 loc) · 2.59 KB

Find products that are similar to a given product

Description

The consumer has found a product that fulfills his requirements. He now wants to find products with similar features.

The corresponding query starts from a random product and looks for all other products with at least one common feature and a wider range of values for two of its numeric properties.

Sample

"Look for products similar to boozed, with at least one shared feature, and a productPropertyNumeric1 value between 427 and 627 (100 more or less than its value for boozed, 527) and a productPropertyNumeric2 value between 545 and 945 (200 more or less than its value for boozed, 745)".

Expected Outcome

Given the sample dataset bsbm-1000products, the product labels the user should obtain if restricted to the first 5 ordered alphabetically are:

"debouches orangs unethically", "dirk professionalize", "grappled", "imposed", "pepperiness gothically shiner".

SPARQL Query to Perform

SELECT DISTINCT ?product ?productLabel
WHERE {
	?product rdfs:label ?productLabel .
  FILTER (%ProductXYZ% != ?product)
	%ProductXYZ% bsbm:productFeature ?prodFeature .
	?product bsbm:productFeature ?prodFeature .
	%ProductXYZ% bsbm:productPropertyNumeric1 ?origProperty1 .
	?product bsbm:productPropertyNumeric1 ?simProperty1 .
	FILTER (?simProperty1 < (?origProperty1 + 100) && ?simProperty1 > (?origProperty1100))
	%ProductXYZ% bsbm:productPropertyNumeric2 ?origProperty2 .
	?product bsbm:productPropertyNumeric2 ?simProperty2 .
	FILTER (?simProperty2 < (?origProperty2 + 200) && ?simProperty2 > (?origProperty2200))
}
ORDER BY ?productLabel
LIMIT 5

SPARQL Query for the Sample Query

PREFIX bsbm: <http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX pr13: <http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/dataFromProducer13/>
SELECT DISTINCT ?productLabel
WHERE {
	?product rdfs:label ?productLabel .
  FILTER (pr13:Product594 != ?product)
	pr13:Product594 bsbm:productFeature ?prodFeature .
	?product bsbm:productFeature ?prodFeature .
	pr13:Product594 bsbm:productPropertyNumeric1 ?origProperty1 .
	?product bsbm:productPropertyNumeric1 ?simProperty1 .
	FILTER (?simProperty1 < (?origProperty1 + 100) && ?simProperty1 > (?origProperty1 - 100))
	pr13:Product594 bsbm:productPropertyNumeric2 ?origProperty2 .
	?product bsbm:productPropertyNumeric2 ?simProperty2 .
	FILTER (?simProperty2 < (?origProperty2 + 200) && ?simProperty2 > (?origProperty2 - 200))
}
ORDER BY ?productLabel
LIMIT 5