"
]
},
"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": "code",
"execution_count": 5,
"id": "22147392-a907-4b64-b9ff-bd334dc464b4",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Set default view in a way to limit noise as much as possible.\n",
"N1904.displaySetup(condensed=True, multiFeatures=False,queryFeatures=False)"
]
},
{
"cell_type": "markdown",
"id": "8fa361fd-fd13-48ad-905d-8886a649faab",
"metadata": {
"tags": []
},
"source": [
"# 3 - Performing the queries \n",
"##### [Back to TOC](#TOC)"
]
},
{
"cell_type": "markdown",
"id": "366d51db-627c-42d7-bf70-24c8eb277ed5",
"metadata": {
"tags": []
},
"source": [
"## 3.1 - Looking for and presenting the incongruent cases\n",
"\n",
"The level of mismatch to select upon can be adjusted by addapting the following lines:\n",
"\n",
"```\n",
"a .gn#gn. b \n",
"b .gn#gn. c\n",
"a .case#case. b\n",
"b .case#case. c\n",
"```\n",
"\n",
"The actual query is presented below:"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "24f91cc3-f97c-4d39-92b3-f121efdebc1b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0.34s 16 results\n"
]
}
],
"source": [
"# Define the query template\n",
"MismatchesQuery = '''\n",
"wg wgrole=adv\n",
" a:word sp=prep\n",
" <: b:word sp=adj\n",
" <: c:word sp=noun \n",
"a .gn#gn. b \n",
"b .gn#gn. c\n",
"a .case#case. b\n",
"b .case#case. c\n",
"'''\n",
"\n",
"MismatchesList = N1904.search(MismatchesQuery)\n",
"# This will create a list containing ordered tuples consisting of node numbers of the items as they appear in the query"
]
},
{
"cell_type": "markdown",
"id": "9801e754-a14c-47a4-855f-f6e0d3d0e0fa",
"metadata": {},
"source": [
"The resulting data, stored in MismatchesList, can be further processed and presented in a table format. It's important to note that the strings displayed under 'Greek' and 'Gloss' are not the running text itself but rather the concatenation of a preposition, adjective, and noun. This way, the table presentation will visualize the data in a more structured manner."
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "cbcfcf04-9cdc-483f-95d8-e2487b2e7415",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(157951, 5117, 5118, 5119)\n"
]
}
],
"source": [
"for result in MismatchesList: \n",
" print (result)\n",
" break"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bdeacfb9-ef39-4d65-9113-febf05a701c0",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# idea to filter out duplicates - not working yet\n",
"\n",
"unique_tuples = set()\n",
"for result in MismatchesList:\n",
" # Process the relevant nodes or features to form a tuple\n",
" tuple_data = (result[0], result[1], result[2], result[3])\n",
" \n",
" # Add the tuple to the set\n",
" unique_tuples.add(tuple_data)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "6735e007-dca5-4c3f-8650-7a197ec8e309",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"╒════════════════════╤════════════════════════╤════════════════════════════════════════╕\n",
"│ location │ Greek │ Gloss │\n",
"╞════════════════════╪════════════════════════╪════════════════════════════════════════╡\n",
"│ Matthew 10:16 │ ἐν μέσῳ λύκων │ in [the] midst of wolves │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ Matthew 10:16 │ ἐν μέσῳ λύκων │ in [the] midst of wolves │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ Matthew 11:11 │ ἐν γεννητοῖς γυναικῶν │ among [those] born of women │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ Matthew 28:1 │ εἰς μίαν σαββάτων │ toward [the] first [day] of [the] week │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ Matthew 28:1 │ εἰς μίαν σαββάτων │ toward [the] first [day] of [the] week │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ Luke 7:28 │ ἐν γεννητοῖς γυναικῶν │ among [those] born of women │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ Luke 10:3 │ ἐν μέσῳ λύκων │ in [the] midst of wolves │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ Luke 10:3 │ ἐν μέσῳ λύκων │ in [the] midst of wolves │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ Luke 17:11 │ διὰ μέσον Σαμαρίας │ through [the] midst of Samaria │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ I_Corinthians 2:13 │ ἐν διδακτοῖς Πνεύματος │ in [those] taught of [the] Spirit │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ I_Corinthians 5:8 │ ἐν ἀζύμοις εἰλικρινίας │ with unleavened [bread] of sincerity │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ I_Corinthians 16:2 │ κατὰ μίαν σαββάτου │ Every first of the week │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ Hebrews 2:12 │ ἐν μέσῳ ἐκκλησίας │ in [the] midst of [the] congregation │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ Hebrews 2:12 │ ἐν μέσῳ ἐκκλησίας │ in [the] midst of [the] congregation │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ I_Peter 3:22 │ ἐν δεξιᾷ Θεοῦ │ at [the] right hand of God │\n",
"├────────────────────┼────────────────────────┼────────────────────────────────────────┤\n",
"│ I_Peter 3:22 │ ἐν δεξιᾷ Θεοῦ │ at [the] right hand of God │\n",
"╘════════════════════╧════════════════════════╧════════════════════════════════════════╛\n"
]
}
],
"source": [
"# Library to format table\n",
"from tabulate import tabulate\n",
"\n",
"# The result is a list of tuples with node ids\n",
"# Gather the results\n",
"Results=[]\n",
"for tuple in MismatchesList:\n",
" greek=F.word.v(tuple[1])+' '+F.word.v(tuple[2])+' '+F.word.v(tuple[3])\n",
" gloss=F.gloss.v(tuple[1])+' '+F.gloss.v(tuple[2])+' '+F.gloss.v(tuple[3])\n",
" # Following line creates a nicely formated presentation of the verse\n",
" location=\"{} {}:{}\".format(F.book.v(tuple[1]),F.chapter.v(tuple[1]),F.verse.v(tuple[1]))\n",
" result=(location,greek,gloss)\n",
" Results.append(result)\n",
" \n",
"# Produce the table\n",
"headers = [\"location\",\"Greek\",\"Gloss\"]\n",
"print(tabulate(Results, headers=headers, tablefmt='fancy_grid'))"
]
},
{
"cell_type": "markdown",
"id": "666e97f9-4237-491b-b004-444e266ba44b",
"metadata": {},
"source": [
"## 3.2 - Some note on returned datastructure \n",
"##### [Back to TOC](#TOC)\n",
"\n",
"Note that the format of the returned list. The tuples in the mismatch list consist of tuples with 'wg, word, word and word. This matches the node elements included in the initial query:\n",
"```\n",
"phrase\n",
" a:word sp=prep\n",
" <: b:word sp=adj\n",
" <: c:word sp=noun \n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "b6a03000-57eb-44cf-bac0-a83e4e896a02",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"wg\n",
"word\n",
"word\n",
"word\n"
]
}
],
"source": [
"for tuple in MismatchesList:\n",
" for index in range(4): print (F.otype.v(tuple[index]))\n",
" # only print the first tuple\n",
" break;"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "b81bad7c-5555-4793-94b8-7f7ea845e8af",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"verse 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse Matthew 10:16
sentence #312 (start: Matthew 10:16)
wg #4243: cl
wg #4244: cl* adv sub-CL
wg #4245: cl VerbElided O-ADV
sentence #313 (start: Matthew 10:16)
wg #4249: cl* Conj-CL
wg #4250: cl* CLaCL
wg #4251: cl
wg #4252: cl* adv sub-CL
wg #4253: cl VerbElided S2CL
wg #4255: group
wg #4256: cl
wg #4257: cl* adv sub-CL
wg #4258: cl VerbElided S2CL
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse 2"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse Matthew 11:11
sentence #361 (start: Matthew 11:11)
wg #4763: group ClCl
wg #4766: cl* CLaCL
wg #4767: cl ADV-V-ADV-S
wg #4770: adjp s AdjpAdvp
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse 3"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse Matthew 28:1
sentence #1111 (start: Matthew 28:1)
wg #14846: cl* Conj-CL
wg #14847: cl ADV-ADV-V-S-ADV
wg #14847: cl ADV-ADV-V-S-ADV
wg #14853: s NpaNp
wg #14854: apposition np Np-Appos
wg #14855: np DetNP apposition
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse 4"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse Luke 7:28
sentence #301 (start: Luke 7:28)
wg #4644: cl
wg #4645: cl o P-ADV-ADV-S-VC
sentence #302 (start: Luke 7:28)
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse 5"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse Luke 10:3
sentence #469 (start: Luke 10:3)
wg #6878: ClCl
wg #6880: cl
wg #6881: cl* adv sub-CL
wg #6882: cl VerbElided O-ADV
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse 6"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse Luke 17:11
sentence #786 (start: Luke 17:11)
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse 7"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse I_Corinthians 2:13
sentence #35 (start: I_Corinthians 2:12)
wg #581: cl* Conj-CL
wg #582: cl
wg #593: cl* sub-CL
wg #594: cl V-O
wg #595: apposition np o NP-CL
wg #600: cl O-ADV-V-ADV-ADV apposition
wg #601: group adv notPPbutPP
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse 8"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse I_Corinthians 5:8
sentence #104 (start: I_Corinthians 5:8)
wg #1312: cl* Conj-CL
wg #1313: cl V-ADV
wg #1314: group adv notPPbutPP
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse 9"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse I_Corinthians 16:2
sentence #499 (start: I_Corinthians 16:2)
wg #5381: cl
wg #5386: cl adv V-O
wg #5387: apposition np o NP-CL
wg #5388: cl* PtclCL apposition
wg #5388: cl* PtclCL apposition
wg #5390: cl* adv sub-CL
wg #5391: cl ADV-ADV-ADV-S-V
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse 10"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse Hebrews 2:12
sentence #24 (start: Hebrews 2:11)
wg #357: cl ADV-ADV-V-ADV-ADV
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse 11"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse I_Peter 3:21
sentence #47 (start: I_Peter 3:21)
wg #939: cl ADV-O-ADV-V-S-ADV
wg #941: apposition np s Np-Appos
wg #941: apposition np s Np-Appos
wg #942: apposition np Np-Appos apposition
wg #943: group notNPbutNP apposition
wg #950: pp adv PrepNp
wg #951: np NPofNP
wg #952: apposition np NP-CL
wg #953: apposition np Np-Appos
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse 12"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"verse I_Peter 3:22
sentence #47 (start: I_Peter 3:21)
wg #939: cl ADV-O-ADV-V-S-ADV
wg #950: pp adv PrepNp
wg #951: np NPofNP
wg #952: apposition np NP-CL
wg #954: cl apposition
wg #955: cl adv S-VC-P-ADV
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"N1904.show(MismatchesList)"
]
},
{
"cell_type": "markdown",
"id": "49ccb23c-5513-434c-afae-07feceb54a4d",
"metadata": {},
"source": [
"# 4 - Discussion\n",
"##### [Back to TOC](#TOC)\n",
"\n",
"N.A."
]
},
{
"cell_type": "markdown",
"id": "907431c5-673f-4cb6-87e9-55b3abfa4df1",
"metadata": {},
"source": [
"# 5 - Attribution and footnotes\n",
"##### [Back to TOC](#TOC)\n",
"\n",
"N.A."
]
},
{
"cell_type": "markdown",
"id": "8e733cbc-527e-4fa8-8968-ff9f177fe14c",
"metadata": {
"tags": []
},
"source": [
"# 6 - 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": "042c431f-c695-4227-a2a6-016c7ab3d472",
"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
}