Skip to content

Instantly share code, notes, and snippets.

@e-maud
Last active January 30, 2017 08:22
Show Gist options
  • Save e-maud/edb417e207ca53964927 to your computer and use it in GitHub Desktop.
Save e-maud/edb417e207ca53964927 to your computer and use it in GitHub Desktop.

Garzoni People Search : about guarantors

Number of contracts without guarantor
SELECT COUNT (?contract)
WHERE
{
?contract  a grz-owl:Contract . 
FILTER (NOT EXISTS 
{
  ?contract grz-owl:introduces ?guar .
  ?guar grz-owl:role ?role .
  ?role grz-owl:roleType  grz-owl:guarantor .
})
}
Number of contracts with 1,....,n guarantor (ok)

(contract distribution per number of guarantor)

SELECT ?guarCount count(distinct ?contract) 
WHERE
{
SELECT ?contract count(distinct ?guar) AS ?guarCount
WHERE
{
?contract  a grz-owl:Contract ;  grz-owl:introduces ?guar .
?guar grz-owl:role ?role .
?role grz-owl:roleType  grz-owl:guarantor .
}
GROUP BY ?contract
}
ORDER BY ASC(?guarCount)
How many apprentices do guarantor have on average?
SELECT AVG (?numberApp)
WHERE
{
SELECT COUNT (distinct ?app) AS ?numberApp 
WHERE
{
?g  a grz-owl:Person .
?g grz-owl:role/grz-owl:value/grz-owl:roleType  grz-owl:guarantor .
?g grz-owl:has_apprentice ?app .
}
GROUP BY ?g
}
Select the top-10 of guarantors with most apprentices (ok)
SELECT ?g COUNT (distinct ?app)
WHERE
{
?g  a grz-owl:Person .
?g grz-owl:role/grz-owl:value/grz-owl:roleType  grz-owl:guarantor .
?g grz-owl:has_apprentice ?app .
}
GROUP BY ?g
ORDER BY DESC (COUNT (distinct ?app))
LIMIT 10

About Others

How many "other" mentions
SELECT  COUNT (distinct ?other) 
WHERE
{
  ?other  a grz-owl:PersonMention .
  ?other grz-owl:role/grz-owl:roleType  grz-owl:other .
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment