#!/usr/bin/env python
# coding: utf-8
# # Appositions (Nestle1904LFT)
# ## Table of content
# * 1 - Introduction
# * 1.1 - Why is this relevant?
# * 1.2 - Translating into Text-Fabric queries
# * 2 - Load Text-Fabric app and data
# * 3 - Performing the queries
# * 3.1 - Identify appositions in Mat. 1:1 for LFT
# * 3.2 - Other interpretation (GBI)
# * 4 - Discussion
# * 5 - Atribution and footnotes
# * 6 - Required libraries
# # 1 - Introduction
# ##### [Back to TOC](#TOC)
#
# Appositions are grammatical constructs where a word or phrase is placed next to another word or phrase to explain or clarify its meaning. Consider the following text from Matthew 1:1:
#
# > Βίβλος γενέσεως Ἰησοῦ Χριστοῦ υἱοῦ Δαυεὶδ υἱοῦ Ἀβραάμ.
#
# In this verse there are two appositions to 'Ἰησοῦ Χριστοῦ': 'υἱοῦ Δαυεὶδ' and 'υἱοῦ Ἀβραάμ'.
#
# ## 1.1 - Why is this relevant?
#
# In the context of the Bible, the proper analysis of appositions contributes to a more accurate understanding of the text, serving various purposes. One such purpose is clarifying ambiguous references. For instance, in Jude 1:9, the apposition 'archangel' explains which 'Michael' the verse refers to. Additionally, appositions provide further details on important characteristics, roles, or relationships. For example, in Mat. 1:1, the significance of the genealogical relation between Jesus, David, and Abraham is emphasized.
# ## 1.2 - Translating it into a Text-Fabric query
#
#
#
# ## 2 - Load app and data
# ##### [Back to TOC](#TOC)
# In[1]:
get_ipython().run_line_magic('load_ext', 'autoreload')
get_ipython().run_line_magic('autoreload', '2')
# In[2]:
# Loading the Text-Fabric code
# Note: it is assumed Text-Fabric is installed in your environment
from tf.fabric import Fabric
from tf.app import use
# In[3]:
# load the N1904 app and data
N1904 = use ("tonyjurg/Nestle1904LFT", version="0.7", hoist=globals())
# In[4]:
# The following will push the Text-Fabric stylesheet to this notebook (to facilitate proper display with notebook viewer)
N1904.dh(N1904.getCss())
# In[5]:
# Set default view in a way to limit noise as much as possible.
N1904.displaySetup(condensed=True, multiFeatures=False,queryFeatures=False)
# # 3 - Performing the queries
# ##### [Back to TOC](#TOC)
# ## 3.1 - Identify appositions in Mat. 1:1 for LFT
#
# The following will select the first verse of Matthew and put it into the list VerseResult.
# In[6]:
# Define the query template
VerseQuery = '''
book book=Matthew
chapter chapter=1
verse verse=1
'''
# The following will create a list containing ordered tuples consisting of node numbers of the items as they appear in the query
VerseResult = N1904.search(VerseQuery)
# First print the text of the verse:
# In[7]:
# The verse node is the third item (hence the '2') of the first tuple (hence the '0')
T.text(VerseResult[0][2])
# Now lets show the synatactical tree for this verse:
# In[8]:
# Print the result
# Note the options "condensed=True, multiFeatures=False,queryFeatures=False" are included below due to the earlier N1904.displaySetup(...)
N1904.show(VerseResult)
# ## 3.2 - Other interpretation (GBI)
# ##### [Back to TOC](#TOC)
# The LFT Text-Fabric data presents 'υἱοῦ Δαυεὶδ' as apposition to 'Ἰησοῦ Χριστοῦ' and 'υἱοῦ Ἀβραάμ' as apposition to 'Ἰησοῦ Χριστοῦ υἱοῦ Δαυεὶδ'. Another choice of apposition can also be argued: both 'υἱοῦ Δαυεὶδ' and 'υἱοῦ Ἀβραάμ' being appositions to 'Ἰησοῦ Χριστοῦ'. This actualy the case in the XML data for the GBI nodes.
#
# See the following simplified XML code of file [`01-matthew.xml`](https://github.com/tonyjurg/Nestle1904GBI/blob/main/resources/sourcedata/apr_6_2023/01-matthew.xml):
# ```
#
#
#
#
#
#
# Βίβλος
#
#
#
# γενέσεως
#
#
#
#
#
# Ἰησοῦ
#
#
# Χριστοῦ
#
#
#
#
# υἱοῦ
#
#
# Δαυεὶδ
#
#
#
# υἱοῦ
#
#
# Ἀβραάμ.
#
#
#
#
#
#
#
#
#
# ```
# The appostion structure can be visualized by the following image:
#
#
#
#
#
# # 4 - Discussion
# ##### [Back to TOC](#TOC)
#
# There is inherent ambiguity in sentences where the text includes a nested apposition. A comparison of how the GBI and LFT treebanks render these structures highlights this issue. It appears that grammatical rules alone cannot decisively determine the 'correct' rendering in such cases.
# # 5 - Footnotes and attribution
# ##### [Back to TOC](#TOC)
#
# None.
# # 6 - Required libraries
# ##### [Back to TOC](#TOC)
#
# The scripts in this notebook require (beside `text-fabric`) the following Python libraries to be installed in the environment:
#
# {none}
#
# You can install any missing library from within Jupyter Notebook using either`pip` or `pip3`.
# In[ ]: