Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • b5a84cb
  • /
  • programs
  • /
  • parallels.ipynb
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:8862d2d8db0d3ccfe0fffefa4c713d17b53c7d02
directory badge
swh:1:dir:a73693b459a78827d0a6a5b646e03489e5ed3023

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
parallels.ipynb
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import collections\n",
    "import pickle\n",
    "import gzip\n",
    "\n",
    "from tf.app import use"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TF app is up-to-date.\n",
      "Using annotation/app-oldbabylonian commit 82fffd1ec080e9aada4018099c1ad7686317fb2c (=latest)\n",
      "  in /Users/dirk/text-fabric-data/__apps__/oldbabylonian.\n",
      "No new data release available online.\n",
      "Using Nino-cunei/oldbabylonian/tf - 1.0.1 rv1.1 (=latest) in /Users/dirk/text-fabric-data.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<b>Documentation:</b> <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/\" title=\"provenance of Old Babylonian Letters 1900-1600: Cuneiform tablets \">OLDBABYLONIAN</a> <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/transcription.md\" title=\"How TF features represent ATF\">Character table</a> <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"OLDBABYLONIAN feature documentation\">Feature docs</a> <a target=\"_blank\" href=\"https://github.com/annotation/app-oldbabylonian\" title=\"oldbabylonian API documentation\">oldbabylonian API</a> <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Fabric/\" title=\"text-fabric-api\">Text-Fabric API 7.5.0</a> <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Use/Search/\" title=\"Search Templates Introduction and Reference\">Search Reference</a><details open><summary><b>Loaded features</b>:</summary>\n",
       "<p><b>Old Babylonian Letters 1900-1600: Cuneiform tablets </b>: <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/after.tf\">after</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/afterr.tf\">afterr</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/afteru.tf\">afteru</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/atf.tf\">atf</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/atfpost.tf\">atfpost</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/atfpre.tf\">atfpre</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/col.tf\">col</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/collated.tf\">collated</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/collection.tf\">collection</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/comment.tf\">comment</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/damage.tf\">damage</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/det.tf\">det</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/docnote.tf\">docnote</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/docnumber.tf\">docnumber</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/excised.tf\">excised</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/face.tf\">face</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/flags.tf\">flags</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/fraction.tf\">fraction</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/grapheme.tf\">grapheme</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/graphemer.tf\">graphemer</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/graphemeu.tf\">graphemeu</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/lang.tf\">lang</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/langalt.tf\">langalt</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/ln.tf\">ln</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/lnc.tf\">lnc</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/lnno.tf\">lnno</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/missing.tf\">missing</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/object.tf\">object</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/operator.tf\">operator</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/operatorr.tf\">operatorr</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/operatoru.tf\">operatoru</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/otype.tf\">otype</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/pnumber.tf\">pnumber</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/primecol.tf\">primecol</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/primeln.tf\">primeln</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/question.tf\">question</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/reading.tf\">reading</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/readingr.tf\">readingr</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/readingu.tf\">readingu</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/remarkable.tf\">remarkable</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/remarks.tf\">remarks</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/repeat.tf\">repeat</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/srcLn.tf\">srcLn</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/srcLnNum.tf\">srcLnNum</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/srcfile.tf\">srcfile</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/supplied.tf\">supplied</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/sym.tf\">sym</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/symr.tf\">symr</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/symu.tf\">symu</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/trans.tf\">trans</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/translation@en.tf\">translation@ll</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/type.tf\">type</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/uncertain.tf\">uncertain</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/volume.tf\">volume</a>  <b><i><a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/oslots.tf\">oslots</a></i></b> </p></details>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<style>\n",
       "@font-face {\n",
       "  font-family: \"Santakku\";\n",
       "  src:\n",
       "    local(\"Santakku.ttf\"),\n",
       "    url(\"https://github.com/annotation/text-fabric/blob/master/tf/server/static/fonts/Santakku.woff?raw=true\");\n",
       "}\n",
       ".txtn,.txtn a:visited,.txtn a:link {\n",
       "    font-family: sans-serif;\n",
       "    font-size: normal;\n",
       "    text-decoration: none;\n",
       "}\n",
       ".txtp,.txtp a:visited,.txtp a:link {\n",
       "    font-family: monospace;\n",
       "    font-size: normal;\n",
       "    text-decoration: none;\n",
       "}\n",
       ".txtr,.txtr a:visited,.txtr a:link {\n",
       "    font-family: serif;\n",
       "    font-size: large;\n",
       "    text-decoration: none;\n",
       "}\n",
       ".txtu,.txtu a:visited,.txtu a:link {\n",
       "    font-family: Santakku;\n",
       "    font-size: x-large;\n",
       "    text-decoration: none;\n",
       "}\n",
       ".features {\n",
       "    font-family: monospace;\n",
       "    font-size: medium;\n",
       "    font-weight: bold;\n",
       "    color: #0a6611;\n",
       "    display: flex;\n",
       "    flex-flow: column nowrap;\n",
       "    padding: 0.1em;\n",
       "    margin: 0.1em;\n",
       "    direction: ltr;\n",
       "}\n",
       ".features div,.features span {\n",
       "    padding: 0;\n",
       "    margin: -0.1rem 0;\n",
       "}\n",
       ".features .f {\n",
       "    font-family: sans-serif;\n",
       "    font-size: x-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: 0.1em 0em;\n",
       "}\n",
       ".features .xft .f {\n",
       "  color: #000000;\n",
       "  background-color: #eeeeee;\n",
       "  font-style: italic;\n",
       "  font-size: small;\n",
       "  font-weight: normal;\n",
       "}\n",
       ".pnum {\n",
       "    font-family: sans-serif;\n",
       "    font-size: small;\n",
       "    font-weight: bold;\n",
       "    color: #444444;\n",
       "}\n",
       ".nd {\n",
       "    font-family: monospace;\n",
       "    font-size: x-small;\n",
       "    color: #999999;\n",
       "}\n",
       ".meta {\n",
       "    display: flex;\n",
       "    justify-content: flex-start;\n",
       "    align-items: flex-start;\n",
       "    align-content: flex-start;\n",
       "    flex-flow: row nowrap;\n",
       "}\n",
       ".features,.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",
       ".children {\n",
       "    display: flex;\n",
       "    justify-content: flex-start;\n",
       "    align-items: flex-start;\n",
       "    align-content: flex-start;\n",
       "    border: 0;\n",
       "    background-color: #ffffff;\n",
       "}\n",
       ".children.document {\n",
       "    flex-flow: column nowrap;\n",
       "}\n",
       ".children.face {\n",
       "    flex-flow: column nowrap;\n",
       "}\n",
       ".children.line {\n",
       "    align-items: stretch;\n",
       "    flex-flow: row nowrap;\n",
       "}\n",
       ".children.cluster {\n",
       "    flex-flow: row wrap;\n",
       "}\n",
       ".children.line {\n",
       "    align-items: stretch;\n",
       "    flex-flow: row nowrap;\n",
       "}\n",
       ".children.sign {\n",
       "    flex-flow: column nowrap;\n",
       "}\n",
       ".contnr {\n",
       "    width: fit-content;\n",
       "}\n",
       ".contnr.document,.contnr.face,\n",
       ".contnr.line,\n",
       ".contnr.cluster,\n",
       ".contnr.word,\n",
       ".contnr.sign {\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:  0.5em 0.1em 0.1em 0.1em;\n",
       "    margin: 0.8em 0.1em 0.1em 0.1em;\n",
       "    border-radius: 0.2em;\n",
       "    border-style: solid;\n",
       "    border-width: 0.2em;\n",
       "    font-size: small;\n",
       "}\n",
       ".contnr.document,.contnr.face {\n",
       "    border-color: #bb8800;\n",
       "}\n",
       ".contnr.line {\n",
       "    border-color: #0088bb;\n",
       "}\n",
       ".contnr.cluster {\n",
       "    flex-flow: row wrap;\n",
       "    border: 0;\n",
       "}\n",
       ".contnr.word {\n",
       "    border-color: #44bbff;\n",
       "}\n",
       ".contnr.sign {\n",
       "    border-color: #bbbbbb;\n",
       "}\n",
       ".contnr.hl {\n",
       "    background-color: #ffee66;\n",
       "}\n",
       ".lbl.document,.lbl.face,\n",
       ".lbl.line,\n",
       ".lbl.cluster,\n",
       ".lbl.sign,.lbl.word {\n",
       "    margin-top: -1.2em;\n",
       "    margin-left: 1em;\n",
       "    background: #ffffff none repeat scroll 0 0;\n",
       "    padding: 0 0.3em;\n",
       "    border-style: solid;\n",
       "    font-size: small;\n",
       "    display: block;\n",
       "}\n",
       ".lbl.document,.lbl.face {\n",
       "    border-color: #bb8800;\n",
       "    border-width: 0.3em;\n",
       "    border-radius: 0.3em;\n",
       "    color: #bb8800;\n",
       "}\n",
       ".lbl.line {\n",
       "    border-color: #0088bb;\n",
       "    border-width: 0.3em;\n",
       "    border-radius: 0.3em;\n",
       "    color: #0088bb;\n",
       "}\n",
       ".lbl.cluster {\n",
       "    border-color: #dddddd;\n",
       "    border-width: 0.2em;\n",
       "    border-radius: 0.2em;\n",
       "    color: #0000cc;\n",
       "}\n",
       ".lbl.word {\n",
       "    border-color: #44bbff;\n",
       "    border-width: 0.2em;\n",
       "    border-radius: 0.2em;\n",
       "    font-size: medium;\n",
       "    color: #000000;\n",
       "}\n",
       ".lbl.sign {\n",
       "    border-color: #bbbbbb;\n",
       "    border-width: 0.1em;\n",
       "    border-radius: 0.1em;\n",
       "    font-size: small;\n",
       "    color: #000000;\n",
       "}\n",
       ".op {\n",
       "    padding:  0.5em 0.1em 0.1em 0.1em;\n",
       "    margin: 0.8em 0.1em 0.1em 0.1em;\n",
       "    font-family: monospace;\n",
       "    font-size: x-large;\n",
       "    font-weight: bold;\n",
       "}\n",
       ".name {\n",
       "    font-family: monospace;\n",
       "    font-size: medium;\n",
       "    color: #0000bb;\n",
       "}\n",
       ".period {\n",
       "    font-family: monospace;\n",
       "    font-size: medium;\n",
       "    font-weight: bold;\n",
       "    color: #0000bb;\n",
       "}\n",
       ".text {\n",
       "    font-family: sans-serif;\n",
       "    font-size: x-small;\n",
       "    color: #000000;\n",
       "}\n",
       ".srcln {\n",
       "    font-family: monospace;\n",
       "    font-size: medium;\n",
       "    color: #000000;\n",
       "}\n",
       ".srclnnum {\n",
       "    font-family: monospace;\n",
       "    font-size: x-small;\n",
       "    color: #0000bb;\n",
       "}\n",
       ".comment {\n",
       "    color: #7777dd;\n",
       "    font-family: monospace;\n",
       "    font-size: small;\n",
       "}\n",
       ".operator {\n",
       "    color: #ff77ff;\n",
       "    font-size: large;\n",
       "}\n",
       "/* LANGUAGE: superscript and subscript */\n",
       "\n",
       "/* cluster */\n",
       ".det {\n",
       "    vertical-align: super;\n",
       "}\n",
       "/* cluster */\n",
       ".langalt {\n",
       "    vertical-align: sub;\n",
       "}\n",
       "/* REDACTIONAL: line over or under  */\n",
       "\n",
       "/* flag */\n",
       ".collated {\n",
       "    font-weight: bold;\n",
       "    text-decoration: underline;\n",
       "}\n",
       "/* cluster */\n",
       ".excised {\n",
       "    color: #dd0000;\n",
       "    text-decoration: line-through;\n",
       "}\n",
       "/* cluster */\n",
       ".supplied {\n",
       "    color: #0000ff;\n",
       "    text-decoration: overline;\n",
       "}\n",
       "/* flag */\n",
       ".remarkable {\n",
       "    font-weight: bold;\n",
       "    text-decoration: overline;\n",
       "}\n",
       "\n",
       "/* UNSURE: italic*/\n",
       "\n",
       "/* cluster */\n",
       ".uncertain {\n",
       "    font-style: italic\n",
       "}\n",
       "/* flag */\n",
       ".question {\n",
       "    font-weight: bold;\n",
       "    font-style: italic\n",
       "}\n",
       "\n",
       "/* BROKEN: text-shadow */\n",
       "\n",
       "/* cluster */\n",
       ".missing {\n",
       "    color: #999999;\n",
       "    text-shadow: #bbbbbb 1px 1px;\n",
       "}\n",
       "/* flag */\n",
       ".damage {\n",
       "    font-weight: bold;\n",
       "    color: #999999;\n",
       "    text-shadow: #bbbbbb 1px 1px;\n",
       "}\n",
       ".empty {\n",
       "  color: #ff0000;\n",
       "}\n",
       "\n",
       "span.hldot {\n",
       "\tbackground-color: var(--hl-strong);\n",
       "\tborder: 0.2rem solid var(--hl-rim);\n",
       "\tborder-radius: 0.4rem;\n",
       "\t/*\n",
       "\tdisplay: inline-block;\n",
       "\twidth: 0.8rem;\n",
       "\theight: 0.8rem;\n",
       "\t*/\n",
       "}\n",
       "span.hl {\n",
       "\tbackground-color: var(--hl-strong);\n",
       "\tborder-width: 0;\n",
       "\tborder-radius: 0.1rem;\n",
       "\tborder-style: solid;\n",
       "}\n",
       "\n",
       "span.hlup {\n",
       "\tborder-color: var(--hl-dark);\n",
       "\tborder-width: 0.1rem;\n",
       "\tborder-style: solid;\n",
       "\tborder-radius: 0.2rem;\n",
       "  padding: 0.2rem;\n",
       "}\n",
       "\n",
       ":root {\n",
       "\t--hl-strong:        hsla( 60, 100%,  70%, 0.9  );\n",
       "\t--hl-rim:           hsla( 55, 100%,  60%, 0.9  );\n",
       "\t--hl-dark:          hsla( 55, 100%,  40%, 0.9  );\n",
       "}\n",
       "</style>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<details open><summary><b>API members</b>:</summary>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Computed/#computed-data\" title=\"doc\">C Computed</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Computed/#computed-data\" title=\"doc\">Call AllComputeds</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Computed/#computed-data\" title=\"doc\">Cs ComputedString</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#edge-features\" title=\"doc\">E Edge</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#edge-features\" title=\"doc\">Eall AllEdges</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#edge-features\" title=\"doc\">Es EdgeString</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Fabric/#loading\" title=\"doc\">ensureLoaded</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Fabric/#loading\" title=\"doc\">TF</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Fabric/#loading\" title=\"doc\">ignored</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Fabric/#loading\" title=\"doc\">loadLog</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Locality/#locality\" title=\"doc\">L Locality</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Misc/#messaging\" title=\"doc\">cache</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Misc/#messaging\" title=\"doc\">error</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Misc/#messaging\" title=\"doc\">indent</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Misc/#messaging\" title=\"doc\">info</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Misc/#messaging\" title=\"doc\">reset</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Nodes/#navigating-nodes\" title=\"doc\">N Nodes</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Nodes/#navigating-nodes\" title=\"doc\">sortKey</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Nodes/#navigating-nodes\" title=\"doc\">sortKeyTuple</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Nodes/#navigating-nodes\" title=\"doc\">otypeRank</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Nodes/#navigating-nodes\" title=\"doc\">sortNodes</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#node-features\" title=\"doc\">F Feature</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#node-features\" title=\"doc\">Fall AllFeatures</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#node-features\" title=\"doc\">Fs FeatureString</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Search/#search\" title=\"doc\">S Search</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Text/#text\" title=\"doc\">T Text</a></details>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "A = use('oldbabylonian', hoist=globals(), check=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Parallels\n",
    "\n",
    "We make edges between similar lines.\n",
    "\n",
    "When are lines similar?\n",
    "\n",
    "If a certain distance metric is above a certain threshold.\n",
    "\n",
    "We choose this metric:\n",
    "\n",
    "* we reduce a line to the set of readings and graphemes in it, excluding unknown signs and ellipses.\n",
    "* the similarite between two lines is the length of the intersection divided by the length of the union of their sets times 100."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Preparation\n",
    "\n",
    "We pre-compute all sets for all lines."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "READABLE_TYPES = {'reading', 'grapheme', 'numeral', 'complex'}\n",
    "\n",
    "def makeSet(l):\n",
    "  if F.lnc.v(l): # comment line\n",
    "    return None\n",
    "  lineSet = set()\n",
    "  for s in L.d(l, otype='sign'):\n",
    "    if F.type.v(s) in READABLE_TYPES:\n",
    "      r = F.readingr.v(s)\n",
    "      if r:\n",
    "        lineSet.add(r)\n",
    "      g = F.graphemer.v(s)\n",
    "      if g:\n",
    "        lineSet.add(g)\n",
    "  return lineSet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "25923 lines\n"
     ]
    }
   ],
   "source": [
    "lines = {}\n",
    "\n",
    "for l in F.otype.s('line'):\n",
    "  lineSet = makeSet(l)\n",
    "  if lineSet:\n",
    "    lines[l] = lineSet\n",
    "    \n",
    "nLines = len(lines)\n",
    "print(f'{nLines} lines')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Measure"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def sim(lSet, mSet):\n",
    "  return int(round(100 * len(lSet & mSet) / len(lSet | mSet)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Compute all similarities\n",
    "\n",
    "We are going to perform several hundreds of millions of comparisons, each of which is more than an elemetary operation.\n",
    "\n",
    "Let's measure time."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "THRESHOLD = 90\n",
    "\n",
    "def computeSim(limit=None):\n",
    "  similarity = {}\n",
    "\n",
    "  lineNodes = sorted(lines.keys())\n",
    "  nLines = len(lineNodes)\n",
    "\n",
    "  nComparisons = nLines * (nLines - 1) // 2\n",
    "\n",
    "  print(f'{nComparisons} comparisons to make')\n",
    "  chunkSize = nComparisons // 100\n",
    "\n",
    "  co = 0\n",
    "  b = 0\n",
    "  si = 0\n",
    "  p = 0\n",
    "\n",
    "  indent(reset=True)\n",
    "\n",
    "  stop = False\n",
    "  for i in range(nLines):\n",
    "    nodeI = lineNodes[i]\n",
    "    lineI = lines[nodeI]\n",
    "    for j in range(i + 1, nLines):\n",
    "      nodeJ = lineNodes[j]\n",
    "      lineJ = lines[nodeJ]\n",
    "      s = sim(lineI, lineJ)\n",
    "      co += 1\n",
    "      b += 1\n",
    "      if b == chunkSize:\n",
    "        p += 1\n",
    "        info(f'{p:>3}% - {co:>12} comparisons and {si:>10} similarities')\n",
    "        b = 0\n",
    "        if limit is not None and p >= limit:\n",
    "          stop = True\n",
    "          break\n",
    "\n",
    "      if s < THRESHOLD:\n",
    "        continue\n",
    "      similarity[(nodeI, nodeJ)] = sim(lineI, lineJ)\n",
    "      si += 1\n",
    "    if stop:\n",
    "      break\n",
    "\n",
    "  info(f'{p:>3}% - {co:>12} comparisons and {si:>10} similarities')\n",
    "  return similarity"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We are going to run it to 1% first and do some checks then."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "335988003 comparisons to make\n",
      "  4.26s   1% -      3359880 comparisons and       5695 similarities\n",
      "  4.26s   1% -      3359880 comparisons and       5695 similarities\n"
     ]
    }
   ],
   "source": [
    "similarity = computeSim(limit=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We check the sanity of the results."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "90\n",
      "100\n"
     ]
    }
   ],
   "source": [
    "print(min(similarity.values()))\n",
    "print(max(similarity.values()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "eq = [x for x in similarity.items() if x[1] >= 100]\n",
    "neq = [x for x in similarity.items() if x[1] <= 90]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5689\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "print(len(eq))\n",
    "print(len(neq))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "((230787, 235393), 100)\n",
      "((230796, 230810), 90)\n"
     ]
    }
   ],
   "source": [
    "print(eq[0])\n",
    "print(neq[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P509373\" title=\"P509373 obverse:1\" sec=\"P509373 obverse:1\">P509373 obverse:1&nbsp;</a><span class=\"txtp\">[a-na] _{d}suen_-i-[din-nam]</span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P510729\" title=\"P510729 obverse:1\" sec=\"P510729 obverse:1\">P510729 obverse:1&nbsp;</a><span class=\"txtp\">a-na {d}suen-i-din-[nam]</span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "A.plain(eq[0][0][0])\n",
    "A.plain(eq[0][0][1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P509373\" title=\"P509373 obverse:10\" sec=\"P509373 obverse:10\">P509373 obverse:10&nbsp;</a><span class=\"txtp\">_a-sza3 a-gar3_ na-ag-[ma-lum] _uru_ x x x{ki}</span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P509373\" title=\"P509373 reverse:7'\" sec=\"P509373 reverse:7'\">P509373 reverse:7'&nbsp;</a><span class=\"txtp\">_a-[sza3 a-gar3_ na-ag]-ma-lum _uru gan2_ x x{ki}</span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "A.plain(neq[0][0][0])\n",
    "A.plain(neq[0][0][1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Looks good.\n",
    "\n",
    "Now the whole computation.\n",
    "\n",
    "But if we have done this before, and nothing has changed, we load previous results from disk.\n",
    "\n",
    "If we do not find previous results, we compute them and save the results to disk."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "PARA_DIR = f'{A.tempDir}/parallels'\n",
    "\n",
    "def writeResults(data, location, name):\n",
    "  if not os.path.exists(location):\n",
    "    os.makedirs(location, exist_ok=True)\n",
    "  path = f'{location}/{name}'\n",
    "  with gzip.open(path, 'wb') as f:\n",
    "    pickle.dump(data, f)\n",
    "  print(f'Data written to {path}')\n",
    "  \n",
    "def readResults(location, name):\n",
    "  path = f'{location}/{name}'\n",
    "  if not os.path.exists(path):\n",
    "    print(f'File not found: {path}')\n",
    "    return None\n",
    "  with gzip.open(path, 'rb') as f:\n",
    "    data = pickle.load(f)\n",
    "  print(f'Data read from {path}')\n",
    "  return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Data read from /Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/_temp/parallels/sim.zip\n"
     ]
    }
   ],
   "source": [
    "similarity = readResults(PARA_DIR, 'sim.zip')\n",
    "if not similarity:\n",
    "  similarity = computeSim()\n",
    "  writeResults(similarity, PARA_DIR, 'sim.zip')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "574579"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(similarity)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So, over half a million pairs of similar lines.\n",
    "\n",
    "Let's find out which lines have the most correspondences."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8344 out of 25923 lines have at least one similar line\n"
     ]
    }
   ],
   "source": [
    "parallels = {}\n",
    "\n",
    "for (l, m) in similarity:\n",
    "  parallels.setdefault(l, set()).add(m)\n",
    "  parallels.setdefault(m, set()).add(l)\n",
    "  \n",
    "print(f'{len(parallels)} out of {nLines} lines have at least one similar line')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "rankedParallels = sorted(\n",
    "  parallels.items(),\n",
    "  key=lambda x: (-len(x[1]), x[0]),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1005 siblings of 230788 = qi2-bi2-[ma]\n",
      "1005 siblings of 230824 = qi2-bi2-ma\n",
      "1005 siblings of 230842 = [qi2]-bi2#-ma\n",
      "1005 siblings of 230906 = qi2-bi2-ma\n",
      "1005 siblings of 230914 = qi2-bi2-ma\n",
      "1005 siblings of 231002 = qi2-bi2-ma\n",
      "1005 siblings of 231020 = qi2-bi2-ma\n",
      "1005 siblings of 231053 = [qi2]-bi2-ma\n",
      "1005 siblings of 231066 = qi2-bi2-ma\n",
      "1005 siblings of 231086 = [qi2]-bi2#-ma\n"
     ]
    }
   ],
   "source": [
    "for (l, paras) in rankedParallels[0:10]:\n",
    "  print(f'{len(paras):>4} siblings of {l} = {T.text(l)}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1005 siblings of qi2-bi2-ma\n",
      "1005 siblings of qi2-bi2-ma\n",
      "1005 siblings of qi2-bi2-ma\n",
      "1005 siblings of qi2-bi2-ma\n",
      "1005 siblings of qi2-bi2-ma\n",
      "1005 siblings of qi2-[bi2]-ma\n",
      " 128 siblings of {d}utu u3 {d}marduk li-ba-al-li-t,u2-ka\n",
      " 128 siblings of {d}utu u3 {d}marduk li-ba-al-li-t,u2-ka\n",
      " 128 siblings of {d}utu u3 {d}marduk li-ba-al#-li#-t,u2#-[ka]\n",
      " 128 siblings of [{d}utu u3 {d}]marduk# li#-[ba]-al#-[li]-t,u2#-ka#\n"
     ]
    }
   ],
   "source": [
    "for (l, paras) in rankedParallels[1000:1010]:\n",
    "  print(f'{len(paras):>4} siblings of {T.text(l)}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " 128 siblings of _{d}utu_ u3 _{d}marduk_ li-ba-al-li-t,u2-ka\n",
      " 128 siblings of _{d}utu_ u3 _{d}marduk_ li-ba-al#-li#-t,u2#-ka#\n",
      " 128 siblings of _{d}utu_ u3 _{d}marduk_ li-ba-al-li-t,u2-ka#\n",
      " 127 siblings of {d}utu u3 {d}marduk li-ba-al-li-t,u2-ka!(KI)\n",
      " 127 siblings of {d}utu u3 {d}marduk tu-ba-al-li-t,u2-ka\n",
      " 124 siblings of [li]-ba-[al]-li-[t,u2-ka]\n",
      " 124 siblings of li-ba-al-li-t,u2-ka\n",
      " 124 siblings of li-ba-al-li#-t,u2-ka\n",
      " 124 siblings of li-ba-al-li-t,u2-ka\n",
      " 124 siblings of li-ba-al-li-t,u2-ka\n"
     ]
    }
   ],
   "source": [
    "for (l, paras) in rankedParallels[1130:1140]:\n",
    "  print(f'{len(paras):>4} siblings of {T.text(l)}')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And how many lines have just one correspondence?\n",
    "\n",
    "We look at the tail of rankedParallels."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "There are 1994 exclusively parallel pairs of lines\n"
     ]
    }
   ],
   "source": [
    "pairs = [(x, list(paras)[0]) for (x, paras) in rankedParallels if len(paras) == 1]\n",
    "print(f'There are {len(pairs)} exclusively parallel pairs of lines')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Why not make an overview of exactly how wide-spread parallel lines are?\n",
    "\n",
    "We count how many lines have how many parallels."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1972 lines have n sisters where        n >  100\n",
      " 939 lines have n sisters where  20 <  n <=  50\n",
      " 793 lines have n sisters where  10 <  n <=  20\n",
      "2646 lines have n sisters where   2 <  n <=  10\n",
      "1994 lines have n sisters where        n <=   2\n"
     ]
    }
   ],
   "source": [
    "parallelCount = collections.Counter()\n",
    "\n",
    "buckets = (2, 10, 20, 50, 100)\n",
    "\n",
    "bucketRep = {}\n",
    "prevBucket = None\n",
    "for bucket in buckets:\n",
    "  if prevBucket is None:\n",
    "    bucketRep[bucket] = f'       n <= {bucket:>3}'\n",
    "  elif bucket == buckets[-1]:\n",
    "    bucketRep[bucket] = f'       n >  {bucket:>3}'\n",
    "  else:\n",
    "    bucketRep[bucket] = f'{prevBucket:>3} <  n <= {bucket:>3}'\n",
    "  prevBucket = bucket\n",
    "\n",
    "for (l, paras) in rankedParallels:\n",
    "  clusterSize = len(paras) + 1\n",
    "  if clusterSize > buckets[-1]:\n",
    "    theBucket = buckets[-1]\n",
    "  else:\n",
    "    for bucket in buckets:\n",
    "      if clusterSize <= bucket:\n",
    "        theBucket = bucket\n",
    "        break\n",
    "  parallelCount[theBucket] += 1\n",
    "  \n",
    "for (bucket, amount) in sorted(\n",
    "  parallelCount.items(),\n",
    "  key=lambda x: (-x[0], x[1]),\n",
    "):\n",
    "  print(f'{amount:>4} lines have n sisters where {bucketRep[bucket]}')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Add parallels to the TF dataset\n",
    "\n",
    "We can add this information to the Oldbabylonian dataset as an *edge feature*.\n",
    "\n",
    "An edge feature links two nodes and may annotate that link with a value.\n",
    "\n",
    "For parallels, we link each line to each of its parallel lines and we annotate that link with the similarity between\n",
    "the two lines. The similarity is a percentage, and we round it to integer values.\n",
    "\n",
    "If *n1* is similar to *n2*, then *n2* is similar to *n1*.\n",
    "In order to save space, we only add such links once.\n",
    "\n",
    "We can then use\n",
    "[`E.sim.b(node)`](https://annotation.github.io/text-fabric/Api/Features/#edge-features)\n",
    "to find all nodes that are parallel to node.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "metaData = {\n",
    "  '': {\n",
    "    'name': 'AbB Old Babylonian Cuneiform',\n",
    "    'editor': 'Cale Johnson et. al.',\n",
    "    'institute': 'CDL',\n",
    "    'converters': 'Cale Johnson, Dirk Roorda',    \n",
    "  },\n",
    "  'sim': {\n",
    "    'valueType': 'int',\n",
    "    'edgeValues': True,\n",
    "    'description': 'similarity between lines, as a percentage of the common material wrt the combined material',\n",
    "  },\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "simData = {}\n",
    "for ((f, t), d) in similarity.items():\n",
    "  simData.setdefault(f, {})[t] = d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "ghBase = os.path.expanduser('~/github')\n",
    "subdir = 'parallels'\n",
    "path = f'{A.org}/{A.repo}/{subdir}/tf'\n",
    "location = f'{ghBase}/{path}'\n",
    "module = A.version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   |     0.51s T sim                  to /Users/dirk/github/Nino-cunei/oldbabylonian/parallels/tf/1.0.1\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "TF.save(edgeFeatures=dict(sim=simData), metaData=metaData, location=location, module=module)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Turn the parallels feature into a module\n",
    "\n",
    "The new `sim` feature is a big data feature. You do not want to load it all the time.\n",
    "\n",
    "Here we show how to turn it into a module, so that users can easily load it in a Jupyter notebook or in the TF browser."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "Create release data for Nino-cunei/oldbabylonian/parallels/tf\n",
      "zip files end up in /Users/dirk/Downloads/Nino-cunei-release/oldbabylonian\n",
      "zipping Nino-cunei/oldbabylonian  1.0.1 with   1 features ==> parallels-tf-1.0.1.zip\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "text-fabric-zip 'Nino-cunei/oldbabylonian/parallels/tf'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "I have added this file to a new release of the Oldbabylonian Github repo."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Use the parallels module\n",
    "\n",
    "We load the Oldbabylonian corpus again, but now with the parallels module."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TF app is up-to-date.\n",
      "Using annotation/app-oldbabylonian commit 82fffd1ec080e9aada4018099c1ad7686317fb2c (=latest)\n",
      "  in /Users/dirk/text-fabric-data/__apps__/oldbabylonian.\n",
      "No new data release available online.\n",
      "Using Nino-cunei/oldbabylonian/tf - 1.0.1 rv1.1 (=latest) in /Users/dirk/text-fabric-data.\n",
      "No new data release available online.\n",
      "Using Nino-cunei/oldbabylonian/parallels/tf - 1.0.1 rv1.1 (=latest) in /Users/dirk/text-fabric-data.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<b>Documentation:</b> <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/\" title=\"provenance of Old Babylonian Letters 1900-1600: Cuneiform tablets \">OLDBABYLONIAN</a> <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs/transcription.md\" title=\"How TF features represent ATF\">Character table</a> <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"OLDBABYLONIAN feature documentation\">Feature docs</a> <a target=\"_blank\" href=\"https://github.com/annotation/app-oldbabylonian\" title=\"oldbabylonian API documentation\">oldbabylonian API</a> <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Fabric/\" title=\"text-fabric-api\">Text-Fabric API 7.5.0</a> <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Use/Search/\" title=\"Search Templates Introduction and Reference\">Search Reference</a><details open><summary><b>Loaded features</b>:</summary>\n",
       "<p><b>Old Babylonian Letters 1900-1600: Cuneiform tablets </b>: <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/after.tf\">after</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/afterr.tf\">afterr</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/afteru.tf\">afteru</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/atf.tf\">atf</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/atfpost.tf\">atfpost</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/atfpre.tf\">atfpre</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/col.tf\">col</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/collated.tf\">collated</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/collection.tf\">collection</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/comment.tf\">comment</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/damage.tf\">damage</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/det.tf\">det</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/docnote.tf\">docnote</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/docnumber.tf\">docnumber</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/excised.tf\">excised</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/face.tf\">face</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/flags.tf\">flags</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/fraction.tf\">fraction</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/grapheme.tf\">grapheme</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/graphemer.tf\">graphemer</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/graphemeu.tf\">graphemeu</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/lang.tf\">lang</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/langalt.tf\">langalt</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/ln.tf\">ln</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/lnc.tf\">lnc</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/lnno.tf\">lnno</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/missing.tf\">missing</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/object.tf\">object</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/operator.tf\">operator</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/operatorr.tf\">operatorr</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/operatoru.tf\">operatoru</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/otype.tf\">otype</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/pnumber.tf\">pnumber</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/primecol.tf\">primecol</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/primeln.tf\">primeln</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/question.tf\">question</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/reading.tf\">reading</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/readingr.tf\">readingr</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/readingu.tf\">readingu</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/remarkable.tf\">remarkable</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/remarks.tf\">remarks</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/repeat.tf\">repeat</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/srcLn.tf\">srcLn</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/srcLnNum.tf\">srcLnNum</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/srcfile.tf\">srcfile</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/supplied.tf\">supplied</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/sym.tf\">sym</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/symr.tf\">symr</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/symu.tf\">symu</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/trans.tf\">trans</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/translation@en.tf\">translation@ll</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/type.tf\">type</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/uncertain.tf\">uncertain</a>  <a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/volume.tf\">volume</a>  <b><i><a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/blob/master/docs//transcription.md\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/tf/1.0.1/oslots.tf\">oslots</a></i></b> </p><p><b>Nino-cunei/oldbabylonian/parallels/tf</b>: <b><i><a target=\"_blank\" href=\"https://github.com/Nino-cunei/oldbabylonian/tree/master/parallels/tf\" title=\"/Users/dirk/text-fabric-data/Nino-cunei/oldbabylonian/parallels/tf/1.0.1/sim.tf\">sim</a></i></b> </p></details>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<style>\n",
       "@font-face {\n",
       "  font-family: \"Santakku\";\n",
       "  src:\n",
       "    local(\"Santakku.ttf\"),\n",
       "    url(\"https://github.com/annotation/text-fabric/blob/master/tf/server/static/fonts/Santakku.woff?raw=true\");\n",
       "}\n",
       ".txtn,.txtn a:visited,.txtn a:link {\n",
       "    font-family: sans-serif;\n",
       "    font-size: normal;\n",
       "    text-decoration: none;\n",
       "}\n",
       ".txtp,.txtp a:visited,.txtp a:link {\n",
       "    font-family: monospace;\n",
       "    font-size: normal;\n",
       "    text-decoration: none;\n",
       "}\n",
       ".txtr,.txtr a:visited,.txtr a:link {\n",
       "    font-family: serif;\n",
       "    font-size: large;\n",
       "    text-decoration: none;\n",
       "}\n",
       ".txtu,.txtu a:visited,.txtu a:link {\n",
       "    font-family: Santakku;\n",
       "    font-size: x-large;\n",
       "    text-decoration: none;\n",
       "}\n",
       ".features {\n",
       "    font-family: monospace;\n",
       "    font-size: medium;\n",
       "    font-weight: bold;\n",
       "    color: #0a6611;\n",
       "    display: flex;\n",
       "    flex-flow: column nowrap;\n",
       "    padding: 0.1em;\n",
       "    margin: 0.1em;\n",
       "    direction: ltr;\n",
       "}\n",
       ".features div,.features span {\n",
       "    padding: 0;\n",
       "    margin: -0.1rem 0;\n",
       "}\n",
       ".features .f {\n",
       "    font-family: sans-serif;\n",
       "    font-size: x-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: 0.1em 0em;\n",
       "}\n",
       ".features .xft .f {\n",
       "  color: #000000;\n",
       "  background-color: #eeeeee;\n",
       "  font-style: italic;\n",
       "  font-size: small;\n",
       "  font-weight: normal;\n",
       "}\n",
       ".pnum {\n",
       "    font-family: sans-serif;\n",
       "    font-size: small;\n",
       "    font-weight: bold;\n",
       "    color: #444444;\n",
       "}\n",
       ".nd {\n",
       "    font-family: monospace;\n",
       "    font-size: x-small;\n",
       "    color: #999999;\n",
       "}\n",
       ".meta {\n",
       "    display: flex;\n",
       "    justify-content: flex-start;\n",
       "    align-items: flex-start;\n",
       "    align-content: flex-start;\n",
       "    flex-flow: row nowrap;\n",
       "}\n",
       ".features,.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",
       ".children {\n",
       "    display: flex;\n",
       "    justify-content: flex-start;\n",
       "    align-items: flex-start;\n",
       "    align-content: flex-start;\n",
       "    border: 0;\n",
       "    background-color: #ffffff;\n",
       "}\n",
       ".children.document {\n",
       "    flex-flow: column nowrap;\n",
       "}\n",
       ".children.face {\n",
       "    flex-flow: column nowrap;\n",
       "}\n",
       ".children.line {\n",
       "    align-items: stretch;\n",
       "    flex-flow: row nowrap;\n",
       "}\n",
       ".children.cluster {\n",
       "    flex-flow: row wrap;\n",
       "}\n",
       ".children.line {\n",
       "    align-items: stretch;\n",
       "    flex-flow: row nowrap;\n",
       "}\n",
       ".children.sign {\n",
       "    flex-flow: column nowrap;\n",
       "}\n",
       ".contnr {\n",
       "    width: fit-content;\n",
       "}\n",
       ".contnr.document,.contnr.face,\n",
       ".contnr.line,\n",
       ".contnr.cluster,\n",
       ".contnr.word,\n",
       ".contnr.sign {\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:  0.5em 0.1em 0.1em 0.1em;\n",
       "    margin: 0.8em 0.1em 0.1em 0.1em;\n",
       "    border-radius: 0.2em;\n",
       "    border-style: solid;\n",
       "    border-width: 0.2em;\n",
       "    font-size: small;\n",
       "}\n",
       ".contnr.document,.contnr.face {\n",
       "    border-color: #bb8800;\n",
       "}\n",
       ".contnr.line {\n",
       "    border-color: #0088bb;\n",
       "}\n",
       ".contnr.cluster {\n",
       "    flex-flow: row wrap;\n",
       "    border: 0;\n",
       "}\n",
       ".contnr.word {\n",
       "    border-color: #44bbff;\n",
       "}\n",
       ".contnr.sign {\n",
       "    border-color: #bbbbbb;\n",
       "}\n",
       ".contnr.hl {\n",
       "    background-color: #ffee66;\n",
       "}\n",
       ".lbl.document,.lbl.face,\n",
       ".lbl.line,\n",
       ".lbl.cluster,\n",
       ".lbl.sign,.lbl.word {\n",
       "    margin-top: -1.2em;\n",
       "    margin-left: 1em;\n",
       "    background: #ffffff none repeat scroll 0 0;\n",
       "    padding: 0 0.3em;\n",
       "    border-style: solid;\n",
       "    font-size: small;\n",
       "    display: block;\n",
       "}\n",
       ".lbl.document,.lbl.face {\n",
       "    border-color: #bb8800;\n",
       "    border-width: 0.3em;\n",
       "    border-radius: 0.3em;\n",
       "    color: #bb8800;\n",
       "}\n",
       ".lbl.line {\n",
       "    border-color: #0088bb;\n",
       "    border-width: 0.3em;\n",
       "    border-radius: 0.3em;\n",
       "    color: #0088bb;\n",
       "}\n",
       ".lbl.cluster {\n",
       "    border-color: #dddddd;\n",
       "    border-width: 0.2em;\n",
       "    border-radius: 0.2em;\n",
       "    color: #0000cc;\n",
       "}\n",
       ".lbl.word {\n",
       "    border-color: #44bbff;\n",
       "    border-width: 0.2em;\n",
       "    border-radius: 0.2em;\n",
       "    font-size: medium;\n",
       "    color: #000000;\n",
       "}\n",
       ".lbl.sign {\n",
       "    border-color: #bbbbbb;\n",
       "    border-width: 0.1em;\n",
       "    border-radius: 0.1em;\n",
       "    font-size: small;\n",
       "    color: #000000;\n",
       "}\n",
       ".op {\n",
       "    padding:  0.5em 0.1em 0.1em 0.1em;\n",
       "    margin: 0.8em 0.1em 0.1em 0.1em;\n",
       "    font-family: monospace;\n",
       "    font-size: x-large;\n",
       "    font-weight: bold;\n",
       "}\n",
       ".name {\n",
       "    font-family: monospace;\n",
       "    font-size: medium;\n",
       "    color: #0000bb;\n",
       "}\n",
       ".period {\n",
       "    font-family: monospace;\n",
       "    font-size: medium;\n",
       "    font-weight: bold;\n",
       "    color: #0000bb;\n",
       "}\n",
       ".text {\n",
       "    font-family: sans-serif;\n",
       "    font-size: x-small;\n",
       "    color: #000000;\n",
       "}\n",
       ".srcln {\n",
       "    font-family: monospace;\n",
       "    font-size: medium;\n",
       "    color: #000000;\n",
       "}\n",
       ".srclnnum {\n",
       "    font-family: monospace;\n",
       "    font-size: x-small;\n",
       "    color: #0000bb;\n",
       "}\n",
       ".comment {\n",
       "    color: #7777dd;\n",
       "    font-family: monospace;\n",
       "    font-size: small;\n",
       "}\n",
       ".operator {\n",
       "    color: #ff77ff;\n",
       "    font-size: large;\n",
       "}\n",
       "/* LANGUAGE: superscript and subscript */\n",
       "\n",
       "/* cluster */\n",
       ".det {\n",
       "    vertical-align: super;\n",
       "}\n",
       "/* cluster */\n",
       ".langalt {\n",
       "    vertical-align: sub;\n",
       "}\n",
       "/* REDACTIONAL: line over or under  */\n",
       "\n",
       "/* flag */\n",
       ".collated {\n",
       "    font-weight: bold;\n",
       "    text-decoration: underline;\n",
       "}\n",
       "/* cluster */\n",
       ".excised {\n",
       "    color: #dd0000;\n",
       "    text-decoration: line-through;\n",
       "}\n",
       "/* cluster */\n",
       ".supplied {\n",
       "    color: #0000ff;\n",
       "    text-decoration: overline;\n",
       "}\n",
       "/* flag */\n",
       ".remarkable {\n",
       "    font-weight: bold;\n",
       "    text-decoration: overline;\n",
       "}\n",
       "\n",
       "/* UNSURE: italic*/\n",
       "\n",
       "/* cluster */\n",
       ".uncertain {\n",
       "    font-style: italic\n",
       "}\n",
       "/* flag */\n",
       ".question {\n",
       "    font-weight: bold;\n",
       "    font-style: italic\n",
       "}\n",
       "\n",
       "/* BROKEN: text-shadow */\n",
       "\n",
       "/* cluster */\n",
       ".missing {\n",
       "    color: #999999;\n",
       "    text-shadow: #bbbbbb 1px 1px;\n",
       "}\n",
       "/* flag */\n",
       ".damage {\n",
       "    font-weight: bold;\n",
       "    color: #999999;\n",
       "    text-shadow: #bbbbbb 1px 1px;\n",
       "}\n",
       ".empty {\n",
       "  color: #ff0000;\n",
       "}\n",
       "\n",
       "span.hldot {\n",
       "\tbackground-color: var(--hl-strong);\n",
       "\tborder: 0.2rem solid var(--hl-rim);\n",
       "\tborder-radius: 0.4rem;\n",
       "\t/*\n",
       "\tdisplay: inline-block;\n",
       "\twidth: 0.8rem;\n",
       "\theight: 0.8rem;\n",
       "\t*/\n",
       "}\n",
       "span.hl {\n",
       "\tbackground-color: var(--hl-strong);\n",
       "\tborder-width: 0;\n",
       "\tborder-radius: 0.1rem;\n",
       "\tborder-style: solid;\n",
       "}\n",
       "\n",
       "span.hlup {\n",
       "\tborder-color: var(--hl-dark);\n",
       "\tborder-width: 0.1rem;\n",
       "\tborder-style: solid;\n",
       "\tborder-radius: 0.2rem;\n",
       "  padding: 0.2rem;\n",
       "}\n",
       "\n",
       ":root {\n",
       "\t--hl-strong:        hsla( 60, 100%,  70%, 0.9  );\n",
       "\t--hl-rim:           hsla( 55, 100%,  60%, 0.9  );\n",
       "\t--hl-dark:          hsla( 55, 100%,  40%, 0.9  );\n",
       "}\n",
       "</style>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<details open><summary><b>API members</b>:</summary>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Computed/#computed-data\" title=\"doc\">C Computed</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Computed/#computed-data\" title=\"doc\">Call AllComputeds</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Computed/#computed-data\" title=\"doc\">Cs ComputedString</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#edge-features\" title=\"doc\">E Edge</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#edge-features\" title=\"doc\">Eall AllEdges</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#edge-features\" title=\"doc\">Es EdgeString</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Fabric/#loading\" title=\"doc\">ensureLoaded</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Fabric/#loading\" title=\"doc\">TF</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Fabric/#loading\" title=\"doc\">ignored</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Fabric/#loading\" title=\"doc\">loadLog</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Locality/#locality\" title=\"doc\">L Locality</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Misc/#messaging\" title=\"doc\">cache</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Misc/#messaging\" title=\"doc\">error</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Misc/#messaging\" title=\"doc\">indent</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Misc/#messaging\" title=\"doc\">info</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Misc/#messaging\" title=\"doc\">reset</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Nodes/#navigating-nodes\" title=\"doc\">N Nodes</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Nodes/#navigating-nodes\" title=\"doc\">sortKey</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Nodes/#navigating-nodes\" title=\"doc\">sortKeyTuple</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Nodes/#navigating-nodes\" title=\"doc\">otypeRank</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Nodes/#navigating-nodes\" title=\"doc\">sortNodes</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#node-features\" title=\"doc\">F Feature</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#node-features\" title=\"doc\">Fall AllFeatures</a>, <a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Features/#node-features\" title=\"doc\">Fs FeatureString</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Search/#search\" title=\"doc\">S Search</a><br/>\n",
       "<a target=\"_blank\" href=\"https://annotation.github.io/text-fabric/Api/Text/#text\" title=\"doc\">T Text</a></details>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "A = use('oldbabylonian', hoist=globals(), check=True, mod='Nino-cunei/oldbabylonian/parallels/tf')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lo and behold: you see the parallels module listed with one feature: `sim`. It is in *italics*, which indicates\n",
    "it is an edge feature.\n",
    "\n",
    "We just do a quick check here and in another notebook we study parallels a bit more, using the feature `sim`.\n",
    "\n",
    "We count how many similar pairs their are, and how many 100% similar pairs there are."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  1.55s 574579 results\n"
     ]
    }
   ],
   "source": [
    "query = '''\n",
    "line\n",
    "-sim> line\n",
    "'''\n",
    "results = A.search(query)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  1.58s 573397 results\n"
     ]
    }
   ],
   "source": [
    "query = '''\n",
    "line\n",
    "-sim=100> line\n",
    "'''\n",
    "results = A.search(query)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Remarkably, most of the pairs are 100 percent similar. Let's show just a few:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><tr><th>n</th><th>p</th><th>line</th><th>line</th></tr>\n",
       "<tr><td>1</td><td> <a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P510729\" title=\"show this document on CDLI\" sec=\"P510729 obverse:1\">P510729 obverse:1</a></td><td><span class=\"txtp\">[a-na] _{d}suen_-i-[din-nam]</span> <i>230787</i> </td><td><span class=\"txtp\">a-na {d}suen-i-din-[nam]</span> <i>235393</i> </td></tr>\n",
       "<tr><td>2</td><td> <a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P510730\" title=\"show this document on CDLI\" sec=\"P510730 obverse:1\">P510730 obverse:1</a></td><td><span class=\"txtp\">[a-na] _{d}suen_-i-[din-nam]</span> <i>230787</i> </td><td><span class=\"txtp\">a-na {d}suen-i-din-nam</span> <i>235420</i> </td></tr>\n",
       "<tr><td>3</td><td> <a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P510731\" title=\"show this document on CDLI\" sec=\"P510731 obverse:1\">P510731 obverse:1</a></td><td><span class=\"txtp\">[a-na] _{d}suen_-i-[din-nam]</span> <i>230787</i> </td><td><span class=\"txtp\">a-na {d}suen-i-din-nam</span> <i>235433</i> </td></tr>\n",
       "<tr><td>4</td><td> <a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P510732\" title=\"show this document on CDLI\" sec=\"P510732 obverse:1\">P510732 obverse:1</a></td><td><span class=\"txtp\">[a-na] _{d}suen_-i-[din-nam]</span> <i>230787</i> </td><td><span class=\"txtp\">a-na {d}suen#-i-din-nam#</span> <i>235463</i> </td></tr>\n",
       "<tr><td>5</td><td> <a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P497779\" title=\"show this document on CDLI\" sec=\"P497779 obverse:1\">P497779 obverse:1</a></td><td><span class=\"txtp\">[a-na] _{d}suen_-i-[din-nam]</span> <i>230787</i> </td><td><span class=\"txtp\">a-na {d}suen#-[i]-din-nam</span> <i>235477</i> </td></tr>\n",
       "<tr><td>6</td><td> <a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P510733\" title=\"show this document on CDLI\" sec=\"P510733 obverse:1\">P510733 obverse:1</a></td><td><span class=\"txtp\">[a-na] _{d}suen_-i-[din-nam]</span> <i>230787</i> </td><td><span class=\"txtp\">[a-na] {d}[suen-i-din-nam]</span> <i>235502</i> </td></tr>\n",
       "<tr><td>7</td><td> <a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P510734\" title=\"show this document on CDLI\" sec=\"P510734 obverse:1\">P510734 obverse:1</a></td><td><span class=\"txtp\">[a-na] _{d}suen_-i-[din-nam]</span> <i>230787</i> </td><td><span class=\"txtp\">[a-na {d}suen-i-din-nam]</span> <i>235528</i> </td></tr>\n",
       "<tr><td>8</td><td> <a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P510736\" title=\"show this document on CDLI\" sec=\"P510736 obverse:1\">P510736 obverse:1</a></td><td><span class=\"txtp\">[a-na] _{d}suen_-i-[din-nam]</span> <i>230787</i> </td><td><span class=\"txtp\">a-na {d}suen-i-din-nam</span> <i>235584</i> </td></tr>\n",
       "<tr><td>9</td><td> <a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P510737\" title=\"show this document on CDLI\" sec=\"P510737 obverse:1\">P510737 obverse:1</a></td><td><span class=\"txtp\">[a-na] _{d}suen_-i-[din-nam]</span> <i>230787</i> </td><td><span class=\"txtp\">a-na {d}suen-i-din-nam#</span> <i>235614</i> </td></tr>\n",
       "<tr><td>10</td><td> <a href=\"https://cdli.ucla.edu/search/search_results.php?SearchMode=Text&amp;ObjectID=P370926\" title=\"show this document on CDLI\" sec=\"P370926 obverse:1\">P370926 obverse:1</a></td><td><span class=\"txtp\">[a-na] _{d}suen_-i-[din-nam]</span> <i>230787</i> </td><td><span class=\"txtp\">a-na {d}suen-i-din-nam</span> <i>235628</i> </td></tr></table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "A.table(results, start=1, end=10, withNodes=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There is also a lower level way to work with edge features.\n",
    "\n",
    "We can list all edges going out from a reference node.\n",
    "What we see is tuple of pairs: the target node and the similarity between the reference node and that target node."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((235919, 100),\n",
       " (235983, 100),\n",
       " (235998, 100),\n",
       " (236046, 100),\n",
       " (236063, 100),\n",
       " (236077, 100),\n",
       " (236115, 100),\n",
       " (236123, 100),\n",
       " (236195, 100),\n",
       " (236222, 100),\n",
       " (236277, 100),\n",
       " (236320, 100),\n",
       " (243205, 100),\n",
       " (244633, 100),\n",
       " (245089, 100),\n",
       " (246839, 100),\n",
       " (246870, 100),\n",
       " (246892, 100),\n",
       " (246911, 100),\n",
       " (246924, 100),\n",
       " (246948, 100),\n",
       " (246961, 100),\n",
       " (247114, 100),\n",
       " (247136, 100),\n",
       " (247235, 100),\n",
       " (247263, 100),\n",
       " (247272, 100),\n",
       " (247317, 100),\n",
       " (247345, 100),\n",
       " (247355, 100),\n",
       " (247371, 100),\n",
       " (247386, 100),\n",
       " (247415, 100),\n",
       " (247436, 100),\n",
       " (247459, 100),\n",
       " (247542, 100),\n",
       " (247696, 100),\n",
       " (247708, 100),\n",
       " (247733, 100),\n",
       " (247749, 100),\n",
       " (247794, 100),\n",
       " (247806, 100),\n",
       " (247829, 100),\n",
       " (247867, 100),\n",
       " (247885, 100),\n",
       " (248014, 100),\n",
       " (248041, 100),\n",
       " (248118, 100),\n",
       " (248172, 100),\n",
       " (248381, 100),\n",
       " (248407, 100),\n",
       " (254854, 100),\n",
       " (256079, 100))"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "refNode = 235900\n",
    "\n",
    "E.sim.f(refNode)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Likewise, we can observe the nodes that target the reference node:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((230787, 100),\n",
       " (235393, 100),\n",
       " (235420, 100),\n",
       " (235433, 100),\n",
       " (235463, 100),\n",
       " (235477, 100),\n",
       " (235502, 100),\n",
       " (235528, 100),\n",
       " (235584, 100),\n",
       " (235614, 100),\n",
       " (235628, 100),\n",
       " (235656, 100),\n",
       " (235683, 100),\n",
       " (235729, 100),\n",
       " (235755, 100),\n",
       " (235777, 100),\n",
       " (235810, 100),\n",
       " (235821, 100),\n",
       " (235837, 100),\n",
       " (235850, 100),\n",
       " (235864, 100),\n",
       " (235878, 100))"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "E.sim.t(refNode)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Both sets of nodes are similar to the reference node and it is inconvenient to use both `.f()` and `.t()` to get the similar lines.\n",
    "\n",
    "But there is another way:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((230787, 100),\n",
       " (235393, 100),\n",
       " (235420, 100),\n",
       " (235433, 100),\n",
       " (235463, 100),\n",
       " (235477, 100),\n",
       " (235502, 100),\n",
       " (235528, 100),\n",
       " (235584, 100),\n",
       " (235614, 100),\n",
       " (235628, 100),\n",
       " (235656, 100),\n",
       " (235683, 100),\n",
       " (235729, 100),\n",
       " (235755, 100),\n",
       " (235777, 100),\n",
       " (235810, 100),\n",
       " (235821, 100),\n",
       " (235837, 100),\n",
       " (235850, 100),\n",
       " (235864, 100),\n",
       " (235878, 100),\n",
       " (235919, 100),\n",
       " (235983, 100),\n",
       " (235998, 100),\n",
       " (236046, 100),\n",
       " (236063, 100),\n",
       " (236077, 100),\n",
       " (236115, 100),\n",
       " (236123, 100),\n",
       " (236195, 100),\n",
       " (236222, 100),\n",
       " (236277, 100),\n",
       " (236320, 100),\n",
       " (243205, 100),\n",
       " (244633, 100),\n",
       " (245089, 100),\n",
       " (246839, 100),\n",
       " (246870, 100),\n",
       " (246892, 100),\n",
       " (246911, 100),\n",
       " (246924, 100),\n",
       " (246948, 100),\n",
       " (246961, 100),\n",
       " (247114, 100),\n",
       " (247136, 100),\n",
       " (247235, 100),\n",
       " (247263, 100),\n",
       " (247272, 100),\n",
       " (247317, 100),\n",
       " (247345, 100),\n",
       " (247355, 100),\n",
       " (247371, 100),\n",
       " (247386, 100),\n",
       " (247415, 100),\n",
       " (247436, 100),\n",
       " (247459, 100),\n",
       " (247542, 100),\n",
       " (247696, 100),\n",
       " (247708, 100),\n",
       " (247733, 100),\n",
       " (247749, 100),\n",
       " (247794, 100),\n",
       " (247806, 100),\n",
       " (247829, 100),\n",
       " (247867, 100),\n",
       " (247885, 100),\n",
       " (248014, 100),\n",
       " (248041, 100),\n",
       " (248118, 100),\n",
       " (248172, 100),\n",
       " (248381, 100),\n",
       " (248407, 100),\n",
       " (254854, 100),\n",
       " (256079, 100))"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "E.sim.b(refNode)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's make sure that `.b()` gives the combination of `.f()` and `.t()`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the intersection of f and t is set()\n",
      "t | f = b ? True\n"
     ]
    }
   ],
   "source": [
    "f = {x[0] for x in E.sim.f(refNode)}\n",
    "b = {x[0] for x in E.sim.b(refNode)}\n",
    "t = {x[0] for x in E.sim.t(refNode)}\n",
    "\n",
    "# are f and t disjoint ?\n",
    "\n",
    "print(f'the intersection of f and t is {f & t}')\n",
    "\n",
    "# is b the union of f and t ?\n",
    "\n",
    "print(f't | f = b ? {f | t == b}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API