Skip to content

Concept specificity SPARQL queries

Jindřich Mynarz edited this page Jan 14, 2015 · 3 revisions

Here we show example SPARQL queries for computing CPV concept specificity.

Sum of weighted frequencies of all CPV concepts

The sum of weighted frequencies of all CPV concepts is used for normalization of concept specificities.

PREFIX pc: <http://purl.org/procurement/public-contracts#>

SELECT (SUM(?contractWeight * ?propertyWeight) AS ?count)
WHERE {
  {
    SELECT DISTINCT ?contract ?cpv ?contractWeight ?propertyWeight
    WHERE {
      GRAPH <http://linked.opendata.cz/resource/dataset/vestnikverejnychzakazek.cz/2014-08-25> {
        VALUES (?objectProperty     ?propertyWeight) {
               (pc:mainObject       1)
               (pc:additionalObject 0.5)
        }
        ?contract a pc:Contract ;
          ?objectProperty ?cpv .
        OPTIONAL {
          ?parentContract pc:lot ?contract .
        }
        BIND (IF(BOUND(?parentContract), 0.5, 1) AS ?contractWeight)
      }
    }
  }
}

Concept specificity for asserted CPV concepts

An example SPARQL query for computing concept specificity for asserted concepts.

PREFIX pc: <http://purl.org/procurement/public-contracts#>

SELECT ?cpv (SUM(?weight) AS ?weightedFrequency)
WHERE {
  {
    SELECT DISTINCT ?contract ?cpv ((?propertyWeight * ?contractWeight) AS ?weight)
    WHERE {
      GRAPH <http://linked.opendata.cz/resource/dataset/vestnikverejnychzakazek.cz/2014-08-25> {
        VALUES (?objectProperty     ?propertyWeight) {
               (pc:mainObject       1)
               (pc:additionalObject 0.5)
        }
        ?contract a pc:Contract ;
          ?objectProperty ?cpv .
        OPTIONAL {
          ?parentContract pc:lot ?contract .
        }
        BIND (IF(BOUND(?parentContract), 0.5, 1) AS ?contractWeight)
      }
    }
  }
}
GROUP BY ?cpv

Concept specificity for inferred CPV concepts

An example SPARQL query for computing concept specificity for inferred concepts.

PREFIX pc:   <http://purl.org/procurement/public-contracts#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT ?cpv (SUM(?weight) AS ?weightedFrequency)
WHERE {
  {
    SELECT DISTINCT ?contract ?explicitCPV ((?propertyWeight * ?contractWeight) AS ?weight)
    WHERE {
      GRAPH <http://linked.opendata.cz/resource/dataset/vestnikverejnychzakazek.cz/2014-08-25> {
        VALUES (?objectProperty     ?propertyWeight) {
               (pc:mainObject       1)
               (pc:additionalObject 0.5)
        }
        ?contract a pc:Contract ;
          ?objectProperty ?explicitCPV .
        OPTIONAL {
          ?parentContract pc:lot ?contract .
        }
        BIND (IF(BOUND(?parentContract), 0.5, 1) AS ?contractWeight)
      }
    }
  }
  GRAPH <http://linked.opendata.cz/resource/dataset/cpv-2008> {
    ?explicitCPV skos:broaderTransitive+ ?cpv .
  }
}
GROUP BY ?cpv
Clone this wiki locally