{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "\n", "\n", "You might want to consider the [start](search.ipynb) of this tutorial.\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", "* [Q'uran](https://nbviewer.jupyter.org/github/annotation/tutorials/blob/master/lorentz2020/quran.ipynb)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Rich display\n", "\n", "Text-Fabric offers pretty and plain displays of textual objects.\n", "\n", "A **plain** display of an object is a simple reference to that object if it is big, or the text of that object if it is small.\n", "\n", "A **pretty** display of an object is a representation of the structure of that object. It contains text and features of sub objects.\n", "Provided the object is not too big." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Incantation\n", "\n", "The ins and outs of installing Text-Fabric, getting the corpus, and initializing a notebook are\n", "explained in the [start tutorial](start.ipynb)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2018-05-24T10:06:39.818664Z", "start_time": "2018-05-24T10:06:39.796588Z" } }, "outputs": [], "source": [ "from tf.app import use" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2018-05-24T10:06:51.615044Z", "start_time": "2018-05-24T10:06:50.161456Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using TF-app in /Users/dirk/github/annotation/app-bhsa/code:\n", "\trepo clone offline under ~/github (local github)\n", "Using data in /Users/dirk/github/etcbc/bhsa/tf/c:\n", "\trepo clone offline under ~/github (local github)\n", "Using data in /Users/dirk/github/etcbc/phono/tf/c:\n", "\trepo clone offline under ~/github (local github)\n", "Using data in /Users/dirk/github/etcbc/parallels/tf/c:\n", "\trepo clone offline under ~/github (local github)\n", " | 0.00s Dataset without structure sections in otext:no structure functions in the T-API\n" ] }, { "data": { "text/html": [ "Documentation: BHSA Character table Feature docs bhsa API Text-Fabric API 8.0.0 Search Reference
Loaded features:\n", "

Parallel Passages: crossref

BHSA = Biblia Hebraica Stuttgartensia Amstelodamensis: book book@ll chapter code det domain freq_lex function g_cons g_cons_utf8 g_lex g_lex_utf8 g_word g_word_utf8 gloss gn label language lex lex_utf8 ls nametype nme nu number otype pargr pdp pfm prs prs_gn prs_nu prs_ps ps qere qere_trailer qere_trailer_utf8 qere_utf8 rank_lex rela sp st tab trailer trailer_utf8 txt typ uvf vbe vbs verse voc_lex voc_lex_utf8 vs vt mother oslots

Phonetic Transcriptions: phono phono_trailer

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
API members:\n", "C Computed, Call AllComputeds, Cs ComputedString
\n", "E Edge, Eall AllEdges, Es EdgeString
\n", "ensureLoaded, TF, ignored, loadLog
\n", "L Locality
\n", "cache, error, indent, info, isSilent, reset, setSilent, silentOff, silentOn, warning
\n", "N Nodes, sortKey, sortKeyTuple, otypeRank, sortNodes
\n", "F Feature, Fall AllFeatures, Fs FeatureString
\n", "S Search
\n", "T Text
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# A = use('bhsa', hoist=globals())\n", "A = use('bhsa:clone', checkout=\"clone\", hoist=globals())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Arbitrary nodes\n", "We pretty-print some (arbitrary) nodes.\n", "\n", "The first verse." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1414354" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v1 = A.nodeFromSectionStr('Genesis 1:1')\n", "v1" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:1 " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(v1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With standard features displayed:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:1 
verse
sentence 1
clause xQtX NA
phrase PP Time
inpdp=prep
beginningpdp=subs
phrase VP Pred
createpdp=verbvs=qalvt=perf
phrase NP Subj
god(s)pdp=subs
phrase PP Objc
<object marker>pdp=prep
thepdp=art
heavenspdp=subs
andpdp=conj
<object marker>pdp=prep
thepdp=art
earthpdp=subs
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(v1, standardFeatures=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now a phrase. We display it with little and with much information." ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:57:33.060576Z", "start_time": "2018-04-25T13:57:33.051457Z" } }, "outputs": [ { "data": { "text/html": [ "Genesis 1:4 " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Genesis 1:4 
phrase:651574 PP Cmpl
phrase_atom:904781 PP NA
intervalpdp=prep
52 הָ
thepdp=art
lightpdp=subs
54 וּ
andpdp=conj
intervalpdp=prep
56 הַ
thepdp=art
darknesspdp=subs
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "phrase = 651574\n", "A.pretty(phrase, withNodes=False, prettyTypes=False)\n", "A.pretty(phrase, withNodes=True, standardFeatures=True, showChunks=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Where is this phrase on SHEBANQ?\n", "You can click on the passage reference.\n", "\n", "You can generate a link that points to where a node is on SHEBANQ as follows:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:57:36.441490Z", "start_time": "2018-04-25T13:57:36.432236Z" } }, "outputs": [ { "data": { "text/html": [ "Genesis 1:4" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.webLink(phrase)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you want just the url:" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:57:36.441490Z", "start_time": "2018-04-25T13:57:36.432236Z" } }, "outputs": [ { "data": { "text/plain": [ "'https://shebanq.ancient-data.org/hebrew/text?book=Genesis&chapter=1&verse=4&version=c&mr=m&qw=q&tp=txt_p&tr=hb&wget=v&qget=v&nget=vt'" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A.webLink(phrase, urlOnly=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A link to another passage:" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:57:46.144712Z", "start_time": "2018-04-25T13:57:46.138983Z" } }, "outputs": [], "source": [ "z = A.nodeFromSectionStr('Ezra 3:4')" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:57:47.022343Z", "start_time": "2018-04-25T13:57:47.012756Z" } }, "outputs": [ { "data": { "text/html": [ "Ezra 3:4" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.webLink(z)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Plain\n", "\n", "We can represent a node in plain representation and highlight specific portions." ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "firstVerse = F.otype.s('verse')[0]\n", "allPhrases = F.otype.s('phrase')\n", "phrases = {allPhrases[1], allPhrases[3]}\n", "words = (2, 4, 6, 9)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:1  בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "firstSentence = F.otype.s('sentence')[0]\n", "A.plain(firstSentence)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First we highlight some words:" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:1  בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "highlights = set(words)\n", "A.plain(firstVerse, highlights=highlights)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now some phrases:" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{651545, 651543}\n" ] }, { "data": { "text/html": [ "Genesis 1:1  בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "highlights = set(phrases)\n", "print(highlights)\n", "A.plain(firstVerse, highlights=highlights)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As you see, when we highlight bigger things than words, we put a \n", "highlighted border around the words in those things." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can do both:" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:1  בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "highlights = set(phrases) | set(words)\n", "A.plain(firstVerse, highlights=highlights)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also highlight the verse itself." ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:1  בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "highlights = {firstVerse}\n", "A.plain(firstVerse, highlights=highlights)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can use different colors for highlighting:\n", "\n", "* some words are red\n", "* some other words are green\n", "* phrases are blue" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:1  בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "highlights = {i: 'lightsalmon' for i in [1, 5, 9]}\n", "highlights.update({i: 'mediumaquamarine' for i in [3, 7]})\n", "highlights.update({i: 'blue' for i in phrases})\n", "highlights.update({firstVerse: '#eeeeee'})\n", "A.plain(firstVerse, highlights=highlights)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Pretty\n", "We define two verse nodes:" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:57:50.369004Z", "start_time": "2018-04-25T13:57:50.363695Z" } }, "outputs": [], "source": [ "verse1 = A.nodeFromSectionStr('Genesis 1:7')\n", "verse2 = A.nodeFromSectionStr('Genesis 1:17')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and display the first one:" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:57:53.124725Z", "start_time": "2018-04-25T13:57:53.108960Z" } }, "outputs": [ { "data": { "text/html": [ "Genesis 1:7 
verse
sentence
sentence
clause
phrase
phrase
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(verse1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the next verse we choose a bit more to display: we include standard features:" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:58:01.798768Z", "start_time": "2018-04-25T13:58:01.787884Z" } }, "outputs": [ { "data": { "text/html": [ "Genesis 1:17 
verse
sentence 46
clause WayX NA
phrase CP Conj
andpdp=conj
phrase VP Pred
givepdp=verbvs=qalvt=wayq
phrase PP Objc
<object marker>pdp=prep
phrase NP Subj
god(s)pdp=subs
phrase PP Cmpl
inpdp=prep
firmamentpdp=subs
thepdp=art
heavenspdp=subs
clause InfC Adju
phrase VP Pred
topdp=prep
be lightpdp=verbvs=hifvt=infc
phrase PP Cmpl
uponpdp=prep
thepdp=art
earthpdp=subs
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(verse2, standardFeatures=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The labels of the nodes come from features in the data: hover over a label to see which feature is responsible.\n", "The same holds for the unnamed features below the words, in particular the gloss." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that the sentence in this verse continues after the verse ends, that is why it has no left border.\n", "\n", "In the BHSA,entences, clauses and phrases may be discontinuous.\n", "The designers of the BHSA data (Eep Talstra and Constantijn Sikkel et al.) have added node types\n", "*sentence_atom*, *clause_atom* and *phrase_atom*.\n", "\n", "They are the continuous chunks within the objects of their corresponding non-atom types.\n", "The atom types form a nice nest of building blocks.\n", "\n", "Usually we hide the atom types from view. However, you still see a weak border where the chunks (atoms) are.\n", "But we can make them visible:" ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:58:01.798768Z", "start_time": "2018-04-25T13:58:01.787884Z" } }, "outputs": [ { "data": { "text/html": [ "Genesis 1:17 
verse
sentence
sentence_atom
clause
clause_atom
phrase
phrase_atom
phrase
phrase_atom
phrase
phrase_atom
phrase
clause
clause_atom
phrase
phrase_atom
phrase
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(verse2, showChunks=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Back to the view without the atoms.\n", "\n", "We can even leave out the node types:" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:58:01.798768Z", "start_time": "2018-04-25T13:58:01.787884Z" } }, "outputs": [ { "data": { "text/html": [ "Genesis 1:17 " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(verse2, prettyTypes=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We put in the features (again) and also add node numbers:" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:17 
verse:1414370
sentence:1172335 46
clause:427611 WayX NA
phrase:651720 CP Conj
314 וַ
andpdp=conj
phrase:651721 VP Pred
givepdp=verbvs=qalvt=wayq
phrase:651722 PP Objc
<object marker>pdp=prep
phrase:651723 NP Subj
god(s)pdp=subs
phrase:651724 PP Cmpl
318 בִּ
inpdp=prep
firmamentpdp=subs
320 הַ
thepdp=art
heavenspdp=subs
clause:427612 InfC Adju
phrase:651725 VP Pred
322 לְ
topdp=prep
be lightpdp=verbvs=hifvt=infc
phrase:651726 PP Cmpl
uponpdp=prep
325 הָ
thepdp=art
earthpdp=subs
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(verse2, withNodes=True, standardFeatures=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we selectively remove a few features from the display:" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:58:07.808474Z", "start_time": "2018-04-25T13:58:07.784567Z" } }, "outputs": [ { "data": { "text/html": [ "Genesis 1:17 
verse
sentence 46
clause NA
phrase Conj
pdp=conj
phrase Pred
pdp=verbvs=qalvt=wayq
phrase Objc
phrase Subj
phrase Cmpl
pdp=prep
pdp=art
clause Adju
phrase Pred
pdp=prep
pdp=verbvs=hifvt=infc
phrase Cmpl
pdp=prep
pdp=art
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(verse2, standardFeatures=True, suppress={'gloss', 'typ'})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we add features to the display: `lex` and `g_word` :" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "A.displaySetup(extraFeatures=['lex', 'g_word'], standardFeatures=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We also made `standardFeatures=True)` the temporary default." ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:17 
verse
sentence 46
clause WayX NA
phrase CP Conj
andpdp=conjg_word=WA-lex=W
phrase VP Pred
givepdp=verbvs=qalvt=wayqg_word=J.IT.;71Nlex=NTN[
phrase PP Objc
<object marker>pdp=prepg_word=>OT@91Mlex=>T
phrase NP Subj
god(s)pdp=subsg_word=>:ELOHI73JMlex=>LHJM/
phrase PP Cmpl
inpdp=prepg_word=B.I-lex=B
firmamentpdp=subsg_word=R:QI74J<Alex=RQJ</
thepdp=artg_word=HA-lex=H
heavenspdp=subsg_word=C.@M@92JIMlex=CMJM/
clause InfC Adju
phrase VP Pred
topdp=prepg_word=L:-lex=L
be lightpdp=verbvs=hifvt=infcg_word=H@>I73JRlex=>WR[
phrase PP Cmpl
uponpdp=prepg_word=<ALlex=<L
thepdp=artg_word=H@-lex=H
earthpdp=subsg_word=>@75REYlex=>RY/
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(verse2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and we reset the pretty features to the default values:" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [], "source": [ "A.displayReset('extraFeatures')" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:17 
verse
sentence 46
clause WayX NA
phrase CP Conj
andpdp=conj
phrase VP Pred
givepdp=verbvs=qalvt=wayq
phrase PP Objc
<object marker>pdp=prep
phrase NP Subj
god(s)pdp=subs
phrase PP Cmpl
inpdp=prep
firmamentpdp=subs
thepdp=art
heavenspdp=subs
clause InfC Adju
phrase VP Pred
topdp=prep
be lightpdp=verbvs=hifvt=infc
phrase PP Cmpl
uponpdp=prep
thepdp=art
earthpdp=subs
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(verse2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also opt for less detail: suppose we do not want to dig deeper than the phrases:" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:17 
verse
sentence 46
clause WayX NA
phrase וַ
phrase יִּתֵּ֥ן
phrase אֹתָ֛ם
phrase אֱלֹהִ֖ים
phrase בִּרְקִ֣יעַ הַשָּׁמָ֑יִם
clause InfC Adju
phrase לְהָאִ֖יר
phrase עַל־הָאָֽרֶץ׃
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(verse2, baseTypes={\"phrase\"})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "or if clauses are enough:" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:17 
verse
sentence 46
clause וַיִּתֵּ֥ן אֹתָ֛ם אֱלֹהִ֖ים בִּרְקִ֣יעַ הַשָּׁמָ֑יִם
clause לְהָאִ֖יר עַל־הָאָֽרֶץ׃
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(verse2, baseTypes={\"clause\"})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "even sentences are possible:" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Genesis 1:17 
verse
sentence וַיִּתֵּ֥ן אֹתָ֛ם אֱלֹהִ֖ים בִּרְקִ֣יעַ הַשָּׁמָ֑יִם לְהָאִ֖יר עַל־הָאָֽרֶץ׃
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.pretty(verse2, baseTypes={\"sentence\"})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Before we go on, we reset the display completely." ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [], "source": [ "A.displayReset()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Query results\n", "We run a TF query and show some of its results with a lot of pomp and circumstance.\n", "The query is written by Stephen Ku, and he is the one who prompted me to write\n", "rich display function for query results.\n", "\n", "It asks for a sentence in which there are three clauses, each entirely before the next one.\n", "\n", "The first clause has a predicate phrase containing a verb.\n", "\n", "The second clause has a predicate phrase, a verb is not required nor forbidden.\n", "\n", "The third clause has an object phrase containing a (proper) noun or personal/demonstrative/interrogative pronoun." ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:58:11.225978Z", "start_time": "2018-04-25T13:58:11.220671Z" } }, "outputs": [], "source": [ "ellipQuery = '''\n", "sentence\n", " c1:clause\n", " phrase function=Pred\n", " word pdp=verb\n", " c2:clause\n", " phrase function=Pred\n", " c3:clause typ=Ellp\n", " phrase function=Objc\n", " word pdp=subs|nmpr|prps|prde|prin\n", " c1 << c2\n", " c2 << c3\n", "'''" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Above is the query *template*. Now we *run* the query." ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:58:18.022692Z", "start_time": "2018-04-25T13:58:14.862389Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 2.28s 1472 results\n" ] } ], "source": [ "results = A.search(ellipQuery)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are several ways to present the results.\n", "Here are results 10-12 in a table:" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "
npsentenceclausephrasewordclausephraseclausephraseword
10Exodus 18:8וַיְסַפֵּ֤ר מֹשֶׁה֙ לְחֹ֣תְנֹ֔ו אֵת֩ כָּל־אֲשֶׁ֨ר עָשָׂ֤ה יְהוָה֙ לְפַרְעֹ֣ה וּלְמִצְרַ֔יִם עַ֖ל אֹודֹ֣ת יִשְׂרָאֵ֑ל אֵ֤ת כָּל־הַתְּלָאָה֙ אֲשֶׁ֣ר מְצָאָ֣תַם בַּדֶּ֔רֶךְ וַיַּצִּלֵ֖ם יְהוָֽה׃ וַיְסַפֵּ֤ר מֹשֶׁה֙ לְחֹ֣תְנֹ֔ו אֵת֩ כָּל־יְסַפֵּ֤ר יְסַפֵּ֤ר אֲשֶׁ֨ר עָשָׂ֤ה יְהוָה֙ לְפַרְעֹ֣ה וּלְמִצְרַ֔יִם עַ֖ל אֹודֹ֣ת יִשְׂרָאֵ֑ל עָשָׂ֤ה אֵ֤ת כָּל־הַתְּלָאָה֙ אֵ֤ת כָּל־הַתְּלָאָה֙ כָּל־
11Exodus 18:8וַיְסַפֵּ֤ר מֹשֶׁה֙ לְחֹ֣תְנֹ֔ו אֵת֩ כָּל־אֲשֶׁ֨ר עָשָׂ֤ה יְהוָה֙ לְפַרְעֹ֣ה וּלְמִצְרַ֔יִם עַ֖ל אֹודֹ֣ת יִשְׂרָאֵ֑ל אֵ֤ת כָּל־הַתְּלָאָה֙ אֲשֶׁ֣ר מְצָאָ֣תַם בַּדֶּ֔רֶךְ וַיַּצִּלֵ֖ם יְהוָֽה׃ וַיְסַפֵּ֤ר מֹשֶׁה֙ לְחֹ֣תְנֹ֔ו אֵת֩ כָּל־יְסַפֵּ֤ר יְסַפֵּ֤ר אֲשֶׁ֨ר עָשָׂ֤ה יְהוָה֙ לְפַרְעֹ֣ה וּלְמִצְרַ֔יִם עַ֖ל אֹודֹ֣ת יִשְׂרָאֵ֑ל עָשָׂ֤ה אֵ֤ת כָּל־הַתְּלָאָה֙ אֵ֤ת כָּל־הַתְּלָאָה֙ תְּלָאָה֙
12Exodus 23:15אֶת־חַ֣ג הַמַּצֹּות֮ תִּשְׁמֹר֒ וְחַ֤ג הַקָּצִיר֙ בִּכּוּרֵ֣י מַעֲשֶׂ֔יךָ אֲשֶׁ֥ר תִּזְרַ֖ע בַּשָּׂדֶ֑ה וְחַ֤ג הָֽאָסִף֙ בְּצֵ֣את הַשָּׁנָ֔ה בְּאָסְפְּךָ֥ אֶֽת־מַעֲשֶׂ֖יךָ מִן־הַשָּׂדֶֽה׃ אֶת־חַ֣ג הַמַּצֹּות֮ תִּשְׁמֹר֒ תִּשְׁמֹר֒ תִּשְׁמֹר֒ אֲשֶׁ֥ר תִּזְרַ֖ע בַּשָּׂדֶ֑ה תִּזְרַ֖ע וְחַ֤ג הָֽאָסִף֙ חַ֤ג הָֽאָסִף֙ חַ֤ג
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.table(results, start=10, end=12)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also show the results in pretty displays.\n", "The `A.show()` function asks you for some limits (it will not show more than 100 at a time), and then it displays them.\n", "\n", "It lists the results as follows:\n", "\n", "* a heading showing which result in the sequence of all results this is\n", "* a display of all verses that have result material, with the places highlighted that \n", " correspond to a node in the result tuple\n", " \n", "We show result 10 only." ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:58:23.002898Z", "start_time": "2018-04-25T13:58:21.622054Z" } }, "outputs": [ { "data": { "text/html": [ "

result 10

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Exodus 18:8 
verse:1416361
sentence:1178439
clause:435507
typ=WayX
phrase:675471
function=Conjtyp=CP
38604 וַ
phrase:675472
function=Predtyp=VP
phrase:675473
function=Subjtyp=PrNP
phrase:675474
function=Cmpltyp=PP
phrase:675475
function=Objctyp=PP
38609 אֵת֩
clause:435508
typ=xQtX
phrase:675476
function=Relatyp=CP
phrase:675477
function=Predtyp=VP
phrase:675478
function=Subjtyp=PrNP
phrase:675479
function=Cmpltyp=PP
phrase:675480
function=Adjutyp=PP
clause:435509
typ=Ellp
phrase:675481
function=Objctyp=PP
clause:435510
typ=xQt0
phrase:675482
function=Relatyp=CP
phrase:675483
function=PreOtyp=VP
phrase:675484
function=Locatyp=PP
38628 בַּ
38629
clause:435511
typ=WayX
phrase:675485
function=Conjtyp=CP
38631 וַ
phrase:675486
function=PreOtyp=VP
phrase:675487
function=Subjtyp=PrNP
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.show(results, start=10, end=10, withNodes=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that although the *standard* features are not all shown, the features mentioned in the query are shown.\n", "We can suppress that as well:" ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:58:23.002898Z", "start_time": "2018-04-25T13:58:21.622054Z" } }, "outputs": [ { "data": { "text/html": [ "

result 10

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Exodus 18:8 
verse:1416361
sentence:1178439
clause:435507
phrase:675471
38604 וַ
phrase:675472
phrase:675473
phrase:675474
phrase:675475
38609 אֵת֩
clause:435508
phrase:675476
phrase:675477
phrase:675478
phrase:675479
phrase:675480
clause:435509
phrase:675481
clause:435510
phrase:675482
phrase:675483
phrase:675484
38628 בַּ
38629
clause:435511
phrase:675485
38631 וַ
phrase:675486
phrase:675487
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.show(results, start=10, end=10, withNodes=True, queryFeatures=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also package the results tuples in other things than verses, e.g. sentences, and at the same time cut off the displays at phrases:" ] }, { "cell_type": "code", "execution_count": 50, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:58:23.002898Z", "start_time": "2018-04-25T13:58:21.622054Z" } }, "outputs": [ { "data": { "text/html": [ "

result 10

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Exodus 18:8 
sentence:1178439
clause:435507
phrase:675471 וַ
phrase:675472 67547238605יְסַפֵּ֤ר
phrase:675473 מֹשֶׁה֙
phrase:675474 לְחֹ֣תְנֹ֔ו
phrase:675475 אֵת֩ כָּל־
clause:435508
phrase:675476 אֲשֶׁ֨ר
phrase:675477 675477עָשָׂ֤ה
phrase:675478 יְהוָה֙
phrase:675479 לְפַרְעֹ֣ה וּלְמִצְרַ֔יִם
phrase:675480 עַ֖ל אֹודֹ֣ת יִשְׂרָאֵ֑ל
clause:435509
phrase:675481 675481אֵ֤ת 38623כָּל־הַתְּלָאָה֙
clause:435510
phrase:675482 אֲשֶׁ֣ר
phrase:675483 מְצָאָ֣תַם
phrase:675484 בַּדֶּ֔רֶךְ
clause:435511
phrase:675485 וַ
phrase:675486 יַּצִּלֵ֖ם
phrase:675487 יְהוָֽה׃
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "

result 11

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Exodus 18:8 
sentence:1178439
clause:435507
phrase:675471 וַ
phrase:675472 67547238605יְסַפֵּ֤ר
phrase:675473 מֹשֶׁה֙
phrase:675474 לְחֹ֣תְנֹ֔ו
phrase:675475 אֵת֩ כָּל־
clause:435508
phrase:675476 אֲשֶׁ֨ר
phrase:675477 675477עָשָׂ֤ה
phrase:675478 יְהוָה֙
phrase:675479 לְפַרְעֹ֣ה וּלְמִצְרַ֔יִם
phrase:675480 עַ֖ל אֹודֹ֣ת יִשְׂרָאֵ֑ל
clause:435509
phrase:675481 675481אֵ֤ת כָּל־הַ38625תְּלָאָה֙
clause:435510
phrase:675482 אֲשֶׁ֣ר
phrase:675483 מְצָאָ֣תַם
phrase:675484 בַּדֶּ֔רֶךְ
clause:435511
phrase:675485 וַ
phrase:675486 יַּצִּלֵ֖ם
phrase:675487 יְהוָֽה׃
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "

result 12

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Exodus 23:15 
sentence:1178876
clause:436054
phrase:677181 אֶת־חַ֣ג הַמַּצֹּות֮
phrase:677182 67718241256תִּשְׁמֹר֒
sentence:1178876
clause:436059
phrase:677199 וְ
phrase:677200 חַ֤ג הַקָּצִיר֙
phrase:677201 בִּכּוּרֵ֣י מַעֲשֶׂ֔יךָ
clause:436060
phrase:677202 אֲשֶׁ֥ר
phrase:677203 677203תִּזְרַ֖ע
phrase:677204 בַּשָּׂדֶ֑ה
clause:436061
phrase:677205 וְ
phrase:677206 67720641291חַ֤ג הָֽאָסִף֙
clause:436062
phrase:677207 בְּצֵ֣את
phrase:677208 הַשָּׁנָ֔ה
clause:436063
phrase:677209 בְּאָסְפְּךָ֥
phrase:677210 אֶֽת־מַעֲשֶׂ֖יךָ
phrase:677211 מִן־הַשָּׂדֶֽה׃
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.displaySetup(queryFeatures=False)\n", "A.show(results, start=10, end=12, withNodes=True, condenseType='sentence', baseTypes={\"phrase\"})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note, that now the phrases are heavily highlighted whereas the highlighted words just have a box around them." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's leave out some information:" ] }, { "cell_type": "code", "execution_count": 51, "metadata": { "ExecuteTime": { "end_time": "2018-04-25T13:58:23.002898Z", "start_time": "2018-04-25T13:58:21.622054Z" } }, "outputs": [ { "data": { "text/html": [ "

result 10

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
וַיְסַפֵּ֤ר מֹשֶׁה֙ לְחֹ֣תְנֹ֔ו אֵת֩ כָּל־
אֲשֶׁ֨ר עָשָׂ֤ה יְהוָה֙ לְפַרְעֹ֣ה וּלְמִצְרַ֔יִם עַ֖ל אֹודֹ֣ת יִשְׂרָאֵ֑ל
אֵ֤ת כָּל־הַתְּלָאָה֙
אֲשֶׁ֣ר מְצָאָ֣תַם בַּדֶּ֔רֶךְ
וַיַּצִּלֵ֖ם יְהוָֽה׃
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "

result 11

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
וַיְסַפֵּ֤ר מֹשֶׁה֙ לְחֹ֣תְנֹ֔ו אֵת֩ כָּל־
אֲשֶׁ֨ר עָשָׂ֤ה יְהוָה֙ לְפַרְעֹ֣ה וּלְמִצְרַ֔יִם עַ֖ל אֹודֹ֣ת יִשְׂרָאֵ֑ל
אֵ֤ת כָּל־הַתְּלָאָה֙
אֲשֶׁ֣ר מְצָאָ֣תַם בַּדֶּ֔רֶךְ
וַיַּצִּלֵ֖ם יְהוָֽה׃
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "

result 12

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
אֶת־חַ֣ג הַמַּצֹּות֮ תִּשְׁמֹר֒
וְחַ֤ג הַקָּצִיר֙ בִּכּוּרֵ֣י מַעֲשֶׂ֔יךָ
אֲשֶׁ֥ר תִּזְרַ֖ע בַּשָּׂדֶ֑ה
וְחַ֤ג הָֽאָסִף֙
בְּצֵ֣את הַשָּׁנָ֔ה
בְּאָסְפְּךָ֥ אֶֽת־מַעֲשֶׂ֖יךָ מִן־הַשָּׂדֶֽה׃
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A.show(results, start=10, end=12, withNodes=False, prettyTypes=False, condenseType='sentence', baseTypes={\"clause\"}, withPassage=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# All steps\n", "\n", "* **[start](start.ipynb)** your first step in mastering the bible computationally\n", "* **display** become an expert in creating pretty displays of your text structures\n", "* **[search](search.ipynb)** turbo charge your hand-coding with search templates\n", "* **[exportExcel](exportExcel.ipynb)** make tailor-made spreadsheets out of your results\n", "* **[share](share.ipynb)** draw in other people's data and let them use yours\n", "* **[export](export.ipynb)** export your dataset as an Emdros database\n", "\n", "CC-BY Dirk Roorda" ] } ], "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.7" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": true, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": {}, "toc_section_display": "block", "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }