We have a new module, bhsa.py
, that can display every node in a shebanq-like way.
It can also display query results obtained by Text-Fabric search.
This module is part of the BHSA repo, which you need to have to run TF on the Hebrew Bible anyway. So update your repo by git pull origin master
or clone it again.
The new module makes the use of TF a bit easier.
%load_ext autoreload
%autoreload 2
import sys, os
from IPython.display import display, HTML
from tf.fabric import Fabric
from tf.extra.bhsa import Bhsa
Specify locations.
VERSION = '2017'
DATABASE = '~/github/etcbc'
BHSA = f'bhsa/tf/{VERSION}'
PHONO = f'phono/tf/{VERSION}'
Call Text-Fabric in the usual way.
TF = Fabric(locations=[DATABASE], modules=[BHSA, PHONO], silent=False )
This is Text-Fabric 5.3.3 Api reference : https://dans-labs.github.io/text-fabric/Api/General/ Tutorial : https://github.com/Dans-labs/text-fabric/blob/master/docs/tutorial.ipynb Example data : https://github.com/Dans-labs/text-fabric-data 118 features found and 0 ignored
api = TF.load('''
vs vt
''', silent=True)
api.makeAvailableIn(globals())
If you have your notebook in a github repo, you will get the link to its online version, on GitHub and on NBviewer. provided you pass the name of your notebook.
Note that handy documentation links are shown after loading.
B = Bhsa(api, 'display', version=VERSION)
Documentation: BHSA Feature docs BHSA API Text-Fabric API 5.3.3 Search Reference
We pretty-print an arbitrary node.
B.nodeFromDefaultSection('Genesis 1:1')
('', 1414190)
phrase = 651572
B.pretty(phrase)
Where is this phrase on SHEBANQ?
You can click on the word phrase
in the label of the box.
You can generate this link in code as follows:
B.shbLink(phrase)
A link to another passage:
z = T.nodeFromSection(('Ezra', 3, 4))
B.shbLink(z)
Now a couple of verses:
verse1 = T.nodeFromSection(('Genesis', 1, 7))
verse2 = T.nodeFromSection(('Genesis', 1, 17))
The next verse with node numbers.
B.pretty(verse2, withNodes=True)
Now we selectively remove a few features from the display:
B.pretty(verse2, suppress={'gloss', 'typ'})
We run a TF query and show some of its results with a lot of pomp and circumstance. The query is written by Stephen Ku, and he is the one who prompted me to write rich display function for query results.
ellipQuery = '''
sentence
c1:clause
phrase function=Pred
word pdp=verb
c2:clause
phrase function=Pred
c3:clause typ=Ellp
phrase function=Objc
word pdp=subs|nmpr|prps|prde|prin
c1 << c2
c2 << c3
'''
Instead of running S.search()
, we do B.search()
.
results = B.search(ellipQuery)
len(results)
3.00s 1410 results
1410
Here it comes: the B.show()
function asks you for some limits (it will not show more than 100 at a time), and then it displays them.
It lists the results as follows:
B.show(results, start=10, end=14, withNodes=True)
verse 10
verse 11
verse 12
verse 13
verse 14