#!/usr/bin/env python # coding: utf-8 # # Incongruenct adverb and noun (Nestle1904LFT) # # # **Work in progress!** # ## 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 - Presenting incongruent cases # * 3.2 - Some note on returned datastructure # * 4 - Discussion # * 5 - Atribution and footnotes # * 6 - Required libraries # # 1 - Introduction # ##### [Back to TOC](#TOC) # # In Greek grammar, congruence refers to the agreement or matching of certain grammatical features, such as gender, number, and case, between different parts of a sentence. Specifically, when discussing congruence between an adverb and a noun, it typically refers to the agreement between the adverb and the noun in terms of gender, number, and case. When an adverb is used in conjunction with a noun, they normaly should be congruent, however, there are cases in the Greek New Testament where this is not the case. # ## 1.1 - Why is this relevant? # ##### [Back to TOC](#TOC) # # From a theological perspective, these mismatches are relevant and warrant investigation. It is often suggested that the mismatch may indicate the presence of an elliptical element, which, if included, would resolve the mismatch. However, in certain situations, introducing such an elliptical word could alter the intended meaning. Therefore, careful consideration is required when analyzing these mismatches in theological contexts. # ## 1.2 - Translating into Text-Fabric queries # ##### [Back to TOC](#TOC) # # To perform this query, we will utilize the search template feature of Text-Fabric. This feature enables us to precisely define the levels of incongruency we are interested in examining. By using the search template, we can specify the specific criteria and patterns we want to search for within the data. # # In this example the congruence between preposition, adjective and noun will be examined. # # 2 - Load Text-Fabric 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.6", 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 - Looking for and presenting the incongruent cases # # The level of mismatch to select upon can be adjusted by addapting the following lines: # # ``` # a .gn#gn. b # b .gn#gn. c # a .case#case. b # b .case#case. c # ``` # # The actual query is presented below: # In[21]: # Define the query template MismatchesQuery = ''' wg wgrole=adv a:word sp=prep <: b:word sp=adj <: c:word sp=noun a .gn#gn. b b .gn#gn. c a .case#case. b b .case#case. c ''' MismatchesList = N1904.search(MismatchesQuery) # This will create a list containing ordered tuples consisting of node numbers of the items as they appear in the query # 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. # In[15]: for result in MismatchesList: print (result) break # In[ ]: # idea to filter out duplicates - not working yet unique_tuples = set() for result in MismatchesList: # Process the relevant nodes or features to form a tuple tuple_data = (result[0], result[1], result[2], result[3]) # Add the tuple to the set unique_tuples.add(tuple_data) # In[22]: # Library to format table from tabulate import tabulate # The result is a list of tuples with node ids # Gather the results Results=[] for tuple in MismatchesList: greek=F.word.v(tuple[1])+' '+F.word.v(tuple[2])+' '+F.word.v(tuple[3]) gloss=F.gloss.v(tuple[1])+' '+F.gloss.v(tuple[2])+' '+F.gloss.v(tuple[3]) # Following line creates a nicely formated presentation of the verse location="{} {}:{}".format(F.book.v(tuple[1]),F.chapter.v(tuple[1]),F.verse.v(tuple[1])) result=(location,greek,gloss) Results.append(result) # Produce the table headers = ["location","Greek","Gloss"] print(tabulate(Results, headers=headers, tablefmt='fancy_grid')) # ## 3.2 - Some note on returned datastructure # ##### [Back to TOC](#TOC) # # 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: # ``` # phrase # a:word sp=prep # <: b:word sp=adj # <: c:word sp=noun # ``` # In[12]: for tuple in MismatchesList: for index in range(4): print (F.otype.v(tuple[index])) # only print the first tuple break; # In[23]: N1904.show(MismatchesList) # # 4 - Discussion # ##### [Back to TOC](#TOC) # # N.A. # # 5 - Attribution and footnotes # ##### [Back to TOC](#TOC) # # N.A. # # 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[ ]: