This Jupyter Notebook demonstrates how to display the syntax tree for a specific verse. We will begins by explaining how you can use Text-Fabric to select a particular verse from the Greek New Testament. Additionally, it utilizes the A.viewType() function to showcase the differences between the two types of syntax tree presentations included in the dataset.
%load_ext autoreload
%autoreload 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
# load the N1904 app and data
N1904 = use ("CenterBLC/N1904", version="1.0.0", hoist=globals())
Locating corpus resources ...
Name | # of nodes | # slots / node | % coverage |
---|---|---|---|
book | 27 | 5102.93 | 100 |
chapter | 260 | 529.92 | 100 |
verse | 7944 | 17.34 | 100 |
sentence | 8011 | 17.20 | 100 |
group | 8945 | 7.01 | 46 |
clause | 42506 | 8.36 | 258 |
wg | 106868 | 6.88 | 533 |
phrase | 69007 | 1.90 | 95 |
subphrase | 116178 | 1.60 | 135 |
word | 137779 | 1.00 | 100 |
3
CenterBLC/N1904
C:/Users/tonyj/text-fabric-data/github/CenterBLC/N1904/app
gdb630837ae89b9468c9e50d13bda05cfd3de4f18
''
[]
none
unknown
NA
:
text-orig-full
https://github.com/CenterBLC/N1904/tree/main/docs
about
https://github.com/CenterBLC/N1904
https://github.com/CenterBLC/N1904/blob/main/docs/features/<feature>.md
README
text-orig-full
}True
local
C:/Users/tonyj/text-fabric-data/github/CenterBLC/N1904/_temp
main
Nestle 1904 Greek New Testament
10.5281/zenodo.13117910
[]
CenterBLC
/tf
N1904
N1904
1.0.0
https://learner.bible/text/show_text/nestle1904/
Show this on the website
en
https://learner.bible/text/show_text/nestle1904/<1>/<2>/<3>
{webBase}/word?version={version}&id=<lid>
1.0.0
True
{typ} {function} {rela} \\ {cls} {role} {junction}
''
{typ} {function} {rela} \\ {typems} {role} {rule}
''
True
{typ} {function} {rela} \\ {typems} {role} {rule}
''
{typ} {function} {rela} \\ {role} {rule}
''
{typ} {function} {rela} \\ {typems} {role} {rule}
''
True
{book} {chapter}:{verse}
''
True
{typems} {role} {rule} {junction}
''
lemma
sp
gloss
]grc
Display is setup for viewtype syntax-view
See here for more information on viewtypes
# The following will push the Text-Fabric stylesheet to this notebook (to facilitate proper display with notebook viewer)
N1904.dh(N1904.getCss())
The following example demonstrates a query for a specific verse (Mark 1:1). As expected, the query returns a single result.
# Define the query template
VerseQuery = '''
book book=Mark
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)
0.01s 1 result
The result stored in object VerseResult
is a list of tuples. In this example, the list contains only one tuple. Each tuple corresponds to the nodes retrieved based on the query template, with the number of nodes in the tuple matching the three specified in the query.
You can inspect the contents of VerseResult
using the following print statement:
print (VerseResult)
This will display the numeric values for the selected book, chapter, and verse nodes, which are in this example:
[(137781, 137835, 383782)]
Next we will print the syntax tree for the obtained results:
# Print the result
N1904.show(VerseResult,queryFeatures=False)
verse 1
In addition to the straightforward example provided earlier, there are other, more advanced methods for selecting a specific verse in Text-Fabric. In this section two will be briefly described.
Firstly, the code from the previous cells can be combined into a single, compact, and efficient line of code. This approach yields a list of tuples, with each tuple containing only one element (namely a verse
node), which is then used as argument for the A.show()
function:
N1904.show(N1904.search('verse book=Mark chapter=1 verse=1'))
Another method takes advantage of the fact that A.show()
expects a list of tuples. This is achieved by encapsulating the numeric value of the verse
node in a list, using square brackets [ ]
, and making the integer part of a tupe, using parentheses ( , )
. Additionally, the function T.nodeFromSection()
expects a tuple as input, which is created using ('Mark',1,1)
. Combining these steps results in the following construction:
N1904.show([(T.nodeFromSection(('Mark',1,1)), )])
A similar (but still different) result can be obtained by selecting all words from the verse individualy. Since each word is counted as a separate result, the total number of results is higher — in this case, seven. Additionally, note that the found items (i.e., individual words) are highlighted in yellow. Using the argument condensed=True
combines all the found items, limiting the display to a single instance of the verse, as all results come from the same verse. If the argument condensed=False
were supplied, the verse would be displayed seven times, with each instance highlighting the next consecutive word in yellow.
# Define the query template
AltVerseQuery = '''
word book=Mark chapter=1 verse=1
'''
# 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, queryFeatures=False)
0.10s 7 results
verse 1
Text-Fabric's data design enables a very flexible representation of the corpus text (see this section). If no specific format is defined, the default format will be used, which was set during the dataset's creation (for this dataset, the default is text-orig-full
). Additionally, the dataset includes several other formats that are particularly relevant to the Greek New Testament corpus.
To view the available formats for displaying the text in this dataset:
T.formats
{'lex-orig-plain': 'word', 'lex-translit-plain': 'word', 'text-orig-full': 'word', 'text-orig-plain': 'word', 'text-translit-plain': 'word', 'text-unaccent-plain': 'word'}
This list reveals that all defined formats are based on word
nodes. This means that the output for any given format is generated using a specific set of features associated with word
nodes. The exact combination of features used for each text format can be examined by running the following command:
N1904.showFormats()
format | level | template |
---|---|---|
lex-orig-plain |
word | {lemma}{trailer} |
lex-translit-plain |
word | {lemmatranslit}{trailer} |
text-orig-full |
word | {before}{text}{after} |
text-orig-plain |
word | {text}{trailer} |
text-translit-plain |
word | {translit}{trailer} |
text-unaccent-plain |
word | {unaccent}{trailer} |
This data originates from file otext.tf
:
@config
...
@fmt:text-orig-full={before}{text}{after}
...
Using the example verse, we can illustrate how the different formats in this dataset influence the presentation of Mark 1:1. To do this, we iterate over the defined text formats and display the text associated with the verse
node in each format.
# note: node 383782 is of type 'verse' and associated to Mark 1:1
for formats in T.formats:
print(f'fmt={formats}\t: {T.text(383782,formats)}')
fmt=lex-orig-plain : ἀρχή ὁ εὐαγγέλιον Ἰησοῦς Χριστός υἱός θεός. fmt=lex-translit-plain : arkhe o euaggelion Iesous Khristos uios theos. fmt=text-orig-full : Ἀρχὴ τοῦ εὐαγγελίου Ἰησοῦ Χριστοῦ (Υἱοῦ Θεοῦ). fmt=text-orig-plain : Ἀρχὴ τοῦ εὐαγγελίου Ἰησοῦ Χριστοῦ Υἱοῦ Θεοῦ. fmt=text-translit-plain : Arkhe tou euaggeliou Iesou Khristou Uiou Theou. fmt=text-unaccent-plain : Αρχη του ευαγγελιου Ιησου Χριστου Υιου Θεου.