{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img align=\"right\" src=\"images/tf-small.png\" width=\"128\"/>\n",
    "<img align=\"right\" src=\"images/etcbc.png\"/>\n",
    "<img align=\"right\" src=\"images/dans-small.png\"/>\n",
    "<img align=\"right\" src=\"images/logo.png\"/>\n",
    "\n",
    "# Tutorial\n",
    "\n",
    "This notebook gets you started with using\n",
    "[Text-Fabric](https://annotation.github.io/text-fabric/) for coding in the Dhammapada.\n",
    "\n",
    "Familiarity with the underlying\n",
    "[data model](https://annotation.github.io/text-fabric/tf/about/datamodel.html)\n",
    "is recommended.\n",
    "\n",
    "Short introductions to other TF datasets:\n",
    "\n",
    "* [Dead Sea Scrolls](https://nbviewer.jupyter.org/github/annotation/tutorials/blob/master/lorentz2020/dss.ipynb),\n",
    "* [Old Babylonian Letters](https://nbviewer.jupyter.org/github/annotation/tutorials/blob/master/lorentz2020/oldbabylonian.ipynb),\n",
    "or the\n",
    "* [Quran](https://nbviewer.jupyter.org/github/annotation/tutorials/blob/master/lorentz2020/quran.ipynb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Installing Text-Fabric\n",
    "\n",
    "See [here](https://annotation.github.io/text-fabric/tf/about/install.html)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "incorrectly_encoded_metadata": "jp-MarkdownHeadingCollapsed=true",
    "tags": []
   },
   "source": [
    "## Tip\n",
    "If you start computing with this tutorial, first copy its parent directory to somewhere else,\n",
    "outside your `dhammapada` directory.\n",
    "If you pull changes from the `dhammapada` repository later, your work will not be overwritten.\n",
    "Where you put your tutorial directory is up till you.\n",
    "It will work from any directory."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "incorrectly_encoded_metadata": "jp-MarkdownHeadingCollapsed=true",
    "tags": []
   },
   "source": [
    "## Dhammapada data\n",
    "\n",
    "Text-Fabric will fetch a standard set of features for you from the newest GitHub release binaries.\n",
    "\n",
    "It will fetch version `0.1`.\n",
    "\n",
    "The data will be stored in the `text-fabric-data` in your home directory."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Incantation\n",
    "\n",
    "The simplest way to get going is by this *incantation*:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:17:17.537171Z",
     "start_time": "2018-05-18T09:17:17.517809Z"
    }
   },
   "outputs": [],
   "source": [
    "from tf.app import use"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For the very last version, use `hot`.\n",
    "\n",
    "For the latest release, use `latest`.\n",
    "\n",
    "If you have cloned the repos (TF app and data), use `clone`.\n",
    "\n",
    "If you do not want/need to upgrade, leave out the checkout specifiers."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rate limit is 5000 requests per hour, with 4999 left for this hour\n",
      "\tconnecting to online GitHub repo etcbc/dhammapada ... connected\n",
      "\tapp/__init__.py...downloaded\n",
      "\tapp/app.py...downloaded\n",
      "\tapp/config.yaml...downloaded\n",
      "\tapp/static...directory\n",
      "\t\tapp/static/display.css...downloaded\n",
      "\t\tapp/static/logo.png...downloaded\n",
      "\tOK\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<b title=\"latest commit\">TF-app:</b> <span title=\"#028933496845fa5e8ea6e0a47d88ec02069ae8b0\">~/text-fabric-data/etcbc/dhammapada/app</span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<b title=\"local release\">data:</b> <span title=\"rv0.2=#aa872b672057dafc3fa55663b8b611b876aad4fc offline under ~/text-fabric-data\">~/text-fabric-data/etcbc/dhammapada/tf/0.2</span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This is Text-Fabric 9.2.0\n",
      "Api reference : https://annotation.github.io/text-fabric/tf/cheatsheet.html\n",
      "\n",
      "16 features found and 0 ignored\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<b>Text-Fabric:</b> <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/tf/cheatsheet.html\" title=\"text-fabric-api\">Text-Fabric API 9.2.0</a>, <a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/app\" title=\"etcbc/dhammapada TF-app\">etcbc/dhammapada/app  v3</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/tf/about/searchusage.html\" title=\"Search Templates Introduction and Reference\">Search Reference</a><br><b>Data:</b> <a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/about.md\" title=\"provenance of Dhammapada-Latine\">DHAMMAPADA</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/tf/writing/.html\" title=\"How TF features represent text\">Character table</a>, <a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"DHAMMAPADA feature documentation\">Feature docs</a><br><b>Features:</b><br>\n",
       "<details><summary><b>Dhammapada-Latine</b></summary>\n",
       "    <div class=\"fcorpus\">\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/clarity.tf\">clarity</a>\n",
       "</div>\n",
       "<div class=\"fmono\">int</div>\n",
       "<details>\n",
       "    <summary>word is inserted for clarity, marked by inclusion in ( and ); only in Latin translation</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>1 (=true) or absent (=false)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/extrastanza.tf\">extrastanza</a>\n",
       "</div>\n",
       "<div class=\"fmono\">int</div>\n",
       "<details>\n",
       "    <summary>word is outside a stanza, between stanzas or in pre/post vagga material</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>1 (=true) or absent (=false)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/freq_occ.tf\">freq_occ</a>\n",
       "</div>\n",
       "<div class=\"fmono\">int</div>\n",
       "<details>\n",
       "    <summary>the number of times that this word occurs</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>positive integer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/latin.tf\">latin</a>\n",
       "</div>\n",
       "<div class=\"fmono\">str</div>\n",
       "<details>\n",
       "    <summary>bare word (without non-word-letters)</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>string (for Latin translation) or empty (for Pali original)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/latinpost.tf\">latinpost</a>\n",
       "</div>\n",
       "<div class=\"fmono\">str</div>\n",
       "<details>\n",
       "    <summary>non-word letters after word, with trailing spaces</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>string (for Latin translation) or empty (for Pali original)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/latinpre.tf\">latinpre</a>\n",
       "</div>\n",
       "<div class=\"fmono\">str</div>\n",
       "<details>\n",
       "    <summary>non-word letters before word, no leading spaces</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>string (for Latin translation) or empty (for Pali original)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/n.tf\">n</a>\n",
       "</div>\n",
       "<div class=\"fmono\">int</div>\n",
       "<details>\n",
       "    <summary>number of vagga, stanza (relative to work), sentence, clause (both relative to vagga)</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>positive number, 0 for pre-stanza material in a vagga</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/otype.tf\">otype</a>\n",
       "</div>\n",
       "<div class=\"fmono\">str</div>\n",
       "<details>\n",
       "    <summary></summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/pali.tf\">pali</a>\n",
       "</div>\n",
       "<div class=\"fmono\">str</div>\n",
       "<details>\n",
       "    <summary>bare word (without non-word-letters)</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>string (for Pali original) or empty (for Latin translation)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/palipost.tf\">palipost</a>\n",
       "</div>\n",
       "<div class=\"fmono\">str</div>\n",
       "<details>\n",
       "    <summary>non-word letters after word, with trailing spaces</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>string (for Pali original) or empty (for Latin translation)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/palipre.tf\">palipre</a>\n",
       "</div>\n",
       "<div class=\"fmono\">str</div>\n",
       "<details>\n",
       "    <summary>non-word letters before word, no leading spaces</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>string (for Pali original) or empty (for Latin translation)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/quote.tf\">quote</a>\n",
       "</div>\n",
       "<div class=\"fmono\">int</div>\n",
       "<details>\n",
       "    <summary>word is inside a quote</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>1 (=true) or absent (=false)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/trans.tf\">trans</a>\n",
       "</div>\n",
       "<div class=\"fmono\">int</div>\n",
       "<details>\n",
       "    <summary>whether the node belongs to the original text or a translation</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>1 (=Latin translation) or absent (=Pali original)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat \">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/uncertain.tf\">uncertain</a>\n",
       "</div>\n",
       "<div class=\"fmono\">int</div>\n",
       "<details>\n",
       "    <summary>word is marked as uncertain by inclusion in [ and ]; only in Pali original</summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">format:</div>\n",
       "    <div>1 (=true) or absent (=false)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "<div class=\"frow\">\n",
       "    <div class=\"fnamecat edge\">\n",
       "<a target=\"_blank\" href=\"https://github.com/etcbc/dhammapada/blob/master/docs/transcription.md\" title=\"~/text-fabric-data/etcbc/dhammapada/tf/0.2/oslots.tf\">oslots</a>\n",
       "</div>\n",
       "<div class=\"fmono\">none</div>\n",
       "<details>\n",
       "    <summary></summary>\n",
       "    <div class=\"fmeta\">\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">converters:</div>\n",
       "    <div>Dirk Roorda (Text-Fabric)</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">copynote1:</div>\n",
       "    <div>Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">dateWritten:</div>\n",
       "    <div>2021-12-24T14:49:10Z</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">digitizers:</div>\n",
       "    <div>Bee Scherer, Yvonne Mataar</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">edition:</div>\n",
       "    <div>2nd</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">editor:</div>\n",
       "    <div>V. Fausboll</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">institute:</div>\n",
       "    <div>Text and Traditions, VU Amsterdam</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">language:</div>\n",
       "    <div>pli,lat</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">place:</div>\n",
       "    <div>London</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">project:</div>\n",
       "    <div>Dhammapada-latine</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">publisher:</div>\n",
       "    <div>Luzac &amp; Co.</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">researcher:</div>\n",
       "    <div>Bee Scherer</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">sourceFormat:</div>\n",
       "    <div>plain text</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">stamp:</div>\n",
       "    <div>50480</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">subtitle:</div>\n",
       "    <div>being a collection of moral verses in Pali</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">title:</div>\n",
       "    <div>The Dhammapada</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">version:</div>\n",
       "    <div>0.2</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">writtenBy:</div>\n",
       "    <div>Text-Fabric</div>\n",
       "</div>\n",
       "\n",
       "<div class=\"fmetarow\">\n",
       "    <div class=\"fmetakey\">yearPublished:</div>\n",
       "    <div>1900</div>\n",
       "</div>\n",
       "\n",
       "        </div>\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "    </div>\n",
       "</details>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<style>tr.tf.ltr, td.tf.ltr, th.tf.ltr { text-align: left ! important;}\n",
       "tr.tf.rtl, td.tf.rtl, th.tf.rtl { text-align: right ! important;}\n",
       "@font-face {\n",
       "  font-family: \"Gentium Plus\";\n",
       "  src: local('Gentium Plus'), local('GentiumPlus'),\n",
       "    url('/server/static/fonts/GentiumPlus-R.woff') format('woff'),\n",
       "    url('https://github.com/annotation/text-fabric/blob/master/tf/server/static/fonts/GentiumPlus-R.woff?raw=true') format('woff');\n",
       "}\n",
       "\n",
       "@font-face {\n",
       "  font-family: \"Ezra SIL\";\n",
       "  src: local('Ezra SIL'), local('EzraSIL'),\n",
       "    url('/server/static/fonts/SILEOT.woff') format('woff'),\n",
       "    url('https://github.com/annotation/text-fabric/blob/master/tf/server/static/fonts/SILEOT.woff?raw=true') format('woff');\n",
       "}\n",
       "\n",
       "@font-face {\n",
       "  font-family: \"SBL Hebrew\";\n",
       "  src: local('SBL Hebrew'), local('SBLHebrew'),\n",
       "    url('/server/static/fonts/SBL_Hbrw.woff') format('woff'),\n",
       "    url('https://github.com/annotation/text-fabric/blob/master/tf/server/static/fonts/SBL_Hbrw.woff?raw=true') format('woff');\n",
       "}\n",
       "\n",
       "@font-face {\n",
       "  font-family: \"Estrangelo Edessa\";\n",
       "  src: local('Estrangelo Edessa'), local('EstrangeloEdessa');\n",
       "    url('/server/static/fonts/SyrCOMEdessa.woff') format('woff'),\n",
       "    url('https://github.com/annotation/text-fabric/blob/master/tf/server/static/fonts/SyrCOMEdessa.woff?raw=true') format('woff');\n",
       "}\n",
       "\n",
       "@font-face {\n",
       "  font-family: AmiriQuran;\n",
       "  font-style: normal;\n",
       "  font-weight: 400;\n",
       "  src: local('Amiri Quran'), local('AmiriQuran'),\n",
       "    url('/server/static/fonts/AmiriQuran.woff') format('woff'),\n",
       "    url('https://github.com/annotation/text-fabric/blob/master/tf/server/static/fonts/AmiriQuran.woff?raw=true') format('woff');\n",
       "}\n",
       "\n",
       "@font-face {\n",
       "  font-family: AmiriQuranColored;\n",
       "  font-style: normal;\n",
       "  font-weight: 400;\n",
       "  src: local('Amiri Quran Colored'), local('AmiriQuranColored'),\n",
       "    url('/server/static/fonts/AmiriQuranColored.woff') format('woff'),\n",
       "    url('https://github.com/annotation/text-fabric/blob/master/tf/server/static/fonts/AmiriQuranColored.woff?raw=true') format('woff');\n",
       "}\n",
       "\n",
       "@font-face {\n",
       "  font-family: \"Santakku\";\n",
       "  src: local('Santakku'),\n",
       "    url('/server/static/fonts/Santakku.woff') format('woff'),\n",
       "    url('https://github.com/annotation/text-fabric/blob/master/tf/server/static/fonts/Santakku.woff?raw=true') format('woff');\n",
       "}\n",
       "\n",
       "@font-face {\n",
       "  font-family: \"SantakkuM\";\n",
       "  src: local('SantakkuM'),\n",
       "    url('/server/static/fonts/SantakkuM.woff') format('woff'),\n",
       "    url('https://github.com/annotation/text-fabric/blob/master/tf/server/static/fonts/SantakkuM.woff?raw=true') format('woff');\n",
       "}\n",
       "/* bypassing some classical notebook settings */\n",
       "div#notebook {\n",
       "  line-height: unset;\n",
       "}\n",
       "/* neutral text */\n",
       ".txtn,.txtn a:visited,.txtn a:link {\n",
       "    font-family: sans-serif;\n",
       "    font-size: medium;\n",
       "    direction: ltr;\n",
       "    unicode-bidi: embed;\n",
       "    text-decoration: none;\n",
       "    color: var(--text-color);\n",
       "}\n",
       "/* transcription text */\n",
       ".txtt,.txtt a:visited,.txtt a:link {\n",
       "    font-family: monospace;\n",
       "    font-size: medium;\n",
       "    direction: ltr;\n",
       "    unicode-bidi: embed;\n",
       "    text-decoration: none;\n",
       "    color: var(--text-color);\n",
       "}\n",
       "/* source text */\n",
       ".txto,.txto a:visited,.txto a:link {\n",
       "    font-family: serif;\n",
       "    font-size: medium;\n",
       "    direction: ltr;\n",
       "    unicode-bidi: embed;\n",
       "    text-decoration: none;\n",
       "    color: var(--text-color);\n",
       "}\n",
       "/* phonetic text */\n",
       ".txtp,.txtp a:visited,.txtp a:link {\n",
       "    font-family: Gentium, sans-serif;\n",
       "    font-size: medium;\n",
       "    direction: ltr;\n",
       "    unicode-bidi: embed;\n",
       "    text-decoration: none;\n",
       "    color: var(--text-color);\n",
       "}\n",
       "/* original script text */\n",
       ".txtu,.txtu a:visited,.txtu a:link {\n",
       "    font-family: Gentium, sans-serif;\n",
       "    font-size: medium;\n",
       "    text-decoration: none;\n",
       "    color: var(--text-color);\n",
       "}\n",
       "/* hebrew */\n",
       ".txtu.hbo,.lex.hbo {\n",
       "    font-family: \"Ezra SIL\", \"SBL Hebrew\", sans-serif;\n",
       "    font-size: large;\n",
       "    direction: rtl ! important;\n",
       "    unicode-bidi: embed;\n",
       "}\n",
       "/* syriac */\n",
       ".txtu.syc,.lex.syc {\n",
       "    font-family: \"Estrangelo Edessa\", sans-serif;\n",
       "    font-size: medium;\n",
       "    direction: rtl ! important;\n",
       "    unicode-bidi: embed;\n",
       "}\n",
       "/* neo aramaic */\n",
       ".txtu.cld,.lex.cld {\n",
       "    font-family: \"CharisSIL-R\", sans-serif;\n",
       "    font-size: medium;\n",
       "    direction: ltr ! important;\n",
       "    unicode-bidi: embed;\n",
       "}\n",
       "/* standard arabic */\n",
       ".txtu.ara,.lex.ara {\n",
       "    font-family: \"AmiriQuran\", sans-serif;\n",
       "    font-size: large;\n",
       "    direction: rtl ! important;\n",
       "    unicode-bidi: embed;\n",
       "}\n",
       "/* cuneiform */\n",
       ".txtu.akk,.lex.akk {\n",
       "    font-family: Santakku, sans-serif;\n",
       "    font-size: large;\n",
       "    direction: ltr ! important;\n",
       "    unicode-bidi: embed;\n",
       "}\n",
       "/* greek */\n",
       ".txtu.grc,.lex.grc a:link {\n",
       "    font-family: Gentium, sans-serif;\n",
       "    font-size: medium;\n",
       "    direction: ltr ! important;\n",
       "    unicode-bidi: embed;\n",
       "}\n",
       "a:hover {\n",
       "    text-decoration: underline | important;\n",
       "    color: #0000ff | important;\n",
       "}\n",
       ".ltr {\n",
       "    direction: ltr ! important;\n",
       "    unicode-bidi: embed;\n",
       "}\n",
       ".rtl {\n",
       "    direction: rtl ! important;\n",
       "    unicode-bidi: embed;\n",
       "}\n",
       ".ubd {\n",
       "    unicode-bidi: embed;\n",
       "}\n",
       ".col {\n",
       "   display: inline-block;\n",
       "}\n",
       ".features {\n",
       "    font-family: monospace;\n",
       "    font-size: medium;\n",
       "    font-weight: bold;\n",
       "    color: var(--features);\n",
       "    display: flex;\n",
       "    flex-flow: column nowrap;\n",
       "    justify-content: flex-start;\n",
       "    align-items: flex-start;\n",
       "    align-content: flex-start;\n",
       "    padding: 2px;\n",
       "    margin: 2px;\n",
       "    direction: ltr;\n",
       "    unicode-bidi: embed;\n",
       "    border: var(--meta-width) solid var(--meta-color);\n",
       "    border-radius: var(--meta-width);\n",
       "}\n",
       ".features div,.features span {\n",
       "    padding: 0;\n",
       "    margin: -2px 0;\n",
       "}\n",
       ".features .f {\n",
       "    font-family: sans-serif;\n",
       "    font-size: small;\n",
       "    font-weight: normal;\n",
       "    color: #5555bb;\n",
       "}\n",
       ".features .xft {\n",
       "  color: #000000;\n",
       "  background-color: #eeeeee;\n",
       "  font-size: medium;\n",
       "  margin: 2px 0px;\n",
       "}\n",
       ".features .xft .f {\n",
       "  color: #000000;\n",
       "  background-color: #eeeeee;\n",
       "  font-size: small;\n",
       "  font-weight: normal;\n",
       "}\n",
       ".tfsechead {\n",
       "    font-family: sans-serif;\n",
       "    font-size: small;\n",
       "    font-weight: bold;\n",
       "    color: var(--tfsechead);\n",
       "    unicode-bidi: embed;\n",
       "    text-align: start;\n",
       "}\n",
       ".structure {\n",
       "    font-family: sans-serif;\n",
       "    font-size: small;\n",
       "    font-weight: bold;\n",
       "    color: var(--structure);\n",
       "    unicode-bidi: embed;\n",
       "    text-align: start;\n",
       "}\n",
       ".comments {\n",
       "    display: flex;\n",
       "    justify-content: flex-start;\n",
       "    align-items: flex-start;\n",
       "    align-content: flex-start;\n",
       "    flex-flow: column nowrap;\n",
       "}\n",
       ".nd, a:link.nd {\n",
       "    font-family: sans-serif;\n",
       "    font-size: small;\n",
       "    color: var(--node);\n",
       "    vertical-align: super;\n",
       "    direction: ltr ! important;\n",
       "    unicode-bidi: embed;\n",
       "}\n",
       ".lex {\n",
       "  color: var(--lex-color);;\n",
       "}\n",
       ".children,.children.ltr {\n",
       "    display: flex;\n",
       "    border: 0;\n",
       "    background-color: #ffffff;\n",
       "    justify-content: flex-start;\n",
       "    align-items: flex-start;\n",
       "    align-content: flex-start;\n",
       "}\n",
       ".children.stretch {\n",
       "    align-items: stretch;\n",
       "}\n",
       ".children.hor {\n",
       "    flex-flow: row nowrap;\n",
       "}\n",
       ".children.hor.wrap {\n",
       "    flex-flow: row wrap;\n",
       "}\n",
       ".children.ver {\n",
       "    flex-flow: column nowrap;\n",
       "}\n",
       ".children.ver.wrap {\n",
       "    flex-flow: column wrap;\n",
       "}\n",
       ".contnr {\n",
       "    width: fit-content;\n",
       "    display: flex;\n",
       "    justify-content: flex-start;\n",
       "    align-items: flex-start;\n",
       "    align-content: flex-start;\n",
       "    flex-flow: column nowrap;\n",
       "    background: #ffffff none repeat scroll 0 0;\n",
       "    padding:  10px 2px 2px 2px;\n",
       "    margin: 16px 2px 2px 2px;\n",
       "    border-style: solid;\n",
       "    font-size: small;\n",
       "}\n",
       ".contnr.trm {\n",
       "    background-attachment: local;\n",
       "}\n",
       ".contnr.cnul {\n",
       "    padding:  0;\n",
       "    margin: 0;\n",
       "    border-style: solid;\n",
       "    font-size: xx-small;\n",
       "}\n",
       ".contnr.cnul,.lbl.cnul {\n",
       "    border-color: var(--border-color-nul);\n",
       "    border-width: var(--border-width-nul);\n",
       "    border-radius: var(--border-width-nul);\n",
       "}\n",
       ".contnr.c0,.lbl.c0 {\n",
       "    border-color: var(--border-color0);\n",
       "    border-width: var(--border-width0);\n",
       "    border-radius: var(--border-width0);\n",
       "}\n",
       ".contnr.c1,.lbl.c1 {\n",
       "    border-color: var(--border-color1);\n",
       "    border-width: var(--border-width1);\n",
       "    border-radius: var(--border-width1);\n",
       "}\n",
       ".contnr.c2,.lbl.c2 {\n",
       "    border-color: var(--border-color2);\n",
       "    border-width: var(--border-width2);\n",
       "    border-radius: var(--border-width2);\n",
       "}\n",
       ".contnr.c3,.lbl.c3 {\n",
       "    border-color: var(--border-color3);\n",
       "    border-width: var(--border-width3);\n",
       "    border-radius: var(--border-width3);\n",
       "}\n",
       ".contnr.c4,.lbl.c4 {\n",
       "    border-color: var(--border-color4);\n",
       "    border-width: var(--border-width4);\n",
       "    border-radius: var(--border-width4);\n",
       "}\n",
       "span.plain {\n",
       "    display: inline-block;\n",
       "    white-space: pre-wrap;\n",
       "}\n",
       ".plain {\n",
       "    background-color: #ffffff;\n",
       "}\n",
       ".plain.l,.contnr.l,.contnr.l>.lbl {\n",
       "    border-left-style: dotted\n",
       "}\n",
       ".plain.r,.contnr.r,.contnr.r>.lbl {\n",
       "    border-right-style: dotted\n",
       "}\n",
       ".plain.lno,.contnr.lno,.contnr.lno>.lbl {\n",
       "    border-left-style: none\n",
       "}\n",
       ".plain.rno,.contnr.rno,.contnr.rno>.lbl {\n",
       "    border-right-style: none\n",
       "}\n",
       ".plain.l {\n",
       "    padding-left: 4px;\n",
       "    margin-left: 2px;\n",
       "    border-width: var(--border-width-plain);\n",
       "}\n",
       ".plain.r {\n",
       "    padding-right: 4px;\n",
       "    margin-right: 2px;\n",
       "    border-width: var(--border-width-plain);\n",
       "}\n",
       ".lbl {\n",
       "    font-family: monospace;\n",
       "    margin-top: -24px;\n",
       "    margin-left: 20px;\n",
       "    background: #ffffff none repeat scroll 0 0;\n",
       "    padding: 0 6px;\n",
       "    border-style: solid;\n",
       "    display: block;\n",
       "    color: var(--label)\n",
       "}\n",
       ".lbl.trm {\n",
       "    background-attachment: local;\n",
       "    margin-top: 2px;\n",
       "    margin-left: 2px;\n",
       "    padding: 2px 2px;\n",
       "    border-style: none;\n",
       "}\n",
       ".lbl.cnul {\n",
       "    font-size: xx-small;\n",
       "}\n",
       ".lbl.c0 {\n",
       "    font-size: small;\n",
       "}\n",
       ".lbl.c1 {\n",
       "    font-size: small;\n",
       "}\n",
       ".lbl.c2 {\n",
       "    font-size: medium;\n",
       "}\n",
       ".lbl.c3 {\n",
       "    font-size: medium;\n",
       "}\n",
       ".lbl.c4 {\n",
       "    font-size: large;\n",
       "}\n",
       ".occs, a:link.occs {\n",
       "    font-size: small;\n",
       "}\n",
       "\n",
       "/* PROVENANCE */\n",
       "\n",
       "div.prov {\n",
       "\tmargin: 40px;\n",
       "\tpadding: 20px;\n",
       "\tborder: 2px solid var(--fog-rim);\n",
       "}\n",
       "div.pline {\n",
       "\tdisplay: flex;\n",
       "\tflex-flow: row nowrap;\n",
       "\tjustify-content: stretch;\n",
       "\talign-items: baseline;\n",
       "}\n",
       "div.p2line {\n",
       "\tmargin-left: 2em;\n",
       "\tdisplay: flex;\n",
       "\tflex-flow: row nowrap;\n",
       "\tjustify-content: stretch;\n",
       "\talign-items: baseline;\n",
       "}\n",
       "div.psline {\n",
       "\tdisplay: flex;\n",
       "\tflex-flow: row nowrap;\n",
       "\tjustify-content: stretch;\n",
       "\talign-items: baseline;\n",
       "\tbackground-color: var(--gold-mist-back);\n",
       "}\n",
       "div.pname {\n",
       "\tflex: 0 0 5rem;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "div.pval {\n",
       "    flex: 1 1 auto;\n",
       "}\n",
       "\n",
       "/* KEYBOARD */\n",
       ".ccoff {\n",
       "  background-color: inherit;\n",
       "}\n",
       ".ccon {\n",
       "  background-color: yellow ! important;\n",
       "}\n",
       "/* TF header */\n",
       "\n",
       "summary {\n",
       "  /* needed to override the normalize.less\n",
       "   * in the classical jupyter notebook\n",
       "   */\n",
       "  display: list-item ! important;\n",
       "}\n",
       "\n",
       ".fcorpus {\n",
       "  display: flex;\n",
       "  flex-flow: column nowrap;\n",
       "  justify-content: flex-start;\n",
       "  align-items: flex-start;\n",
       "  align-content: flex-start;\n",
       "}\n",
       ".frow {\n",
       "  display: flex;\n",
       "  flex-flow: row nowrap;\n",
       "  justify-content: flex-start;\n",
       "  align-items: flex-start;\n",
       "  align-content: flex-start;\n",
       "}\n",
       ".fmeta {\n",
       "  display: flex;\n",
       "  flex-flow: column nowrap;\n",
       "  justify-content: flex-start;\n",
       "  align-items: flex-start;\n",
       "  align-content: flex-start;\n",
       "}\n",
       ".fmetarow {\n",
       "  display: flex;\n",
       "  flex-flow: row nowrap;\n",
       "  justify-content: flex-start;\n",
       "  align-items: flex-start;\n",
       "  align-content: flex-start;\n",
       "}\n",
       ".fmetakey {\n",
       "  min-width: 10rem;\n",
       "  font-family: monospace;\n",
       "}\n",
       ".fnamecat {\n",
       "  min-width: 10rem;\n",
       "}\n",
       ".fnamecat.edge {\n",
       "  font-weight: bold;\n",
       "  font-style: italic;\n",
       "}\n",
       ".fmono {\n",
       "    font-family: monospace;\n",
       "}\n",
       "\n",
       ":root {\n",
       "\t--node:               hsla(120, 100%,  20%, 1.0  );\n",
       "\t--label:              hsla(  0, 100%,  20%, 1.0  );\n",
       "\t--tfsechead:          hsla(  0, 100%,  25%, 1.0  );\n",
       "\t--structure:          hsla(120, 100%,  25%, 1.0  );\n",
       "\t--features:           hsla(  0,   0%,  30%, 1.0  );\n",
       "  --text-color:         hsla( 60,  80%,  10%, 1.0  );\n",
       "  --lex-color:          hsla(220,  90%,  60%, 1.0  );\n",
       "  --meta-color:         hsla(  0,   0%,  90%, 0.7  );\n",
       "  --meta-width:         3px;\n",
       "  --border-color-nul:   hsla(  0,   0%,  90%, 0.5  );\n",
       "  --border-color0:      hsla(  0,   0%,  90%, 0.9  );\n",
       "  --border-color1:      hsla(  0,   0%,  80%, 0.9  );\n",
       "  --border-color2:      hsla(  0,   0%,  70%, 0.9  );\n",
       "  --border-color3:      hsla(  0,   0%,  80%, 0.8  );\n",
       "  --border-color4:      hsla(  0,   0%,  60%, 0.9  );\n",
       "  --border-width-nul:   2px;\n",
       "  --border-width0:      2px;\n",
       "  --border-width1:      3px;\n",
       "  --border-width2:      4px;\n",
       "  --border-width3:      6px;\n",
       "  --border-width4:      5px;\n",
       "  --border-width-plain: 2px;\n",
       "}\n",
       ".hl {\n",
       "  background-color: var(--hl-strong);\n",
       "}\n",
       "span.hl {\n",
       "\tbackground-color: var(--hl-strong);\n",
       "\tborder-width: 0;\n",
       "\tborder-radius: 2px;\n",
       "\tborder-style: solid;\n",
       "}\n",
       "div.contnr.hl,div.lbl.hl {\n",
       "  background-color: var(--hl-strong);\n",
       "}\n",
       "div.contnr.hl {\n",
       "  border-color: var(--hl-rim) ! important;\n",
       "\tborder-width: 4px ! important;\n",
       "}\n",
       "\n",
       "span.hlbx {\n",
       "\tborder-color: var(--hl-rim);\n",
       "\tborder-width: 4px ! important;\n",
       "\tborder-style: solid;\n",
       "\tborder-radius: 6px;\n",
       "  padding: 4px;\n",
       "  margin: 4px;\n",
       "}\n",
       "\n",
       "span.plain {\n",
       "  display: inline-block;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "\n",
       ":root {\n",
       "\t--hl-strong:        hsla( 60, 100%,  70%, 0.9  );\n",
       "\t--hl-rim:           hsla( 55,  80%,  50%, 1.0  );\n",
       "}\n",
       ".trans1 {\n",
       "    color: #0000cc;\n",
       "}\n",
       ".extrastanza1 {\n",
       "  font-weight: bold;\n",
       "}\n",
       ".clarity1 {\n",
       "  font-family: monospace;\n",
       "  color: #8888ff;\n",
       "}\n",
       ".uncertain1 {\n",
       "  font-family: monospace;\n",
       "  color: #888888;\n",
       "}\n",
       ".quote1 {\n",
       "  font-style: italic;\n",
       "}\n",
       "</style>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "const copyChar = (el, c) => {\n",
       "    for (const el of document.getElementsByClassName('ccon')) {\n",
       "        el.className = 'ccoff'\n",
       "    }\n",
       "    el.className = 'ccon'\n",
       "    navigator.clipboard.writeText(String.fromCharCode(c))\n",
       "}\n",
       "</script>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div><b>Text-Fabric API:</b> names <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/tf/cheatsheet.html\" title=\"doc\">N F E L T S C TF</a> directly usable</div><hr>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "A = use('etcbc/dhammapada:hot', hoist=globals())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "# Features\n",
    "The data of the Dhammapada is organized in features.\n",
    "They are *columns* of data.\n",
    "Think of the corpus as a big spreadsheet, where row 1 corresponds to the\n",
    "first word, row 2 to the second word, and so on, for all 13,000 words.\n",
    "\n",
    "The one column contains the letters of each Pali word.\n",
    "Another column contains the letters of each Latin word.\n",
    "There are columns which tell whether words are parts of quotations, or between `[ ]` (uncertain),\n",
    "or between `( )` (for clarity), and so on.\n",
    "\n",
    "Instead of putting that information in one big table, the data is organized in separate columns.\n",
    "We call those columns **features**."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "By clicking on the triangle in front of **Dhammapada-Latine**\n",
    "you can see which features have been loaded, with a short description, and from there you can expand more information.\n",
    "If you click on a feature name, you find its documentation.\n",
    "If you hover over a name, you see where the feature is located on your system.\n",
    "\n",
    "Edge features are marked by ***bold italic*** formatting.\n",
    "We only have one edge feature: `oslots`, which is a standard TF feature.\n",
    "Corpora might add more edge features, and probably newer versions of this corpus will have edge features."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "incorrectly_encoded_metadata": "jp-MarkdownHeadingCollapsed=true",
    "tags": []
   },
   "source": [
    "## API\n",
    "\n",
    "The result of the incantation is that we have a bunch of special variables at our disposal\n",
    "that give us access to the corpus.\n",
    "\n",
    "At this point it is helpful to throw a quick glance at the text-fabric API documentation\n",
    "(see the links under **API Members** above).\n",
    "\n",
    "The most essential thing for now is that we can use `F` to access the data in the features\n",
    "we've loaded.\n",
    "But there is more, such as `N`, which helps us to walk over the text, as we see in a minute.\n",
    "\n",
    "The **API members** above show you exactly which new names have been inserted in your namespace.\n",
    "If you click on these names, you go to the API documentation for them."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Search\n",
    "Text-Fabric contains a flexible search engine, that does not only work for the data of this corpus,\n",
    "but also for data that you add to it.\n",
    "\n",
    "**Search is the quickest way to come up-to-speed with your data, without too much programming.**\n",
    "\n",
    "For example, lets display a number of words with frequencies higher than some threshold."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  0.01s 2604 results\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<p><b>clause</b> <i>1</i></p>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></div><div class=\" children\"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">manasā </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>9</span></div></div><div class=\"contnr c0 trm   hl\" ><div class=\"lbl c0 trm hl\" ><span class=\"txtu\">ce </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>24</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">paduṭṭhena </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>1</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">bhāsatī </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>2</span></div></div><div class=\"contnr c0 trm   hl\" ><div class=\"lbl c0 trm hl\" ><span class=\"txtu\">vā </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>22</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">karoti </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>5</span></div></div><div class=\"contnr c0 trm   hl\" ><div class=\"lbl c0 trm hl\" ><span class=\"txtu\">vā </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>22</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">tato </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>12</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">naṃ </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>8</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">dukkham </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>5</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">anveti </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>4</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">cakkaṃ </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>1</span></div></div><div class=\"contnr c0 trm   hl\" ><div class=\"lbl c0 trm hl\" ><span class=\"txtu\">va </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>73</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">vahato </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>1</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">padaṃ. </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>9</span></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<p><b>clause</b> <i>2</i></p>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></div><div class=\" children\"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">Naturae </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>2</span></div></div><div class=\"contnr c0 trm   hl\" ><div class=\"lbl c0 trm hl\" ><span class=\"txtu\">a </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>30</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">mente </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>12</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">principium </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>1</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">ducunt, </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>4</span></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<p><b>clause</b> <i>3</i></p>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></div><div class=\" children\"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">mens </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>6</span></div></div><div class=\"contnr c0 trm   hl\" ><div class=\"lbl c0 trm hl\" ><span class=\"txtu\">est </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>137</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">potior </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>1</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">pars </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>1</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">earum, </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>1</span></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<p><b>clause</b> <i>4</i></p>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></div><div class=\" children\"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   hl\" ><div class=\"lbl c0 trm hl\" ><span class=\"txtu\">e </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>21</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">mente </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>12</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">constant; </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>1</span></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<p><b>clause</b> <i>5</i></p>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></div><div class=\" children\"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   hl\" ><div class=\"lbl c0 trm hl\" ><span class=\"txtu\">si </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>24</span></div></div><div class=\"contnr c0 trm   hl\" ><div class=\"lbl c0 trm hl\" ><span class=\"txtu\">(quis) </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>25</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">mente </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>12</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">inquinata </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>1</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">aut </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>4</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">loquitur </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>2</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">aut </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>4</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">agit, </span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>6</span></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "query = \"\"\"\n",
    "word freq_occ>20\n",
    "\"\"\"\n",
    "\n",
    "results = A.search(query)\n",
    "A.show(results, start=1, end=5, condenseType=\"clause\", condensed=True)\n",
    "A.displayReset(\"tupleFeatures\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Jump to the dedicated [search](search.ipynb) search tutorial first, to whet your appetite further.\n",
    "\n",
    "The real power of search lies in the fact that it is integrated in a programming environment.\n",
    "You can use programming to:\n",
    "\n",
    "* compose dynamic queries\n",
    "* process query results\n",
    "\n",
    "Therefore, the rest of this tutorial is still important when you want to tap that power.\n",
    "If you continue here, you learn all the basics of data-navigation with Text-Fabric."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Before we start coding, we load some modules that we need underway:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:17:16.202764Z",
     "start_time": "2018-05-18T09:17:16.197546Z"
    }
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import collections\n",
    "from itertools import chain"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "# Counting\n",
    "\n",
    "In order to get acquainted with the data, we start with the simple task of counting.\n",
    "\n",
    "## Count all nodes\n",
    "We use the\n",
    "[`N.walk()` generator](https://annotation.github.io/text-fabric/tf/core/nodes.html#tf.core.nodes.Nodes.walk)\n",
    "to walk through the nodes.\n",
    "\n",
    "We compared the corpus data to a gigantic spreadsheet, where the rows correspond to the words.\n",
    "In Text-Fabric, we call the rows `slots`, because they are the textual positions that can be filled with words.\n",
    "\n",
    "Besides the words there are other objects: clauses, sentences, stanzas, vaggas.\n",
    "They also correspond to rows in the big spreadsheet.\n",
    "\n",
    "In Text-Fabric we call all these rows *nodes*, and the `N()` generator\n",
    "carries us through those nodes in the textual order.\n",
    "\n",
    "Just one extra thing: the `info` statements generate timed messages.\n",
    "If you use them instead of `print` you'll get a sense of the amount of time that\n",
    "the various processing steps typically need."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:17:43.894153Z",
     "start_time": "2018-05-18T09:17:43.597128Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  0.00s Counting nodes ...\n",
      "  0.00s 16664 nodes\n"
     ]
    }
   ],
   "source": [
    "A.indent(reset=True)\n",
    "A.info(\"Counting nodes ...\")\n",
    "\n",
    "i = 0\n",
    "for n in N.walk():\n",
    "    i += 1\n",
    "\n",
    "A.info(\"{} nodes\".format(i))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## What are those nodes?\n",
    "Every node has a type, like word, clause, or sentence.\n",
    "We know that we have approximately 13,000 words and a 3500 other nodes.\n",
    "But what exactly are they?\n",
    "\n",
    "Text-Fabric has two special features, `otype` and `oslots`, that must occur in every Text-Fabric data set.\n",
    "`otype` tells you for each node its type, and you can ask for the number of `slot`s in the text.\n",
    "\n",
    "Here we go!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:17:47.820323Z",
     "start_time": "2018-05-18T09:17:47.812328Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'word'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "F.otype.slotType"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:17:48.549430Z",
     "start_time": "2018-05-18T09:17:48.543371Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12922"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "F.otype.maxSlot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:17:49.251302Z",
     "start_time": "2018-05-18T09:17:49.244467Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "16664"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "F.otype.maxNode"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:17:49.922863Z",
     "start_time": "2018-05-18T09:17:49.916078Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('vagga', 'stanza', 'sentence', 'clause', 'word')"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "F.otype.all"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:17:51.782779Z",
     "start_time": "2018-05-18T09:17:51.774167Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(('vagga', 497.0, 16639, 16664),\n",
       " ('stanza', 27.20421052631579, 16164, 16638),\n",
       " ('sentence', 14.153340635268346, 15251, 16163),\n",
       " ('clause', 5.5506872852233675, 12923, 15250),\n",
       " ('word', 1, 1, 12922))"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "C.levels.data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is interesting: above you see all the textual objects, with the average size of their objects,\n",
    "the node where they start, and the node where they end."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Count individual object types\n",
    "This is an intuitive way to count the number of nodes in each type.\n",
    "Note in passing, how we use the `indent` in conjunction with `info` to produce neat timed\n",
    "and indented progress messages."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:17:57.806821Z",
     "start_time": "2018-05-18T09:17:57.558523Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  0.00s counting objects ...\n",
      "   |     0.00s      26 vaggas\n",
      "   |     0.00s     475 stanzas\n",
      "   |     0.00s     913 sentences\n",
      "   |     0.00s    2328 clauses\n",
      "   |     0.00s   12922 words\n",
      "  0.00s Done\n"
     ]
    }
   ],
   "source": [
    "A.indent(reset=True)\n",
    "A.info(\"counting objects ...\")\n",
    "\n",
    "for otype in F.otype.all:\n",
    "    i = 0\n",
    "\n",
    "    A.indent(level=1, reset=True)\n",
    "\n",
    "    for n in F.otype.s(otype):\n",
    "        i += 1\n",
    "\n",
    "    A.info(\"{:>7} {}s\".format(i, otype))\n",
    "\n",
    "A.indent(level=0)\n",
    "A.info(\"Done\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Viewing textual objects\n",
    "\n",
    "We use the A API (the extra power) to peek into the corpus."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First some words. Just to make sure that node 1 has type \"word\":"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'word'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "F.otype.v(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Some words in plain view:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:18:02.282178Z",
     "start_time": "2018-05-18T09:18:02.274117Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=003\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 3\">1 3</a></span></span>  <span class=\"txtu\">maṃ </span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=069\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"5 69\">5 69</a></span></span>  <span class=\"txtu\">[bālo] </span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=297\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"21 297\">21 297</a></span></span>  <span class=\"txtu\">(est). </span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "wordShows = (90, 2007, 9001)\n",
    "for word in wordShows:\n",
    "    A.plain(word, withPassage=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You see, words can be Pali and Latin.\n",
    "\n",
    "Before the words you see the vagga and stanza references.\n",
    "There is in fact a hyperlink underneath them. Click on it, and you go to the same stanza online,\n",
    "on the [Tipitaka site](https://www.tipitaka.net/tipitaka/dhp). \n",
    "This site provides an English translation and commentary.\n",
    "\n",
    "We can improve the layout a bit by setting the text format to a different value:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "A.displaySetup(fmt=\"layout-orig-full\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We do the same command again:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:18:02.282178Z",
     "start_time": "2018-05-18T09:18:02.274117Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=003\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 3\">1 3</a></span></span>  <span class=\"txtu\"><span class=\"quote1\">maṃ </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=069\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"5 69\">5 69</a></span></span>  <span class=\"txtu\"><span class=\"uncertain1\">[bālo] </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=297\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"21 297\">21 297</a></span></span>  <span class=\"txtu\"><span class=\"clarity1 trans1\">(est). </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "wordShows = (90, 2007, 9001)\n",
    "for word in wordShows:\n",
    "    A.plain(word, withPassage=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can leave out the passage reference:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"txtu\"><span class=\"quote1\">maṃ </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"txtu\"><span class=\"uncertain1\">[bālo] </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"txtu\"><span class=\"clarity1 trans1\">(est). </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for word in wordShows:\n",
    "    A.plain(word, withPassage=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we show other objects, both with and without passage reference."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "normalShow = dict(\n",
    "    wordShow=wordShows[0],\n",
    "    clauseShow=13290,\n",
    "    sentenceShow=15228,\n",
    ")\n",
    "\n",
    "sectionShow = dict(\n",
    "    stanzaShow=16431,\n",
    "    vaggaShow=16580,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "**wordShow** = node `90`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=003\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 3\">1 3</a></span></span>  <span class=\"txtu\"><span class=\"quote1\">maṃ </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"txtu\"><span class=\"quote1\">maṃ </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**clauseShow** = node `13290`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=068\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"5 68\">5 68</a></span></span>  <span class=\"txtu\"><span class=\"trans1\">Id </span></span><span class=\"txtu\"><span class=\"trans1\">vero </span></span><span class=\"txtu\"><span class=\"trans1\">facinus </span></span><span class=\"txtu\"><span class=\"trans1\">bene </span></span><span class=\"txtu\"><span class=\"trans1\">factum, </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"txtu\"><span class=\"trans1\">Id </span></span><span class=\"txtu\"><span class=\"trans1\">vero </span></span><span class=\"txtu\"><span class=\"trans1\">facinus </span></span><span class=\"txtu\"><span class=\"trans1\">bene </span></span><span class=\"txtu\"><span class=\"trans1\">factum, </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**sentenceShow** = node `15228`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=421\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"26 421\">26 421</a></span></span>  <span class=\"txtu\"><span class=\"trans1\">appetitus </span></span><span class=\"txtu\"><span class=\"trans1\">expertem, </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"txtu\"><span class=\"trans1\">appetitus </span></span><span class=\"txtu\"><span class=\"trans1\">expertem, </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for (name, n) in normalShow.items():\n",
    "    A.dm(f\"**{name}** = node `{n}`\\n\")\n",
    "    A.plain(n)\n",
    "    A.plain(n, withPassage=False)\n",
    "    A.dm(\"\\n---\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "**stanzaShow** = node `16431`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=1234\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"17 1234\">17 1234</a></span></span>  <span class=\"txtu\"><span class=\"extrastanza1\">Kodhavaggo </span></span><span class=\"txtu\"><span class=\"extrastanza1\">sattarasamo </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"txtu\"><span class=\"extrastanza1\">Kodhavaggo </span></span><span class=\"txtu\"><span class=\"extrastanza1\">sattarasamo </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**vaggaShow** = node `16580`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=368\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"25 368\">25 368</a></span></span>  <span class=\"txtu\">mettāvihārī </span><span class=\"txtu\">yo </span><span class=\"txtu\">bhikkhu </span><span class=\"txtu\">pasanno </span><span class=\"txtu\">Buddhasāsane </span><span class=\"txtu\">adhigacche </span><span class=\"txtu\">padaṃ </span><span class=\"txtu\">santaṃ </span><span class=\"txtu\">saṃkhārūpasamaṃ </span><span class=\"txtu\">sukhaṃ. </span><span class=\"txtu\"><span class=\"trans1\">Benevole </span></span><span class=\"txtu\"><span class=\"trans1\">vivens </span></span><span class=\"txtu\"><span class=\"trans1\">bhikkhus, </span></span><span class=\"txtu\"><span class=\"trans1\">Buddhae </span></span><span class=\"txtu\"><span class=\"trans1\">praeceptis </span></span><span class=\"txtu\"><span class=\"trans1\">sedatus, </span></span><span class=\"txtu\"><span class=\"trans1\">adit </span></span><span class=\"txtu\"><span class=\"trans1\">locum </span></span><span class=\"txtu\"><span class=\"trans1\">tranquillum, </span></span><span class=\"txtu\"><span class=\"trans1\">naturarum </span></span><span class=\"txtu\"><span class=\"clarity1 trans1\">(saṃkhārā) </span></span><span class=\"txtu\"><span class=\"trans1\">sedationem, </span></span><span class=\"txtu\"><span class=\"trans1\">gaudium. </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"txtu\">mettāvihārī </span><span class=\"txtu\">yo </span><span class=\"txtu\">bhikkhu </span><span class=\"txtu\">pasanno </span><span class=\"txtu\">Buddhasāsane </span><span class=\"txtu\">adhigacche </span><span class=\"txtu\">padaṃ </span><span class=\"txtu\">santaṃ </span><span class=\"txtu\">saṃkhārūpasamaṃ </span><span class=\"txtu\">sukhaṃ. </span><span class=\"txtu\"><span class=\"trans1\">Benevole </span></span><span class=\"txtu\"><span class=\"trans1\">vivens </span></span><span class=\"txtu\"><span class=\"trans1\">bhikkhus, </span></span><span class=\"txtu\"><span class=\"trans1\">Buddhae </span></span><span class=\"txtu\"><span class=\"trans1\">praeceptis </span></span><span class=\"txtu\"><span class=\"trans1\">sedatus, </span></span><span class=\"txtu\"><span class=\"trans1\">adit </span></span><span class=\"txtu\"><span class=\"trans1\">locum </span></span><span class=\"txtu\"><span class=\"trans1\">tranquillum, </span></span><span class=\"txtu\"><span class=\"trans1\">naturarum </span></span><span class=\"txtu\"><span class=\"clarity1 trans1\">(saṃkhārā) </span></span><span class=\"txtu\"><span class=\"trans1\">sedationem, </span></span><span class=\"txtu\"><span class=\"trans1\">gaudium. </span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for (name, n) in sectionShow.items():\n",
    "    if name == \"verseShow\":\n",
    "        continue\n",
    "    A.dm(f\"**{name}** = node `{n}`\\n\")\n",
    "    A.plain(n)\n",
    "    A.plain(n, withPassage=False)\n",
    "    A.dm(\"\\n---\\n\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that for vagga nodes the `withPassage` has little effect.\n",
    "The passage is the thing that is hyperlinked. The node is represented as a textual reference to the piece of text\n",
    "in question."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can also dive into the structure of the textual objects, provided they are not too large.\n",
    "\n",
    "The function `pretty` gives a display of the object that a node stands for together with the structure below that node."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "**wordShow** = node `90`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=003\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 3\">1 3</a></span></div><div class=\" children\"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"quote1\">maṃ </span></span></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**clauseShow** = node `13290`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=068\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"5 68\">5 68</a></span></div><div class=\" children\"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">Id </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">vero </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">facinus </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">bene </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">factum, </span></span></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**sentenceShow** = node `15228`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=421\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"26 421\">26 421</a></span></div><div class=\" children\"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">appetitus </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">expertem, </span></span></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for (name, n) in normalShow.items():\n",
    "    A.dm(f\"**{name}** = node `{n}`\\n\")\n",
    "    A.pretty(n)\n",
    "    A.dm(\"\\n---\\n\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note\n",
    "* if you click on the passage, you go to the [Tipitaka site](https://www.tipitaka.net/tipitaka/dhp).\n",
    "  Most of the time you go to the exact stanza, but on the Tipitaka site some stanzas are combined.\n",
    "  In that case you land on a table of contents and you can find the desired stanza easily."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you need a link to Tipitaka for just any node:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:18:15.022571Z",
     "start_time": "2018-05-18T09:18:15.016639Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=329\" title=\"Show this stanza with English translation and comments on Tipitaka\" sec=\"23 329\">23 329</a>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "tenthousand = 10000\n",
    "A.webLink(tenthousand)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can show some standard features in the display:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "**wordShow** = node `90`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=003\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 3\">1 3</a></span></div><div class=\" children\"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"quote1\">maṃ </span></span></div><div class='features'><span class=\"quote \" ><span class=\"f\">quote=</span>1</span></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**clauseShow** = node `13290`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=068\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"5 68\">5 68</a></span></div><div class=\" children\"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span> <span class=\"txtu\"><span title=\"n\">34</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">Id </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">vero </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">facinus </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">bene </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">factum, </span></span></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**sentenceShow** = node `15228`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=421\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"26 421\">26 421</a></span></div><div class=\" children\"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span> <span class=\"txtu\"><span title=\"n\">173</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">appetitus </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">expertem, </span></span></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**stanzaShow** = node `16431`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=1234\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"17 1234\">17 1234</a></span></div><div class=\" children\"><div class=\"contnr c3    \" ><div class=\"lbl c3  \" ><span class=\"nd\">stanza</span></div><div class=\"children hor wrap \"><div class=\"contnr c2    \" ><div class=\"lbl c2  \" ><span class=\"nd\">sentence</span> <span class=\"txtu\"><span title=\"n\">14</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span> <span class=\"txtu\"><span title=\"n\">21</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"extrastanza1\">Kodhavaggo </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"extrastanza1\">sattarasamo </span></span></div></div></div></div></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**vaggaShow** = node `16580`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=368\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"25 368\">25 368</a></span></div><div class=\" children\"><div class=\"contnr c3    \" ><div class=\"lbl c3  \" ><span class=\"nd\">stanza</span></div><div class=\"children hor wrap \"><div class=\"contnr c2    \" ><div class=\"lbl c2  \" ><span class=\"nd\">sentence</span> <span class=\"txtu\"><span title=\"n\">10</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span> <span class=\"txtu\"><span title=\"n\">18</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">mettāvihārī </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">yo </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">bhikkhu </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">pasanno </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">Buddhasāsane </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">adhigacche </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">padaṃ </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">santaṃ </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">saṃkhārūpasamaṃ </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">sukhaṃ. </span></div></div></div></div></div></div><div class=\"contnr c2    \" ><div class=\"lbl c2  \" ><span class=\"nd\">sentence</span> <span class=\"txtu\"><span title=\"n\">9</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span> <span class=\"txtu\"><span title=\"n\">34</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">Benevole </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">vivens </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">bhikkhus, </span></span></div></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span> <span class=\"txtu\"><span title=\"n\">35</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">Buddhae </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">praeceptis </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">sedatus, </span></span></div></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span> <span class=\"txtu\"><span title=\"n\">36</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">adit </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">locum </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">tranquillum, </span></span></div></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span> <span class=\"txtu\"><span title=\"n\">37</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">naturarum </span></span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"clarity1 trans1\">(saṃkhārā) </span></span></div><div class='features'><span class=\"clarity \" ><span class=\"f\">clarity=</span>1</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">sedationem, </span></span></div></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span> <span class=\"txtu\"><span title=\"n\">38</span></span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">gaudium. </span></span></div></div></div></div></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for (name, n) in list(normalShow.items()) + list(sectionShow.items()):\n",
    "    A.dm(f\"**{name}** = node `{n}`\\n\")\n",
    "    A.pretty(n, standardFeatures=True)\n",
    "    A.dm(\"\\n---\\n\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Or we can command a specific feature to show up:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "**wordShow** = node `90`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=003\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 3\">1 3</a></span></div><div class=\" children\"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"quote1\">maṃ </span></span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>7</span></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**clauseShow** = node `13290`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=068\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"5 68\">5 68</a></span></div><div class=\" children\"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">Id </span></span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>1</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">vero </span></span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>26</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">facinus </span></span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>8</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">bene </span></span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>25</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">factum, </span></span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>14</span></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**sentenceShow** = node `15228`\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=421\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"26 421\">26 421</a></span></div><div class=\" children\"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">appetitus </span></span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>1</span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\"><span class=\"trans1\">expertem, </span></span></div><div class='features'><span class=\"freq_occ xft\" ><span class=\"f\">freq_occ=</span>9</span></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "\n",
       "---\n"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for (name, n) in list(normalShow.items()):\n",
    "    A.dm(f\"**{name}** = node `{n}`\\n\")\n",
    "    A.pretty(n, extraFeatures=\"freq_occ\")\n",
    "    A.dm(\"\\n---\\n\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Feature statistics\n",
    "\n",
    "`F`\n",
    "gives access to all features.\n",
    "Every feature has a method\n",
    "`freqList()`\n",
    "to generate a frequency list of its values, higher frequencies first.\n",
    "Here is a top 20 of the Pali words:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:18:18.039544Z",
     "start_time": "2018-05-18T09:18:17.784073Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(('ca', 181),\n",
       " ('na', 143),\n",
       " ('va', 73),\n",
       " ('yo', 54),\n",
       " (\"n'\", 47),\n",
       " ('atthi', 41),\n",
       " ('tam', 38),\n",
       " ('so', 36),\n",
       " ('hi', 35),\n",
       " ('hoti', 33),\n",
       " ('taṃ', 30),\n",
       " ('ve', 30),\n",
       " ('te', 28),\n",
       " ('pi', 26),\n",
       " ('attano', 24),\n",
       " ('ce', 24),\n",
       " ('etaṃ', 22),\n",
       " ('eva', 22),\n",
       " ('vā', 22),\n",
       " ('bhikkhu', 21))"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "F.pali.freqList()[0:20]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And here for Latin:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:18:18.039544Z",
     "start_time": "2018-05-18T09:18:17.784073Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(('non', 220),\n",
       " ('et', 150),\n",
       " ('est', 137),\n",
       " ('in', 120),\n",
       " ('velut', 66),\n",
       " ('qui', 64),\n",
       " ('eum', 48),\n",
       " ('homo', 39),\n",
       " ('hoc', 37),\n",
       " ('vel', 37),\n",
       " ('Non', 36),\n",
       " ('dico', 36),\n",
       " ('is', 35),\n",
       " ('ego', 34),\n",
       " ('ad', 33),\n",
       " ('brāhmanam', 33),\n",
       " ('sapiens', 33),\n",
       " ('fit', 32),\n",
       " ('a', 30),\n",
       " ('gaudium', 30))"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "F.latin.freqList()[0:20]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Word distribution\n",
    "\n",
    "Let's do a bit more fancy word stuff.\n",
    "\n",
    "### Hapaxes\n",
    "\n",
    "A hapax is a unique word.\n",
    "Note that we have not (yet) lexeme information, so all we count are word occurrences.\n",
    "We are oblivious to the fact that the same word may occur in several forms.\n",
    "\n",
    "We print 10 Pali hapaxes and 10 Latin hapaxes.\n",
    "\n",
    "Let's do it with search templates.\n",
    "Remember that we have a feature `trans` that indicates whether an object belongs to the Pali text or to the Latin text.\n",
    "But we forgot the details.\n",
    "\n",
    "We call it up!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "trans                node (int) whether the node belongs to the original text or a translation\n"
     ]
    }
   ],
   "source": [
    "A.isLoaded(\"trans\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Good, but a little bit more info please:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "trans                node (int)\n",
      "\tconverters           = Dirk Roorda (Text-Fabric)\n",
      "\tcopynote1            = Digitisation supported by Shri Brihad Bhartiya Samaj 20 February 2020\n",
      "\tdateWritten          = 2021-12-24T14:49:10Z\n",
      "\tdescription          = whether the node belongs to the original text or a translation\n",
      "\tdigitizers           = Bee Scherer, Yvonne Mataar\n",
      "\tedition              = 2nd\n",
      "\teditor               = V. Fausboll\n",
      "\tformat               = 1 (=Latin translation) or absent (=Pali original)\n",
      "\tinstitute            = Text and Traditions, VU Amsterdam\n",
      "\tlanguage             = pli,lat\n",
      "\tplace                = London\n",
      "\tproject              = Dhammapada-latine\n",
      "\tpublisher            = Luzac & Co.\n",
      "\tresearcher           = Bee Scherer\n",
      "\tsourceFormat         = plain text\n",
      "\tstamp                = 50480\n",
      "\tsubtitle             = being a collection of moral verses in Pali\n",
      "\ttitle                = The Dhammapada\n",
      "\tversion              = 0.2\n",
      "\twrittenBy            = Text-Fabric\n",
      "\tyearPublished        = 1900\n"
     ]
    }
   ],
   "source": [
    "A.isLoaded(\"trans\", pretty=True, meta=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "We see under key `format`: value 1 means Latin, absence of value means Pali.\n",
    "\n",
    "In queries, we can select for exactly that:\n",
    "\n",
    "`trans#` means: feature `trans` does not have a value for the node\n",
    "`trans` means: feature `trans` has a value for the node\n",
    "\n",
    "So here are two templates: one for the Pali hapaxes and one for the Latin hapaxes.\n",
    "We run them both."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  0.01s 2006 results\n",
      "  0.01s 1841 results\n"
     ]
    }
   ],
   "source": [
    "query = \"\"\"\n",
    "word trans# freq_occ=1\n",
    "\"\"\"\n",
    "paliResults = A.search(query, sort=True)\n",
    "\n",
    "query = \"\"\"\n",
    "word trans freq_occ=1\n",
    "\"\"\"\n",
    "latinResults = A.search(query, sort=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we print the first 10 results of both:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><tr class=\"tf ltr\"><th class=\"tf ltr\">n</th><th class=\"tf ltr\">p</th><th class=\"tf ltr\">word</th></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">1</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=1001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1001\">1 1001</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\"><span class=\"extrastanza1\">Yamakavagga </span></span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">2</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\">paduṭṭhena </span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">3</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\">cakkaṃ </span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">4</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\">vahato </span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">5</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=002\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 2\">1 2</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\">pasannena </span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">6</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=002\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 2\">1 2</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\">chāyā </span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">7</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=002\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 2\">1 2</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\">anapāyinī. </span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">8</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=003\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 3\">1 3</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\">upanayihanti </span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">9</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=003\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 3\">1 3</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\">sammati. </span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">10</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=004\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 4\">1 4</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\">upanayhanti </span></span></span></td></tr></table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<table><tr class=\"tf ltr\"><th class=\"tf ltr\">n</th><th class=\"tf ltr\">p</th><th class=\"tf ltr\">word</th></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">1</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\"><span class=\"trans1\">principium </span></span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">2</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\"><span class=\"trans1\">potior </span></span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">3</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\"><span class=\"trans1\">pars </span></span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">4</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\"><span class=\"trans1\">earum, </span></span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">5</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\"><span class=\"trans1\">constant; </span></span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">6</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\"><span class=\"trans1\">inquinata </span></span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">7</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\"><span class=\"trans1\">rota </span></span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">8</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\"><span class=\"clarity1 trans1\">(bovis) </span></span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">9</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\"><span class=\"trans1\">vehentis </span></span></span></span></td></tr>\n",
       "<tr class=\"tf ltr\"><td class=\"tf ltr\">10</td><td class=\"tf ltr\"><span class=\"tfsechead ltr\"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 1\">1 1</a></span></span></td><td class=\"tf ltr\"><span class=\" ubd\"><span class=\"plain   hl\" ><span class=\"txtu\"><span class=\"trans1\">pedem. </span></span></span></span></td></tr></table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "A.table(paliResults, end=10)\n",
    "A.table(latinResults, end=10)\n",
    "A.displayReset(\"tupleFeatures\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can also get hapaxes by means of ordinary Python programming.\n",
    "We show this lower level way of working as well, because we are going to need it.\n",
    "\n",
    "We use the feature `freq_occ`  and `trans` again."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pali-hapaxes\n",
      "Yamakavagga\n",
      "paduṭṭhena\n",
      "cakkaṃ\n",
      "vahato\n",
      "pasannena\n",
      "chāyā\n",
      "anapāyinī\n",
      "upanayihanti\n",
      "sammati\n",
      "upanayhanti\n",
      "\n",
      "latin-hapaxes\n",
      "principium\n",
      "potior\n",
      "pars\n",
      "earum\n",
      "constant\n",
      "inquinata\n",
      "rota\n",
      "bovis\n",
      "vehentis\n",
      "pedem\n"
     ]
    }
   ],
   "source": [
    "paliHapaxes = []\n",
    "latinHapaxes = []\n",
    "for w in F.otype.s(\"word\"):\n",
    "    if F.freq_occ.v(w) == 1:\n",
    "        if F.trans.v(w):\n",
    "            latinHapaxes.append(F.latin.v(w))\n",
    "        else:\n",
    "            paliHapaxes.append(F.pali.v(w))\n",
    "        if len(paliHapaxes) >= 10 and len(latinHapaxes) >= 10:\n",
    "            break\n",
    "            \n",
    "print(\"pali-hapaxes\")\n",
    "for hapax in paliHapaxes[0:10]:\n",
    "    print(hapax)\n",
    "print(\"\\nlatin-hapaxes\")\n",
    "for hapax in latinHapaxes[0:10]:\n",
    "    print(hapax)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There is yet another quite different way of getting the hapaxes:\n",
    "\n",
    "We use the function `freqList()` that is available for every feature in every text-fabric dataset.\n",
    "It produces a frequency list of the values of that feature."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2009 pali-hapaxes\n",
      "\t'bhivaḍḍhati\n",
      "\t'ham\n",
      "\t'samānasaṃvāso\n",
      "\t'taro\n",
      "\t'tivākyaṃ\n",
      "\t'yaṃ\n",
      "\t*1\n",
      "\t*2\n",
      "\t*3\n",
      "\tAntako\n",
      "1843 latin-hapaxes\n",
      "\t-omni\n",
      "\tAc\n",
      "\tAd\n",
      "\tAdmoneat\n",
      "\tAetatem\n",
      "\tAffectibus\n",
      "\tAlia\n",
      "\tAlieni\n",
      "\tAliis\n",
      "\tAliorum\n"
     ]
    }
   ],
   "source": [
    "for lang in (\"pali\", \"latin\"):\n",
    "    hapaxes = sorted(word for (word, freq) in Fs(lang).freqList() if freq == 1)\n",
    "    print(f\"{len(hapaxes):>4} {lang}-hapaxes\")\n",
    "    for hapax in hapaxes[0:10]:\n",
    "        print(f\"\\t{hapax}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This gives us hapaxes indeed, but sorted by the word form.\n",
    "Before we got them in the order in which they show up in de text.\n",
    "\n",
    "Additionally, we see how many hapaxes there are in the corpus.\n",
    "\n",
    "But, wait a minute: the numbers do not agree!\n",
    "\n",
    "The query says: 2006 and 1841 hapaxes.\n",
    "\n",
    "Above we get: 2009 and 1843 ones.\n",
    "\n",
    "How can that be?\n",
    "\n",
    "Well, the query looks for true hapaxes, words that occur only once in the whole corpus, Pali and Latin\n",
    "taken together.\n",
    "\n",
    "The `freqList()` mode has been computed for the feature it is called on.\n",
    "So we have a separate frequency list for Pali and for Latin.\n",
    "\n",
    "If there words that occur both in Pali and in Latin, it could indeed cause discrepancies.\n",
    "\n",
    "Let's put our finger on it.\n",
    "\n",
    "We find the pali hapaxes that are extra w.r.t. to the query results."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2009"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hapsFreqList = {x[0] for x in F.pali.freqList() if x[1] == 1}\n",
    "len(hapsFreqList)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2006"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hapsQuery = {F.pali.v(w[0]) for w in paliResults}\n",
    "len(hapsQuery)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We pick the difference:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Atula', 'Buddham', 'saṃsāro'}"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hapsFreqList - hapsQuery"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now the corresponding nodes:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1732: 'saṃsāro', 5511: 'Buddham', 6846: 'Atula'}"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nodesPali = {n: F.pali.v(n) for n in F.otype.s(\"word\") if F.pali.v(n) in {'Atula', 'Buddham', 'saṃsāro'}}\n",
    "nodesPali"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We now get the occurrences of these words in Latin sentences:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1745: 'saṃsāro',\n",
       " 5492: 'Buddham',\n",
       " 5527: 'Buddham',\n",
       " 5816: 'Buddham',\n",
       " 6868: 'Atula',\n",
       " 8971: 'Buddham'}"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nodesLatin = {n: F.latin.v(n) for n in F.otype.s(\"word\") if F.latin.v(n) in {'Atula', 'Buddham', 'saṃsāro'}}\n",
    "nodesLatin"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Indeed, all these words have Latin occurrences."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Small occurrence base\n",
    "\n",
    "The occurrence base of a word are the stanzas and vaggas in which occurs.\n",
    "Let's look for words that occur in a single vagga."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:18:36.257701Z",
     "start_time": "2018-05-18T09:18:36.082461Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  0.00s Separating words into Pali and Latin\n",
      "  0.01s  5532 pali words\n",
      "  0.01s  7390 latin words\n"
     ]
    }
   ],
   "source": [
    "A.indent(reset=True)\n",
    "A.info(\"Separating words into Pali and Latin\")\n",
    "\n",
    "words = dict(pali=[], latin=[])\n",
    "\n",
    "for w in F.otype.s(\"word\"):\n",
    "    if F.trans.v(w):\n",
    "        words[\"latin\"].append(w)\n",
    "    else:\n",
    "        words[\"pali\"].append(w)\n",
    "        \n",
    "for (lang, ws) in words.items():\n",
    "    A.info(f\"{len(ws):>5} {lang} words\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We write a function that collects for each word the vaggas they occur in.\n",
    "\n",
    "The function accepts a parameter which holds the words we are interested in.\n",
    "\n",
    "We use a part of the TF-API, `L` (=locality) that will be explained later.\n",
    "`L.u()` finds nodes that embed a given node."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:18:36.257701Z",
     "start_time": "2018-05-18T09:18:36.082461Z"
    }
   },
   "outputs": [],
   "source": [
    "def inVaggas(wordList):\n",
    "    wordInVagga = collections.defaultdict(set)\n",
    "    \n",
    "    for w in wordList:\n",
    "        word = F.latin.v(w) if F.trans.v(w) else F.pali.v(w)\n",
    "        v = L.u(w, otype=\"vagga\")\n",
    "        wordInVagga[word].add(v)\n",
    "        \n",
    "    return wordInVagga"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We call the function for the Pali words and for the Latin words:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "wordInVagga = {}\n",
    "\n",
    "for (lang, ws) in words.items():\n",
    "    wordInVagga[lang] = inVaggas(ws)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's count how many words are confined to exactly one vagga, i.e. words that occur in one vagga or another and nowhere else.\n",
    "\n",
    "And we want to know how many words occur in exactly 2 vaggas, and so on."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pali word distribution over number of vaggas\n",
      "\t   1 word  confined to 26 vaggas\n",
      "\t   1 word  confined to 25 vaggas\n",
      "\t   1 word  confined to 22 vaggas\n",
      "\t   2 words confined to 19 vaggas\n",
      "\t   1 word  confined to 18 vaggas\n",
      "\t   2 words confined to 17 vaggas\n",
      "\t   3 words confined to 15 vaggas\n",
      "\t   4 words confined to 14 vaggas\n",
      "\t   1 word  confined to 13 vaggas\n",
      "\t   1 word  confined to 12 vaggas\n",
      "\t   2 words confined to 11 vaggas\n",
      "\t   2 words confined to 10 vaggas\n",
      "\t   4 words confined to  9 vaggas\n",
      "\t   8 words confined to  8 vaggas\n",
      "\t   6 words confined to  7 vaggas\n",
      "\t  19 words confined to  6 vaggas\n",
      "\t  14 words confined to  5 vaggas\n",
      "\t  41 words confined to  4 vaggas\n",
      "\t  90 words confined to  3 vaggas\n",
      "\t 272 words confined to  2 vaggas\n",
      "\t2284 words confined to  1 vagga \n",
      "latin word distribution over number of vaggas\n",
      "\t   2 words confined to 26 vaggas\n",
      "\t   1 word  confined to 25 vaggas\n",
      "\t   1 word  confined to 24 vaggas\n",
      "\t   1 word  confined to 22 vaggas\n",
      "\t   1 word  confined to 20 vaggas\n",
      "\t   1 word  confined to 18 vaggas\n",
      "\t   1 word  confined to 17 vaggas\n",
      "\t   2 words confined to 16 vaggas\n",
      "\t   5 words confined to 15 vaggas\n",
      "\t   5 words confined to 14 vaggas\n",
      "\t   3 words confined to 13 vaggas\n",
      "\t   3 words confined to 12 vaggas\n",
      "\t   4 words confined to 11 vaggas\n",
      "\t   5 words confined to 10 vaggas\n",
      "\t  11 words confined to  9 vaggas\n",
      "\t  14 words confined to  8 vaggas\n",
      "\t  14 words confined to  7 vaggas\n",
      "\t  25 words confined to  6 vaggas\n",
      "\t  41 words confined to  5 vaggas\n",
      "\t  80 words confined to  4 vaggas\n",
      "\t 154 words confined to  3 vaggas\n",
      "\t 401 words confined to  2 vaggas\n",
      "\t2118 words confined to  1 vagga \n"
     ]
    }
   ],
   "source": [
    "for (lang, invg) in wordInVagga.items():\n",
    "    print(f\"{lang} word distribution over number of vaggas\")\n",
    "    wordDist = collections.Counter()\n",
    "    for vs in invg.values():\n",
    "        wordDist[len(vs)] += 1\n",
    "    for (nv, nw) in sorted(wordDist.items(), key=lambda x: (-x[0], x[1])):\n",
    "        wPlural = \" \" if nw == 1 else \"s\" \n",
    "        vPlural = \" \" if nv == 1 else \"s\" \n",
    "        print(f\"\\t{nw:>4} word{wPlural} confined to {nv:>2} vagga{vPlural}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Extravagant vaggas\n",
    "\n",
    "It would be interesting to know for each vagga what the proportion is of the words that are confined to it\n",
    "relative to the total number of words.\n",
    "Vaggas that score higher by this measure are in a sense more extravagant that vaggas that score lower.\n",
    "\n",
    "Let's compute that list.\n",
    "\n",
    "We use `L.d()` which finds the nodes that are embedded in a given node."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:18:52.143337Z",
     "start_time": "2018-05-18T09:18:52.130385Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "vagga Pali         |Latin        \n",
      "      #all #own  %own | #all #own  %own\n",
      "----------------------------------------\n",
      "24    258  173 67.1% |  325  152 46.8%\n",
      "11    125   82 65.6% |  157   86 54.8%\n",
      "7     106   69 65.1% |  148   53 35.8%\n",
      "3     103   64 62.1% |  133   64 48.1%\n",
      "2     116   72 62.1% |  143   63 44.1%\n",
      "12    110   68 61.8% |  141   52 36.9%\n",
      "26    343  212 61.8% |  394  184 46.7%\n",
      "4     137   84 61.3% |  180   79 43.9%\n",
      "21    120   73 60.8% |  149   59 39.6%\n",
      "1     171  104 60.8% |  207   86 41.5%\n",
      "23    155   94 60.6% |  189   89 47.1%\n",
      "22    142   85 59.9% |  180   80 44.4%\n",
      "19    137   80 58.4% |  169   71 42.0%\n",
      "20    168   98 58.3% |  221   97 43.9%\n",
      "14    167   97 58.1% |  209   90 43.1%\n",
      "18    195  110 56.4% |  249  117 47.0%\n",
      "16     86   47 54.7% |  110   48 43.6%\n",
      "8     117   63 53.8% |  155   64 41.3%\n",
      "15    108   58 53.7% |  138   57 41.3%\n",
      "6     149   80 53.7% |  184   80 43.5%\n",
      "25    207  111 53.6% |  265  105 39.6%\n",
      "5     161   86 53.4% |  199   81 40.7%\n",
      "17    131   69 52.7% |  159   64 40.3%\n",
      "10    176   91 51.7% |  214  102 47.7%\n",
      "9     118   61 51.7% |  135   46 34.1%\n",
      "13    113   53 46.9% |  137   49 35.8%\n"
     ]
    }
   ],
   "source": [
    "print(f\"vagga {'Pali':<13}|{'Latin':<13}\")\n",
    "print(\n",
    "    \"{:<5} {:>4} {:>4} {:>5} | {:>4} {:>4} {:>5}\\n{}\".format(\n",
    "        \"\",\n",
    "        \"#all\",\n",
    "        \"#own\",\n",
    "        \"%own\",\n",
    "        \"#all\",\n",
    "        \"#own\",\n",
    "        \"%own\",\n",
    "        \"-\" * 40,\n",
    "    )\n",
    ")\n",
    "vaggaList = []\n",
    "\n",
    "for v in F.otype.s(\"vagga\"):\n",
    "    vagga = F.n.v(v)\n",
    "    ws = L.d(v, otype=\"word\")\n",
    "    wordsPali = {F.pali.v(w) for w in ws if not F.trans.v(w)}\n",
    "    allPali = len(wordsPali)\n",
    "    wordsLatin = {F.latin.v(w) for w in ws if F.trans.v(w)}\n",
    "    allLatin = len(wordsLatin)\n",
    "    singlePali = sum(1 for word in wordsPali if len(wordInVagga[\"pali\"][word]) == 1)\n",
    "    singleLatin = sum(1 for word in wordsLatin if len(wordInVagga[\"latin\"][word]) == 1)\n",
    "    percentPali = 100 * singlePali / allPali\n",
    "    percentLatin = 100 * singleLatin / allLatin\n",
    "    vaggaList.append((vagga, allPali, singlePali, percentPali, allLatin, singleLatin, percentLatin))\n",
    "\n",
    "for x in sorted(vaggaList, key=lambda e: (-e[3], -e[2], e[1])):\n",
    "    print(\"{:<2}   {:>4} {:>4} {:>4.1f}% | {:>4} {:>4} {:>4.1f}%\".format(*x))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that the least extravagant vagga in Pali is also one of the least extravagant vaggas in Latin.\n",
    "And the second most extravagant vagga in Pali is the most extravagant vagga in Latin."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "# Locality API\n",
    "We travel upwards and downwards, forwards and backwards through the nodes.\n",
    "The Locality-API (`L`) provides functions: `u()` for going up, and `d()` for going down,\n",
    "`n()` for going to next nodes and `p()` for going to previous nodes.\n",
    "\n",
    "These directions are indirect notions: nodes are just numbers, but by means of the\n",
    "`oslots` feature they are linked to slots. One node *contains* an other node, if the one is linked to a set of slots that contains the set of slots that the other is linked to.\n",
    "And one if next or previous to an other, if its slots follow or precede the slots of the other one.\n",
    "\n",
    "`L.u(node)` **Up** is going to nodes that embed `node`.\n",
    "\n",
    "`L.d(node)` **Down** is the opposite direction, to those that are contained in `node`.\n",
    "\n",
    "`L.n(node)` **Next** are the next *adjacent* nodes, i.e. nodes whose first slot comes immediately after the last slot of `node`.\n",
    "\n",
    "`L.p(node)` **Previous** are the previous *adjacent* nodes, i.e. nodes whose last slot comes immediately before the first slot of `node`.\n",
    "\n",
    "All these functions yield nodes of all possible node types.\n",
    "By passing an optional parameter, you can restrict the results to nodes of that type.\n",
    "\n",
    "The result are ordered according to the order of things in the text.\n",
    "\n",
    "The functions return always a tuple, even if there is just one node in the result.\n",
    "\n",
    "## Going up\n",
    "We go from the 10th word to the vagga it contains.\n",
    "Note the `[0]` at the end. You expect one vagga yet `L` returns a tuple.\n",
    "To get the only element of that tuple, you need to do that `[0]`.\n",
    "\n",
    "If you are like me, you keep forgetting it, and that will lead to weird error messages later on."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:18:55.410034Z",
     "start_time": "2018-05-18T09:18:55.404051Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "16639\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div class=\"\"><span class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=1001\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1\">1</a></span></span>  <span class=\"txtu \"><span class=\"tfsechead ltr\"><span class=\"ltr\"> </span></span></span></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "w = 10\n",
    "firstVagga = L.u(w, otype=\"vagga\")[0]\n",
    "print(firstVagga)\n",
    "A.plain(firstVagga)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The **1** is a hyperlink that takes you to the online version of the vagga."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And let's see all the containing objects of word 10:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:18:56.772513Z",
     "start_time": "2018-05-18T09:18:56.766324Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "word 10 is contained in vagga 16639\n",
      "word 10 is contained in stanza 16165\n",
      "word 10 is contained in sentence 15252\n",
      "word 10 is contained in clause 12925\n"
     ]
    }
   ],
   "source": [
    "for otype in F.otype.all:\n",
    "    if otype == F.otype.slotType:\n",
    "        continue\n",
    "    up = L.u(w, otype=otype)\n",
    "    upNode = \"x\" if len(up) == 0 else up[0]\n",
    "    print(\"word {} is contained in {} {}\".format(w, otype, upNode))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Going next\n",
    "Let's go to the next nodes of the first vagga."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:18:58.821681Z",
     "start_time": "2018-05-18T09:18:58.814893Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    687: word          first slot=687   , last slot=687   \n",
      "  13047: clause        first slot=687   , last slot=687   \n",
      "  15297: sentence      first slot=687   , last slot=687   \n",
      "  16186: stanza        first slot=687   , last slot=687   \n",
      "  16640: vagga         first slot=687   , last slot=987   \n"
     ]
    }
   ],
   "source": [
    "afterFirstVagga = L.n(firstVagga)\n",
    "for n in afterFirstVagga:\n",
    "    print(\n",
    "        \"{:>7}: {:<13} first slot={:<6}, last slot={:<6}\".format(\n",
    "            n,\n",
    "            F.otype.v(n),\n",
    "            E.oslots.s(n)[0],\n",
    "            E.oslots.s(n)[-1],\n",
    "        )\n",
    "    )\n",
    "secondVagga = L.n(firstVagga, otype=\"vagga\")[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Going previous\n",
    "\n",
    "And let's see what is right before the second book."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:19:00.163973Z",
     "start_time": "2018-05-18T09:19:00.154857Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  16639: vagga         first slot=1     , last slot=686   \n",
      "  16185: stanza        first slot=685   , last slot=686   \n",
      "  15296: sentence      first slot=685   , last slot=686   \n",
      "  13046: clause        first slot=685   , last slot=686   \n",
      "    686: word          first slot=686   , last slot=686   \n"
     ]
    }
   ],
   "source": [
    "for n in L.p(secondVagga):\n",
    "    print(\n",
    "        \"{:>7}: {:<13} first slot={:<6}, last slot={:<6}\".format(\n",
    "            n,\n",
    "            F.otype.v(n),\n",
    "            E.oslots.s(n)[0],\n",
    "            E.oslots.s(n)[-1],\n",
    "        )\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Going down"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We go to the stanzas of the second book, and just count them."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:19:02.530705Z",
     "start_time": "2018-05-18T09:19:02.475279Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "14\n"
     ]
    }
   ],
   "source": [
    "stanzas = L.d(secondVagga, otype=\"stanza\")\n",
    "print(len(stanzas))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The 10th stanza\n",
    "We pick the 10th stanza and explore what is above and below it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:19:04.024679Z",
     "start_time": "2018-05-18T09:19:03.995207Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Node 16174\n",
      "   |   UP\n",
      "   |      |   16639           vagga\n",
      "   |   DOWN\n",
      "   |      |   15272           sentence\n",
      "   |      |   12980           clause\n",
      "   |      |   314             word\n",
      "   |      |   315             word\n",
      "   |      |   316             word\n",
      "   |      |   317             word\n",
      "   |      |   318             word\n",
      "   |      |   319             word\n",
      "   |      |   320             word\n",
      "   |      |   321             word\n",
      "   |      |   322             word\n",
      "   |      |   323             word\n",
      "   |      |   324             word\n",
      "   |      |   325             word\n",
      "   |      |   15273           sentence\n",
      "   |      |   12981           clause\n",
      "   |      |   326             word\n",
      "   |      |   327             word\n",
      "   |      |   328             word\n",
      "   |      |   329             word\n",
      "   |      |   12982           clause\n",
      "   |      |   330             word\n",
      "   |      |   331             word\n",
      "   |      |   332             word\n",
      "   |      |   12983           clause\n",
      "   |      |   333             word\n",
      "   |      |   334             word\n",
      "   |      |   335             word\n",
      "   |      |   336             word\n",
      "   |      |   12984           clause\n",
      "   |      |   337             word\n",
      "   |      |   338             word\n",
      "   |      |   339             word\n",
      "   |      |   340             word\n",
      "   |      |   341             word\n",
      "   |      |   342             word\n",
      "Done\n"
     ]
    }
   ],
   "source": [
    "s = F.otype.s(\"stanza\")[10]\n",
    "A.indent(level=0, reset=True)\n",
    "A.info(\"Node {}\".format(s), tm=False)\n",
    "A.indent(level=1)\n",
    "A.info(\"UP\", tm=False)\n",
    "A.indent(level=2)\n",
    "A.info(\"\\n\".join([\"{:<15} {}\".format(u, F.otype.v(u)) for u in L.u(s)]), tm=False)\n",
    "A.indent(level=1)\n",
    "A.info(\"DOWN\", tm=False)\n",
    "A.indent(level=2)\n",
    "A.info(\"\\n\".join([\"{:<15} {}\".format(u, F.otype.v(u)) for u in L.d(s)]), tm=False)\n",
    "A.indent(level=0)\n",
    "A.info(\"Done\", tm=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Text API\n",
    "\n",
    "So far, we have mainly seen nodes and their numbers, and the names of node types.\n",
    "You would almost forget that we are dealing with text.\n",
    "So let's try to see some text.\n",
    "\n",
    "In the same way as `F` gives access to feature data,\n",
    "`T` gives access to the text.\n",
    "That is also feature data, but you can tell Text-Fabric which features are specifically\n",
    "carrying the text, and in return Text-Fabric offers you\n",
    "a Text API: `T`.\n",
    "\n",
    "## Formats\n",
    "The Dhammapada text can be represented in a number of ways:\n",
    "\n",
    "* all text (Pali and Latin)\n",
    "* only Pali\n",
    "* only Latin\n",
    "\n",
    "If you wonder where the information about text formats is stored:\n",
    "not in the program text-fabric, but in the data set.\n",
    "It has a feature `otext`, which specifies the formats and which features\n",
    "must be used to produce them. `otext` is the third special feature in a TF data set,\n",
    "next to `otype` and `oslots`.\n",
    "It is an optional feature.\n",
    "If it is absent, there will be no `T` API.\n",
    "\n",
    "Here is a list of all available formats in this data set."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:19:05.606582Z",
     "start_time": "2018-05-18T09:19:05.593486Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['layout-latin-full',\n",
       " 'layout-orig-full',\n",
       " 'layout-pali-full',\n",
       " 'text-latin-full',\n",
       " 'text-orig-full',\n",
       " 'text-pali-full']"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sorted(T.formats)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Using the formats\n",
    "\n",
    "We can pretty display in the default format, which is `text-orig-full`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=010\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 10\">1 10</a></span></div><div class=\" children\"><div class=\"contnr c3    \" ><div class=\"lbl c3  \" ><span class=\"nd\">stanza</span></div><div class=\"children hor wrap \"><div class=\"contnr c2    \" ><div class=\"lbl c2  \" ><span class=\"nd\">sentence</span></div><div class=\"children hor wrap \"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">yo </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">ca </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">vantakasāv' </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">assa </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">sīlesu </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">susamāhito </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">upeto </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">damasaccena </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">sa </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">ve </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">kāsāvam </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">arhati. </span></div></div></div></div></div></div><div class=\"contnr c2    \" ><div class=\"lbl c2  \" ><span class=\"nd\">sentence</span></div><div class=\"children hor wrap \"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">Qui </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">vero </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">affectus </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">respuit, </span></div></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">virtutibus </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">bene </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">instructus, </span></div></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">temperantia </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">et </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">veritate </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">praeditus, </span></div></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">ille </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">certe </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">fulva </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">veste </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">dignus </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtu\">est. </span></div></div></div></div></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "s = F.otype.s(\"stanza\")[10]\n",
    "A.pretty(s, fmt=\"text-orig-full\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Or Pali -only:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=010\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 10\">1 10</a></span></div><div class=\" children\"><div class=\"contnr c3    \" ><div class=\"lbl c3  \" ><span class=\"nd\">stanza</span></div><div class=\"children hor wrap \"><div class=\"contnr c2    \" ><div class=\"lbl c2  \" ><span class=\"nd\">sentence</span></div><div class=\"children hor wrap \"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">yo </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">ca </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">vantakasāv' </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">assa </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">sīlesu </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">susamāhito </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">upeto </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">damasaccena </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">sa </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">ve </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">kāsāvam </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">arhati. </span></div></div></div></div></div></div><div class=\"contnr c2    \" ><div class=\"lbl c2  \" ><span class=\"nd\">sentence</span></div><div class=\"children hor wrap \"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div></div></div></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "A.pretty(s, fmt=\"text-pali-full\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Or Latin only"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"tfsechead \"><span class=\"ltr\"><a target=\"_blank\" href=\"https://www.tipitaka.net/tipitaka/dhp/verseload.php?verse=010\" title=\"Show this stanza with English translation and comments on tipitaka\" sec=\"1 10\">1 10</a></span></div><div class=\" children\"><div class=\"contnr c3    \" ><div class=\"lbl c3  \" ><span class=\"nd\">stanza</span></div><div class=\"children hor wrap \"><div class=\"contnr c2    \" ><div class=\"lbl c2  \" ><span class=\"nd\">sentence</span></div><div class=\"children hor wrap \"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div><div class=\"contnr c0 trm   \" ></div></div></div></div></div><div class=\"contnr c2    \" ><div class=\"lbl c2  \" ><span class=\"nd\">sentence</span></div><div class=\"children hor wrap \"><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">Qui </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">vero </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">affectus </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">respuit, </span></div></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">virtutibus </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">bene </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">instructus, </span></div></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">temperantia </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">et </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">veritate </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">praeditus, </span></div></div></div></div><div class=\"contnr c1    \" ><div class=\"lbl c1  \" ><span class=\"nd\">clause</span></div><div class=\"children hor wrap \"><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">ille </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">certe </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">fulva </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">veste </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">dignus </span></div></div><div class=\"contnr c0 trm   \" ><div class=\"lbl c0 trm \" ><span class=\"txtn\">est. </span></div></div></div></div></div></div></div></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "A.pretty(s, fmt=\"text-latin-full\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## T.text()\n",
    "\n",
    "This function is central to get text representations of nodes. Its most basic usage is\n",
    "\n",
    "```python\n",
    "T.text(nodes, fmt=fmt)\n",
    "```\n",
    "where `nodes` is a list or iterable of nodes, usually word nodes, and `fmt` is the name of a format.\n",
    "If you leave out `fmt`, the default `text-orig-full` is chosen.\n",
    "\n",
    "The result is the text in that format for all nodes specified:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Yamakavagga manopubbaṅgamā dhammā manoseṭṭhā manomayā, manasā ce paduṭṭhena bhāsatī vā karoti '"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "T.text([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], fmt=\"text-orig-full\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There is also another usage of this function:\n",
    "\n",
    "```python\n",
    "T.text(node, fmt=fmt)\n",
    "```\n",
    "\n",
    "where `node` is a single node.\n",
    "In this case, the default format is `ntype-orig-full` where `ntype` is the type of `node`.\n",
    "\n",
    "If the format is defined in the corpus, it will be used. Otherwise, the word nodes contained in `node` will be looked up\n",
    "and represented with the default format `text-orig-full`.\n",
    "\n",
    "In this way we can sensibly represent a lot of different nodes, such as vaggas, stanzas, sentences, clauses and words.\n",
    "\n",
    "We compose a set of example nodes and run `T.text` on them:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 15251, 16164, 16639]"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "exampleNodes = [\n",
    "    1,\n",
    "    F.otype.s(\"sentence\")[0],\n",
    "    F.otype.s(\"stanza\")[0],\n",
    "    F.otype.s(\"vagga\")[0],\n",
    "]\n",
    "exampleNodes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This is word 1:\n",
      "Yamakavagga \n",
      "\n",
      "This is sentence 15251:\n",
      "Yamakavagga \n",
      "\n",
      "This is stanza 16164:\n",
      "Yamakavagga \n",
      "\n",
      "This is vagga 16639:\n",
      "Yamakavagga manopubbaṅgamā dhammā manoseṭṭhā manomayā, manasā ce paduṭṭhena bhāsatī vā karoti vā tato naṃ dukkham anveti cakkaṃ va vahato padaṃ. Naturae a mente principium ducunt, mens est potior pars earum, e mente constant; si (quis) mente inquinata aut loquitur aut agit, tum eum sequitur dolor, ut rota (bovis) vehentis pedem. manopubbaṅgamā dhammā manoseṭṭhā manomayā, manasā ce pasannena bhāsatī vā karoti vā tato naṃ sukham anveti chāyā va anapāyinī. Naturae a mente etc.; si (quis) mente serena aut loquitur aut agit, tum eum sequitur gaudium ut umbra non decedens. \"akkocchi maṃ avadhi maṃ ajini maṃ ahāsi me\", ye taṃ upanayihanti veraṃ tesaṃ na sammati. \"Conviciis me obruit, verberavit me, vicit me, spoliavit me\"; qui isto (animo) sese induunt, iracundia eorum non sedatur. \"akkocchi maṃ avadhi maṃ ajini maṃ ahāsi me\", ye taṃ na upanayhanti veraṃ tes' ūpasammati. \"Conviciis etc.\"; qui isto (animo) sese non induunt, iracundia in iis sedatur. na hi verena verāni sammant' idha kudācanaṃ averena ca sammanti, esa dhammo sanantano. Non enim iracundia iracundiae sedantur hic unquam, placabilitate vero sedantur; haec lex aeterna (est). pare ca na vijānanti: \"mayam ettha yamāmase\", ye ca tattha vijānanti tato sammanti medhagā. Alieni non intelligunt: nos hic moriemur; qui vero hoc comprehendunt, tum (eorum) sedantur iurgia. subhānupassiṃ viharantaṃ indriyesu asaṃvutaṃ bhojanamhi câmattaññuṃ kusītaṃ hīnavīriyaṃ taṃ ve pasahatī Māro vāto rukkhaṃ va dubbalaṃ. Iucunda spectantem viventem, sensus non coercentem et in cibo modi nescium, socordem, viribus destitutum, eum certe superat Māras, ventus arborem sicut infirmam. asubhānupassiṃ viharantaṃ indriyesu susaṃvutaṃ bhojanamhi ca mattaññuṃ saddhaṃ āraddhavīriyaṃ taṃ [ve] na-ppasahatī Māro vāto selaṃ va pabbataṃ. Iucunda non spectantem viventem, sensus bene coercentem et in cibo modum noscentem, fidem habentem, intentis viribus praeditum, eum certe non superat Māras, ventus saxeum volut montem. anikkasāvo kāsāvaṃ yo vatthaṃ paridahessati apeto damasaccena na so kāsāvaṃ arhati. Affectibus non liber qui fulvam vestem induere vult, temperantia et veritate privatus, non ille fulva veste dignus est. yo ca vantakasāv' assa sīlesu susamāhito upeto damasaccena sa ve kāsāvam arhati. Qui vero affectus respuit, virtutibus bene instructus, temperantia et veritate praeditus, ille certe fulva veste dignus est. asāre sāramatino sāre câsāradassino te sāraṃ nâdhigacchanti micchāsaṃkappagocarā. In eo, quod non essentiale, essentiam opinantes atque in essentia nonessentiale videntes, hi essentiam non adeunt, falsi studii participes. sārañ ca sārato ñatvā asārañ ca asārato te sāraṃ adhigacchanti sammāsaṃkappagocarā. Essentiam vero essentiale habentes, et nonessentiale non-essentiale, hi essentiam adeunt, veri studii participes. yathā agāraṃ ducchannaṃ vuṭṭhi samativijjhati evaṃ abhāvitaṃ cittaṃ rāgo samativijjhati. Sicut domum male tectam pluvia perrumpit, ita meditatione destitutam cogitationionem cupido perrumpit. yathā agāraṃ succhannaṃ vuṭṭhi na samativijjhati evaṃ subhāvitaṃ cittaṃ rāgo na samativijjhati. Sicut domum bene tectam pluvia non perrumpit, ita meditabundam cogitationem cupido non perrumpit. idha socati pecca socati pāpakārī ubhayattha socati, so socati so vihaññati disvā kammakiliṭṭham attano. In hoc aevo moeret, morte obita moeret malum patrans, utrobique moeret; ille moeret, ille contristatur videns impuritatem facinoris sui. idha modati pecca modati katapuñño ubhayattha modati, so modati so pamodati disvā kammavisuddhim attano. In hoc aevo gaudet, morte obita gaudet qui bonum perfecit, utrobique gaudet; ille gaudet, ille valde gaudet videns munditiam facinoris sui. idha tappati pecca tappati pāpakārī ubhayattha tappati, \"pāpaṃ me katan\" ti tappati. bhiyyo tappati duggatiṃ gato. In hoc aevo cruciatur, morte obita cruciatur malum patrans, utrobique cruciatur; \"malum a me peractum\", ita (cogitans) cruciatur, magis cruciatur tartarum ingressus. idha nandati pecca nandati katapuñño, ubhayattha nandati, \"puññam me katan\" ti nandati. bhiyyo nandati suggatiṃ gato. In hoc aevo gaudet, morte obita gaudet qui bonum perfecit, utrobique gaudet; \"bonum a me peractum\", ita (cogitans) gaudet, magis gaudet coelum ingressus. bahum pi ce sahitam bhāsamāno na takkaro hoti naro pamatto gopo va gāvo gaṇayam paresaṃ na bhāgavā sāmaññassa hoti. Multa quoque si concinna loquens ea non facit vir socors, bubulcus velut vaccas aliorum numerans, congregationis Samanarum non fit particeps. appam pi ce sahitam bhāsamāno dhammassa hoti anudhammacārī rāgañ ca dosañ ca pahāya mohaṃ sammappajāno suvimuttacitto anupādiyāno idha vā huraṃ vā sa bhāgavā sāmaññassa hoti. Pauca quoque si (quis) concinna loquens secundum legem vitam degit, et cupidinem et odium (et) perturbationem animi relinquens, plane sapiens, cogitatione bene liberata praeditus, nihil appetens vel hic vel illic, is congregationis Samanarum fit particeps. Yamakavaggo paṭhamo \n",
      "\n"
     ]
    }
   ],
   "source": [
    "for n in exampleNodes:\n",
    "    print(f\"This is {F.otype.v(n)} {n}:\")\n",
    "    print(T.text(n))\n",
    "    print(\"\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Using the formats\n",
    "Now let's use those formats to print out the second stanza of the Dhammapada."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:19:10.077589Z",
     "start_time": "2018-05-18T09:19:10.070503Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "text-latin-full:\n",
      "Naturae a mente principium ducunt, mens est potior pars earum, e mente constant; si (quis) mente inquinata aut loquitur aut agit, tum eum sequitur dolor, ut rota (bovis) vehentis pedem. \n",
      "\n",
      "\n",
      "text-orig-full:\n",
      "manopubbaṅgamā dhammā manoseṭṭhā manomayā, manasā ce paduṭṭhena bhāsatī vā karoti vā tato naṃ dukkham anveti cakkaṃ va vahato padaṃ. Naturae a mente principium ducunt, mens est potior pars earum, e mente constant; si (quis) mente inquinata aut loquitur aut agit, tum eum sequitur dolor, ut rota (bovis) vehentis pedem. \n",
      "\n",
      "\n",
      "text-pali-full:\n",
      "manopubbaṅgamā dhammā manoseṭṭhā manomayā, manasā ce paduṭṭhena bhāsatī vā karoti vā tato naṃ dukkham anveti cakkaṃ va vahato padaṃ. \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "secondStanza = F.otype.s(\"stanza\")[1]\n",
    "\n",
    "for fmt in sorted(T.formats):\n",
    "    if fmt.startswith(\"layout\"):\n",
    "        continue\n",
    "    print(\"{}:\\n{}\\n\\n\".format(fmt, T.text(secondStanza, fmt=fmt)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If we do not specify a format, the **default** format is used (`text-orig-full`)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:19:13.490426Z",
     "start_time": "2018-05-18T09:19:13.486053Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Yamakavagga manopubbaṅgamā dhammā manoseṭṭhā manomayā, manasā ce paduṭṭhena bhāsatī vā karoti '"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "T.text(range(1, 12))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The important things to remember are:\n",
    "\n",
    "* you can supply a list of word nodes and get them represented in all formats\n",
    "* you can get non-word nodes `n` in default format by `T.text(n)`\n",
    "* you can get non-word nodes `n` in other formats by `T.text(n, fmt=fmt, descend=True)`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Whole text in all formats\n",
    "Part of the pleasure of working with computers is that they can crunch massive amounts of data.\n",
    "The text of the Dhammapada is a piece of cake.\n",
    "\n",
    "It takes less than a tenth of a second to have that cake and eat it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-18T09:19:27.839331Z",
     "start_time": "2018-05-18T09:19:18.526400Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  0.00s writing plain text of whole Dhammapada in all formats ...\n",
      "  0.06s done 3 formats\n"
     ]
    }
   ],
   "source": [
    "A.indent(reset=True)\n",
    "A.info(\"writing plain text of whole Dhammapada in all formats ...\")\n",
    "text = collections.defaultdict(list)\n",
    "for v in F.otype.s(\"stanza\"):\n",
    "    for fmt in sorted(T.formats):\n",
    "        if fmt.startswith(\"layout\"):\n",
    "            continue\n",
    "        text[fmt].append(T.text(v, fmt=fmt, descend=True))\n",
    "A.info(\"done {} formats\".format(len(text)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "text-latin-full\n",
      "\n",
      "Naturae a mente principium ducunt, mens est potior pars earum, e mente constant; si (quis) mente inquinata aut loquitur aut agit, tum eum sequitur dolor, ut rota (bovis) vehentis pedem. \n",
      "Naturae a mente etc.; si (quis) mente serena aut loquitur aut agit, tum eum sequitur gaudium ut umbra non decedens. \n",
      "\"Conviciis me obruit, verberavit me, vicit me, spoliavit me\"; qui isto (animo) sese induunt, iracundia eorum non sedatur. \n",
      "\"Conviciis etc.\"; qui isto (animo) sese non induunt, iracundia in iis sedatur. \n",
      "\n",
      "text-orig-full\n",
      "Yamakavagga \n",
      "manopubbaṅgamā dhammā manoseṭṭhā manomayā, manasā ce paduṭṭhena bhāsatī vā karoti vā tato naṃ dukkham anveti cakkaṃ va vahato padaṃ. Naturae a mente principium ducunt, mens est potior pars earum, e mente constant; si (quis) mente inquinata aut loquitur aut agit, tum eum sequitur dolor, ut rota (bovis) vehentis pedem. \n",
      "manopubbaṅgamā dhammā manoseṭṭhā manomayā, manasā ce pasannena bhāsatī vā karoti vā tato naṃ sukham anveti chāyā va anapāyinī. Naturae a mente etc.; si (quis) mente serena aut loquitur aut agit, tum eum sequitur gaudium ut umbra non decedens. \n",
      "\"akkocchi maṃ avadhi maṃ ajini maṃ ahāsi me\", ye taṃ upanayihanti veraṃ tesaṃ na sammati. \"Conviciis me obruit, verberavit me, vicit me, spoliavit me\"; qui isto (animo) sese induunt, iracundia eorum non sedatur. \n",
      "\"akkocchi maṃ avadhi maṃ ajini maṃ ahāsi me\", ye taṃ na upanayhanti veraṃ tes' ūpasammati. \"Conviciis etc.\"; qui isto (animo) sese non induunt, iracundia in iis sedatur. \n",
      "\n",
      "text-pali-full\n",
      "Yamakavagga \n",
      "manopubbaṅgamā dhammā manoseṭṭhā manomayā, manasā ce paduṭṭhena bhāsatī vā karoti vā tato naṃ dukkham anveti cakkaṃ va vahato padaṃ. \n",
      "manopubbaṅgamā dhammā manoseṭṭhā manomayā, manasā ce pasannena bhāsatī vā karoti vā tato naṃ sukham anveti chāyā va anapāyinī. \n",
      "\"akkocchi maṃ avadhi maṃ ajini maṃ ahāsi me\", ye taṃ upanayihanti veraṃ tesaṃ na sammati. \n",
      "\"akkocchi maṃ avadhi maṃ ajini maṃ ahāsi me\", ye taṃ na upanayhanti veraṃ tes' ūpasammati. \n",
      "\n"
     ]
    }
   ],
   "source": [
    "for fmt in sorted(text):\n",
    "    print(\"{}\\n{}\\n\".format(fmt, \"\\n\".join(text[fmt][0:5])))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### The full plain text\n",
    "We write those formats to file, in your Downloads folder."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "for fmt in sorted(T.formats):\n",
    "    if fmt.startswith(\"layout\"):\n",
    "        continue\n",
    "    with open(os.path.expanduser(f\"~/Downloads/{fmt}.txt\"), \"w\") as f:\n",
    "        f.write(\"\\n\".join(text[fmt]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Clean caches\n",
    "\n",
    "Text-Fabric pre-computes data for you, so that it can be loaded faster.\n",
    "If the original data is updated, Text-Fabric detects it, and will recompute that data.\n",
    "\n",
    "But there are cases, when the algorithms of Text-Fabric have changed, without any changes in the data, that you might\n",
    "want to clear the cache of precomputed results.\n",
    "\n",
    "There are two ways to do that:\n",
    "\n",
    "* Locate the `.tf` directory of your dataset, and remove all `.tfx` files in it.\n",
    "  This might be a bit awkward to do, because the `.tf` directory is hidden on Unix-like systems.\n",
    "* Call `TF.clearCache()`, which does exactly the same.\n",
    "\n",
    "It is not handy to execute the following cell all the time, that's why I have commented it out.\n",
    "So if you really want to clear the cache, remove the comment sign below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [],
   "source": [
    "# TF.clearCache()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# All steps\n",
    "\n",
    "By now you have an impression how to compute around in the Hebrew Bible.\n",
    "While this is still the beginning, I hope you already sense the power of unlimited programmatic access\n",
    "to all the bits and bytes in the data set.\n",
    "\n",
    "Here are a few directions for unleashing that power.\n",
    "\n",
    "* **start** your first step in mastering the bible computationally\n",
    "* **[search](search.ipynb)** turbo charge your hand-coding with search templates\n",
    "\n",
    "CC-BY Dirk Roorda"
   ]
  }
 ],
 "metadata": {
  "jupytext": {
   "encoding": "# -*- coding: utf-8 -*-"
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.0"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": "block",
   "toc_window_display": false
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {},
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}