{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Some SPARQL queries for Noordergraf\n",
    "\n",
    "This uses the [SPARQL kernel](https://github.com/paulovn/sparql-kernel) for Jupyter Notebook"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "%lsmagics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We set a few default options via those magics."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Modify output format\n",
    "# Don't show more than 80 results (event if more are fetched)\n",
    "%show 80\n",
    "\n",
    "# Request whatever format is appropriate for the query type\n",
    "%format default\n",
    "\n",
    "# Activate table output\n",
    "%display table"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Set the endpoint to Noordergraf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%endpoint https://noordergraf.rug.nl:10036/repositories/noordergraf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%prefix : <https://noordergraf.rug.nl/ns#>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Search for famous people. These are people with a link to an external site, such as wikidata."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "SELECT ?person ?name ?sameas {\n",
    "  ?person :sameAs ?sameas .\n",
    "  ?person :name / :fullName ?name .\n",
    "  ?item :subject ?person .\n",
    "  FILTER fn:not(STRSTARTS(xsd:string(?sameas), \"https://noordergraf\"))\n",
    "} ORDER BY ?name\n"
   ]
  }
 ],
 "metadata": {
  "@webio": {
   "lastCommId": null,
   "lastKernelId": null
  },
  "kernelspec": {
   "display_name": "SPARQL",
   "language": "sparql",
   "name": "sparql"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "sparql"
   },
   "mimetype": "application/sparql-query",
   "name": "sparql",
   "pygments_lexer": "sparql-nb"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
