{ "cells": [ { "cell_type": "markdown", "id": "b33ecd94-2835-4391-9f08-670b379d13de", "metadata": {}, "source": [ "# Speaking to objects (Nestle1904GBI)\n", "\n", "**Work in progress**" ] }, { "cell_type": "markdown", "id": "d53d318b-65fe-4980-8a48-daddd355f115", "metadata": {}, "source": [ "## Table of content \n", "* 1 - Introduction\n", " * 1.1 - Why is this relevant?\n", " * 1.2 - Translating into Text-Fabric queries\n", "* 2 - Load Text-Fabric app and data\n", "* 3 - Performing the queries\n", " * 3.1 - Find phrase combinations where someone is speaking\n", " * 3.2 - TBD\n", "* 4 - Footnotes and attribution\n", "* 5 - Required libraries" ] }, { "cell_type": "markdown", "id": "8ab013e2-c82e-4cd8-a54f-d696b1bebd41", "metadata": {}, "source": [ "# 1 - Introduction \n", "##### [Back to TOC](#TOC)\n", "\n", "TBD" ] }, { "cell_type": "markdown", "id": "111d375c-1586-44a2-83c4-79ae3ad3bdb8", "metadata": {}, "source": [ "## 1.1 - Why is this relevant? \n", "\n", "TBD" ] }, { "cell_type": "markdown", "id": "ab706eb1-49c4-4f5e-96d2-ca62f45dae37", "metadata": { "tags": [] }, "source": [ "## 1.2 - Translating into Text-Fabric queries \n", "\n", "Since we are looking for situations where someone or something is speaking to an object, we first need to look for phrases with function 'Object function' (O). \n", "\n", "\n", "It is using the classification by [Louw-Nida](https://www.laparola.net/greco/louwnida.php):\n", "> ```\n", "1 Geographical Objects and Features\n", "2 Natural Substances\n", "3 Plants\n", "4 Animals\n", "5 Foods and Condiments\n", "6 Artifacts\n", "7 Constructions\n", "```" ] }, { "cell_type": "markdown", "id": "dbc8843b-4930-4ab4-b92b-dbbfb76ca88f", "metadata": {}, "source": [ "# 2 - Load Text-Fabric app and data \n", "##### [Back to TOC](#TOC)" ] }, { "cell_type": "code", "execution_count": 2, "id": "9cc1b0db-edf8-4795-af72-2f2be414d5d8", "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 1, "id": "6abd3aa9-e545-48f1-8392-33b63e28db6d", "metadata": {}, "outputs": [], "source": [ "# Loading the Text-Fabric code\n", "# Note: it is assumed Text-Fabric is installed in your environment\n", "from tf.fabric import Fabric\n", "from tf.app import use" ] }, { "cell_type": "code", "execution_count": 2, "id": "61625284-ca5a-4832-b188-c881d8efceca", "metadata": { "scrolled": true, "tags": [] }, "outputs": [ { "data": { "text/markdown": [ "**Locating corpus resources ...**" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "app: ~/text-fabric-data/github/tonyjurg/Nestle1904GBI/app" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "data: ~/text-fabric-data/github/tonyjurg/Nestle1904GBI/tf/0.4" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", " Text-Fabric: Text-Fabric API 11.4.10, tonyjurg/Nestle1904GBI/app v3, Search Reference
\n", " Data: tonyjurg - Nestle1904GBI 0.4, Character table, Feature docs
\n", "
Node types\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", "\n", "
Name# of nodes# slots/node% coverage
book275102.93100
chapter260529.92100
sentence572024.09100
verse794317.35100
clause161248.54100
phrase726741.90100
word1377791.00100
\n", " Sets: no custom sets
\n", " Features:
\n", "
Nestle 1904 (GBI nodes)\n", "
\n", "\n", "
\n", "
\n", "after\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "book\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "booknum\n", "
\n", "
int
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "bookshort\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "case\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "chapter\n", "
\n", "
int
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "clause\n", "
\n", "
int
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "clauserule\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "clausetype\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "degree\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "formaltag\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "functionaltag\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "gloss\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "gn\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "lemma\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "lex_dom\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "ln\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "monad\n", "
\n", "
int
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "mood\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "nodeID\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "normalized\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "nu\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "number\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "otype\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "person\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "phrase\n", "
\n", "
int
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "phrasefunction\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "phrasefunctionlong\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "phrasetype\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "sentence\n", "
\n", "
int
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "sp\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "splong\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "strongs\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "subj_ref\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "tense\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "type\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "verse\n", "
\n", "
int
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "voice\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "word\n", "
\n", "
str
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "oslots\n", "
\n", "
none
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "
\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Text-Fabric API: names N F E L T S C TF directly usable

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# load the N1904 app and data\n", "N1904 = use (\"tonyjurg/Nestle1904GBI\", version=\"0.4\", hoist=globals())" ] }, { "cell_type": "code", "execution_count": 3, "id": "08eef999-dda6-4551-b8e2-0b3032c8e582", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# The following will push the Text-Fabric stylesheet to this notebook (to facilitate proper display with notebook viewer)\n", "N1904.dh(N1904.getCss())" ] }, { "cell_type": "markdown", "id": "6cee9712-ae79-477c-9f39-1a51e3a0a8a1", "metadata": { "tags": [] }, "source": [ "# 3 - Performing the queries \n", "##### [Back to TOC](#TOC)" ] }, { "cell_type": "markdown", "id": "e2b752ab-1b2a-46f3-a079-fe0a45555b8d", "metadata": {}, "source": [ "## 3.1 - Find phrase combinations where someone is speaking\n", "##### [Back to TOC](#TOC)\n", "\n", "For demonstration purposes the table output is limited to 3 results." ] }, { "cell_type": "code", "execution_count": 4, "id": "7dc0bcba-58a5-49c4-b2bd-2d9c5149786d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.35s 211 results\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", "
npbookchapterclausephrasewordphraseword
1Matthew 2:13MatthewMatthew 2ἰδοὺ ἄγγελος κυρίου φαίνεται κατ’ ὄναρ τῷ Ἰωσὴφ λέγων Ἐγερθεὶς παράλαβε τὸ παιδίον καὶ τὴν μητέρα αὐτοῦ καὶ φεῦγε εἰς Αἴγυπτον, λέγων Ἐγερθεὶς παράλαβε λέγων τὸ παιδίον καὶ τὴν μητέρα αὐτοῦ καὶ παιδίον
2Matthew 2:13MatthewMatthew 2καὶ ἴσθι ἐκεῖ ἕως ἂν εἴπω σοι· μέλλει γὰρ Ἠρῴδης ζητεῖν τὸ παιδίον τοῦ ἀπολέσαι αὐτό. εἴπω εἴπω τὸ παιδίον παιδίον
3Matthew 2:20MatthewMatthew 2ἰδοὺ ἄγγελος Κυρίου φαίνεται κατ’ ὄναρ τῷ Ἰωσὴφ ἐν Αἰγύπτῳ λέγων Ἐγερθεὶς παράλαβε τὸ παιδίον καὶ τὴν μητέρα αὐτοῦ καὶ πορεύου εἰς γῆν Ἰσραήλ· τεθνήκασιν γὰρ οἱ ζητοῦντες τὴν ψυχὴν τοῦ παιδίου. λέγων Ἐγερθεὶς παράλαβε λέγων τὸ παιδίον καὶ τὴν μητέρα αὐτοῦ καὶ παιδίον
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Define the query template\n", "SearchObjectPhrases = '''\n", "book \n", " chapter\n", " clause\n", " a:phrase phrasefunction=V\n", " word lemma=λέγω\n", " b:phrase phrasefunction=O\n", " word ln~^[12345679]\\.\n", "'''\n", "\n", "# The following will create a list containing ordered tuples consisting of node numbers of the items as they appear in the query\n", "ObjectPhrasesList = N1904.search(SearchObjectPhrases)\n", "\n", "# Just print a few of the results in a table\n", "N1904.table(ObjectPhrasesList, condensed=False, extraFeatures={'lemma'}, end=3)" ] }, { "cell_type": "markdown", "id": "e7614415-5bcb-45a0-9f1a-5da625c24f9c", "metadata": {}, "source": [ "Another method to display a limit amount of output, this time using [`plainTuple`](https://annotation.github.io/text-fabric/tf/advanced/display.html#tf.advanced.display.plainTuple) is the following:" ] }, { "cell_type": "code", "execution_count": 5, "id": "1d53ff65-c761-48dc-b915-07831a012d1f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.34s 1 result\n" ] }, { "data": { "text/html": [ "
npbookchapterclausephrasewordphraseword
Matthew 2:13MatthewMatthew 2ἰδοὺ ἄγγελος κυρίου φαίνεται κατ’ ὄναρ τῷ Ἰωσὴφ λέγων Ἐγερθεὶς παράλαβε τὸ παιδίον καὶ τὴν μητέρα αὐτοῦ καὶ φεῦγε εἰς Αἴγυπτον, λέγων Ἐγερθεὶς παράλαβε λέγων τὸ παιδίον καὶ τὴν μητέρα αὐτοῦ καὶ παιδίον
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Limit the query result to 1\n", "TruncatedObjectPhrasesList = N1904.search(SearchObjectPhrases,limit=1)\n", "for NodesTuple in TruncatedObjectPhrasesList: N1904.plainTuple(NodesTuple)" ] }, { "cell_type": "markdown", "id": "47a87214-feb2-4b04-9057-91f302ba600c", "metadata": {}, "source": [ "## 3.2 - second try (in progress) \n", "##### [Back to TOC](#TOC)\n", "\n", "For demonstration purposes the table output is limited to the first 10 results.\n", "*the query as it is now only selects the use of 'lego'*" ] }, { "cell_type": "code", "execution_count": 6, "id": "d2f0f841-cf4a-4433-8aef-f496db01ef62", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " 1 \t Matthew 1:16\n", "\n", " 2 \t Matthew 1:20\n", "\n", " 3 \t Matthew 1:22\n", "\n", " 4 \t Matthew 2:2\n", "\n", " 5 \t Matthew 2:5\n", "\n", " 6 \t Matthew 2:8\n", "\n", " 7 \t Matthew 2:13\n", "\n", " 8 \t Matthew 2:13\n", "\n", " 9 \t Matthew 2:15\n", "\n", " 10 \t Matthew 2:17\n" ] } ], "source": [ "MaxNumberOfResuls=10\n", "ThisResult=0\n", "\n", "for node in F.lemma.s('λέγω'):\n", " ThisResult+=1\n", " gloss=F.gloss.v(node)\n", " # Following line creates a nicely formated presentation of the verse\n", " VerseLocation=N1904.sectionStrFromNode(node)\n", " # The following is an alternative allowing free formating:\n", " # VerseLocation=\"{} {}:{}\".format(F.book.v(node),F.chapter.v(node),F.verse.v(node))\n", " print('\\n',ThisResult,'\\t',VerseLocation) \n", " if ThisResult == MaxNumberOfResuls: break\n" ] }, { "cell_type": "markdown", "id": "be1a41a5-78d9-4274-8395-62ce9e9a52f5", "metadata": { "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ "# 4 - Footnotes and attribution \n", "##### [Back to TOC](#TOC)\n", "\n", "N.A." ] }, { "cell_type": "markdown", "id": "9f799351-c6cd-491b-9acc-85793fb99938", "metadata": { "tags": [] }, "source": [ "# 5 - Required libraries \n", "##### [Back to TOC](#TOC)\n", "\n", "The scripts in this notebook require (beside `text-fabric`) the following Python libraries to be installed in the environment:\n", "\n", " {none}\n", "\n", "You can install any missing library from within Jupyter Notebook using either`pip` or `pip3`." ] }, { "cell_type": "code", "execution_count": null, "id": "c2a0308a-7734-4a71-8abc-1f5dd8bec872", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 5 }