{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "echo '{\"question\": \"Where is Hakata Ward\", \"question_entities\":[\"Q1330839\"], \"id\": \"hakata\"}' > linked.jsonl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "srtk retrieve --input linked.jsonl \\\n",
    "    --output subgraph.jsonl \\\n",
    "    --sparql-endpoint https://query.wikidata.org/sparql \\\n",
    "    --knowledge-graph wikidata \\\n",
    "    --scorer-model-path drt/wikidata-simplequestions \\\n",
    "    --beam-width 2 \\\n",
    "    --max-depth 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"question\":\"Where is Hakata Ward\",\"question_entities\":[\"Q1330839\"],\"triplets\":[[\"Q1330839\",\"P131\",\"Q26600\"],[\"Q1330839\",\"P17\",\"Q17\"]]}\n"
     ]
    }
   ],
   "source": [
    "cat subgraph.jsonl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "srtk visualize --input subgraph.jsonl --output-dir visualization -e https://query.wikidata.org/sparql"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
