#!/usr/bin/env python
# coding: utf-8
# # Print a specific verse (Nestle1904GBI)
# ## Table of content
# * 1 - Introduction
# * 2 - Load Text-Fabric app and data
# * 3 - Performing the queries
# * 3.1 - Show all object phrases in clauses
# * 3.2 - Selecting individual words of the verse
# * 3.3 - Available output formats
# * 4 - Attribution and footnotes
# * 5 - Required libraries
# # 1 - Introduction
# ##### [Back to TOC](#TOC)
#
# This Jupyter Notebook shows the method of selecting a specific verse from the Greek New Testament corpus for display or further processing.
# # 2 - Load Text-Fabric app and data
# ##### [Back to TOC](#TOC)
# In[2]:
get_ipython().run_line_magic('load_ext', 'autoreload')
get_ipython().run_line_magic('autoreload', '2')
# In[3]:
# 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[4]:
# load the N1904 app and data
N1904 = use ("tonyjurg/Nestle1904GBI", version="0.4", hoist=globals())
# In[5]:
# The following will push the Text-Fabric stylesheet to this notebook (to facilitate proper display with notebook viewer)
N1904.dh(N1904.getCss())
# # 3 - Performing the queries
# ##### [Back to TOC](#TOC)
# ## 3.1 - Show a specific verse
# ##### [Back to TOC](#TOC)
#
# The following example will query for a specific verte (i.e. Matthew 1:8). As expected, the query yealds one result.
# In[6]:
# Define the query template
VerseQuery = '''
book book=Matthew
chapter chapter=1
verse verse=8
'''
# 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)
# Print some of the results
N1904.show(VerseResult, start=1, end=2, condensed=True, extraFeatures={'sp', 'clauserule', 'phrasefunction'}, multiFeatures=False)
# ## 3.2 - Selecting individual words of the verse
# ##### [Back to TOC](#TOC)
# A similar (but still different) result can be obtained by selecting all words from the verse individualy. Since counting each word as separate result, the total figure for results is higher (in this case 15). Also note that the found items (i.e. individual words) are coloured yellow. The argument `"condensed=True"` combines all found items, limiting the display to just one instance of the verse (since all results are from the same verse). Would the argument `"condensed=False"` be suplied, the same verse would be printed 15 times, each time with the next consequent word coloured in yellow.
# In[7]:
# Define the query template
AltVerseQuery = '''
word book=Matthew chapter=1 verse=8
'''
# The following will create a list containing ordered tuples consisting of node numbers of the items as they appear in the query
AltVerseResult = N1904.search(AltVerseQuery)
# Print some of the results
N1904.show(AltVerseResult, start=1, end=15, condensed=True, multiFeatures=False)
# ## 3.3 - Available output formats
# ##### [Back to TOC](#TOC)
#
# To check the available formats to display the text:
# In[8]:
N1904.showFormats()
# The same result (although formatted different, since an ordered tuple is returned) can be obtained by the following call:
# In[9]:
T.formats
# Note that this data originates from file `otext.tf`:
#
# >
# ```
# @config
# ...
# @fmt:text-orig-full={word}{after}
# ...
# ```
#
# # 4 - Attribution and footnotes
# ##### [Back to TOC](#TOC)
#
# N.A.
# # 5 - 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`.