In this notebook we search for lexical parallels between verses in this parasha with other verses in the Tenach.
The following code will load the Text-Fabric version of the Biblia Hebraica Stuttgartensia (Amstelodamensis).
%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 app and data
BHSA = use ("etcbc/BHSA", mod="tonyjurg/BHSaddons/tf/", hoist=globals())
Locating corpus resources ...
Name | # of nodes | # slots / node | % coverage |
---|---|---|---|
book | 39 | 10938.21 | 100 |
chapter | 929 | 459.19 | 100 |
lex | 9230 | 46.22 | 100 |
verse | 23213 | 18.38 | 100 |
half_verse | 45179 | 9.44 | 100 |
sentence | 63717 | 6.70 | 100 |
sentence_atom | 64514 | 6.61 | 100 |
clause | 88131 | 4.84 | 100 |
clause_atom | 90704 | 4.70 | 100 |
phrase | 253203 | 1.68 | 100 |
phrase_atom | 267532 | 1.59 | 100 |
subphrase | 113850 | 1.42 | 38 |
word | 426590 | 1.00 | 100 |
3
etcbc/BHSA
C:/Users/tonyj/text-fabric-data/github/etcbc/BHSA/app
gd905e3fb6e80d0fa537600337614adc2af157309
''
<code>Genesis 1:1</code> (use <a href="https://github.com/{org}/{repo}/blob/master/tf/{version}/book%40en.tf" target="_blank">English book names</a>)
g_uvf_utf8
g_vbs
kq_hybrid
languageISO
g_nme
lex0
is_root
g_vbs_utf8
g_uvf
dist
root
suffix_person
g_vbe
dist_unit
suffix_number
distributional_parent
kq_hybrid_utf8
crossrefSET
instruction
g_prs
lexeme_count
rank_occ
g_pfm_utf8
freq_occ
crossrefLCS
functional_parent
g_pfm
g_nme_utf8
g_vbe_utf8
kind
g_prs_utf8
suffix_gender
mother_object_type
none
unknown
NA
{docRoot}/{repo}
''
''
https://{org}.github.io
0_home
{}
True
local
C:/Users/tonyj/text-fabric-data/github/etcbc/BHSA/_temp
BHSA = Biblia Hebraica Stuttgartensia Amstelodamensis
10.5281/zenodo.1007624
Phonetic Transcriptions
https://nbviewer.jupyter.org/github/etcbc/phono/blob/master/programs/phono.ipynb
10.5281/zenodo.1007636
etcbc
/tf
phono
Parallel Passages
https://nbviewer.jupyter.org/github/etcbc/parallels/blob/master/programs/parallels.ipynb
10.5281/zenodo.1007642
etcbc
/tf
parallels
etcbc
/tf
BHSA
2021
https://shebanq.ancient-data.org/hebrew
Show this on SHEBANQ
la
True
{webBase}/text?book=<1>&chapter=<2>&verse=<3>&version={version}&mr=m&qw=q&tp=txt_p&tr=hb&wget=v&qget=v&nget=vt
{webBase}/word?version={version}&id=<lid>
v1.8
{typ} {rela}
''
True
{code}
1
''
True
{label}
''
True
gloss
{voc_lex_utf8}
word
orig
{voc_lex_utf8}
{typ} {function}
''
True
{typ} {rela}
1
''
{number}
''
True
{number}
1
''
True
{number}
''
pdp vs vt
lex:gloss
hbo
The main engine of our queries is the use of Text-Fabric feature crossref
, part of Parallel Passages
module. See also this notebook explaing the concepts and how this feature was created.
# find all verse nodes for this parasha using its sequence number
parashaQuery = '''
verse parashanum=11
'''
parashaResults = BHSA.search(parashaQuery)
0.01s 106 results
# Store parashname, start and end verse for future use
startNode=parashaResults[0][0]
endNode=parashaResults[-1][0]
parashaNameHebrew=F.parashahebr.v(startNode)
parashaNameEnglish=F.parashatrans.v(startNode)
bookStart,chapterStart,startVerse=T.sectionFromNode(startNode)
parashaStart=f'{bookStart} {chapterStart}:{startVerse}'
bookEnd,chapterEnd,startEnd=T.sectionFromNode(endNode)
parashaEnd=f'{chapterEnd}:{startEnd}'
htmlStart='<html><body>'
htmlFooter=f'<p>Data generated by `hapax.ipynb` at `<a href=\"https://github.com/tonyjurg/Parashot\" target=\"_blank\">github.com/tonyjurg/Parashot</a>`</p></body></html>'
from difflib import SequenceMatcher
from IPython.display import HTML, display
# Function to find and highlight matching parts between two strings
def highlightMatches(baseText, comparisonText):
matcher = SequenceMatcher(None, baseText, comparisonText)
highlightedComparisonText = ""
for tag, i1, i2, j1, j2 in matcher.get_opcodes():
if tag == "equal": # Identical parts
highlightedComparisonText += f"<mark>{comparisonText[j1:j2]}</mark>"
else: # Non-matching parts
highlightedComparisonText += comparisonText[j1:j2]
return highlightedComparisonText
# Function to process cross-references and format them into an HTML table
def generateCrossReferencesTable(verseNode):
"""
Generates an HTML table with cross-references for a single verse node, highlighting identical parts.
The main verse text will be right-aligned.
"""
# Get cross-references for the specified verseNode
crossRefs = Es("crossref").f(verseNode)
tableContent = ""
# Check if there are any cross-references for this verse
if crossRefs:
verseSection = T.sectionFromNode(verseNode)
mainVerseText = T.text(verseNode)
linkStepBible = (
f"<a href=\"https://www.stepbible.org/?q=version=NASB2020%7Creference={verseSection[0]}.{verseSection[1]}:{verseSection[2]}&options=HNVUG\" target=\"_blank\">"
f"{verseSection[0]} {verseSection[1]}:{verseSection[2]}</a>"
)
# Right-align the main verse text
tableContent += f"<h4>Cross-references for {linkStepBible}</h4>"
tableContent += f"<div style='text-align: right; font-weight: bold;'>{mainVerseText}</div>"
# Create table header
tableContent += f"<table border='1' style='border-collapse: collapse; width: 100%;'><tr><th>Reference</th><th>Match</th><th>Text</th></tr>"
# Process each cross-reference and add a row to the table
for target, confidence in crossRefs:
targetSection = T.sectionFromNode(target)
targetText = T.text(target)
targetStepBible = (
f"<a href=\"https://www.stepbible.org/?q=version=NASB2020%7Creference={targetSection[0]}.{targetSection[1]}:{targetSection[2]}&options=HNVUG\" target=\"_blank\">"
f"{targetSection[0]} {targetSection[1]}:{targetSection[2]}</a>"
)
# Highlight identical parts in target verse
highlightedText = highlightMatches(mainVerseText, targetText)
# Add the row for the cross-reference
tableContent += f"<tr><td>{targetStepBible}</td><td>{confidence}%</td><td>{highlightedText}</td></tr>"
# Close the table
tableContent += "</table><br>"
return tableContent
# Initialize HTML content
htmlContent = f"<h2>Lexical parallels for parasha {parashaNameEnglish} ({parashaStart}-{parashaEnd})</h2>"
# Process each verse and generate cross-reference tables
for verse in parashaResults:
htmlContent += generateCrossReferencesTable(verse[0])
# Save the content to an HTML file
fileName = f"lexical_parallels({parashaNameEnglish.replace(' ','%20')}).html"
with open(fileName, "w", encoding="utf-8") as file:
file.write(htmlContent)
# Display the HTML content in the notebook
display(HTML(htmlContent))
# wrap html header and footer and display a download button
htmlContentFull = f'{htmlStart}{htmlContent}{htmlFooter}'
downloadButton = f"""
<a download="{fileName}" href="data:text/html;charset=utf-8,{htmlContent.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''')}" target="_blank">
<button>Download Lexical Parallels as HTML</button>
</a>
"""
display(HTML(downloadButton))
Reference | Match | Text |
---|---|---|
Genesis 43:5 | 75% | וְאִם־אֵינְךָ֥ מְשַׁלֵּ֖חַ לֹ֣א נֵרֵ֑ד כִּֽי־הָאִ֞ישׁ אָמַ֤ר אֵלֵ֨ינוּ֙ לֹֽא־תִרְא֣וּ פָנַ֔י בִּלְתִּ֖י אֲחִיכֶ֥ם אִתְּכֶֽם׃ |
Reference | Match | Text |
---|---|---|
Exodus 1:1 | 81% | וְאֵ֗לֶּה שְׁמֹות֙ בְּנֵ֣י יִשְׂרָאֵ֔ל הַבָּאִ֖ים מִצְרָ֑יְמָה אֵ֣ת יַעֲקֹ֔ב אִ֥ישׁ וּבֵיתֹ֖ו בָּֽאוּ׃ |
Reference | Match | Text |
---|---|---|
1_Chronicles 5:3 | 80% | בְּנֵ֥י רְאוּבֵ֖ן בְּכֹ֣ור יִשְׂרָאֵ֑ל חֲנֹ֥וךְ וּפַלּ֖וּא חֶצְרֹ֥ון וְכַרְמִֽי׃ |
Reference | Match | Text |
---|---|---|
Exodus 6:15 | 84% | וּבְנֵ֣י שִׁמְעֹ֗ון יְמוּאֵ֨ל וְיָמִ֤ין וְאֹ֨הַד֙ וְיָכִ֣ין וְצֹ֔חַר וְשָׁא֖וּל בֶּן־הַֽכְּנַעֲנִ֑ית אֵ֖לֶּה מִשְׁפְּחֹ֥ת שִׁמְעֹֽון׃ |
Reference | Match | Text |
---|---|---|
Numbers 3:17 | 76% | וַיִּֽהְיוּ־אֵ֥לֶּה בְנֵֽי־לֵוִ֖י בִּשְׁמֹתָ֑ם גֵּרְשֹׁ֕ון וּקְהָ֖ת וּמְרָרִֽי׃ |
1_Chronicles 5:27 | 100% | בְּנֵ֖י לֵוִ֑י גֵּרְשֹׁ֕ון קְהָ֖ת וּמְרָרִֽי׃ |
1_Chronicles 6:1 | 94% | בְּנֵ֖י לֵוִ֑י גֵּרְשֹׁ֕ם קְהָ֖ת וּמְרָרִֽי׃ |
Reference | Match | Text |
---|---|---|
1_Chronicles 7:1 | 86% | וְלִבְנֵ֣י יִשָׂשכָ֗ר תֹּולָ֧ע וּפוּאָ֛ה יָשׁ֥וּב וְשִׁמְרֹ֖ון אַרְבָּעָֽה׃ ס |
Reference | Match | Text |
---|---|---|
1_Chronicles 7:30 | 78% | בְּנֵ֣י אָשֵׁ֗ר יִמְנָ֧ה וְיִשְׁוָ֛ה וְיִשְׁוִ֥י וּבְרִיעָ֖ה וְשֶׂ֥רַח אֲחֹותָֽם׃ |
Reference | Match | Text |
---|---|---|
Genesis 46:25 | 82% | אֵ֚לֶּה בְּנֵ֣י בִלְהָ֔ה אֲשֶׁר־נָתַ֥ן לָבָ֖ן לְרָחֵ֣ל בִּתֹּ֑ו וַתֵּ֧לֶד אֶת־אֵ֛לֶּה לְיַעֲקֹ֖ב כָּל־נֶ֥פֶשׁ שִׁבְעָֽה׃ |
Reference | Match | Text |
---|---|---|
Genesis 35:24 | 80% | בְּנֵ֣י רָחֵ֔ל יֹוסֵ֖ף וּבִנְיָמִֽן׃ |
Reference | Match | Text |
---|---|---|
Ezra 10:38 | 78% | וּבָנִ֥י וּבִנּ֖וּי שִׁמְעִֽי׃ |
Reference | Match | Text |
---|---|---|
1_Chronicles 7:13 | 85% | בְּנֵ֣י נַפְתָּלִ֗י יַחֲצִיאֵ֧ל וְגוּנִ֛י וְיֵ֥צֶר וְשַׁלּ֖וּם בְּנֵ֥י בִלְהָֽה׃ פ |
Reference | Match | Text |
---|---|---|
Genesis 46:18 | 82% | אֵ֚לֶּה בְּנֵ֣י זִלְפָּ֔ה אֲשֶׁר־נָתַ֥ן לָבָ֖ן לְלֵאָ֣ה בִתֹּ֑ו וַתֵּ֤לֶד אֶת־אֵ֨לֶּה֙ לְיַעֲקֹ֔ב שֵׁ֥שׁ עֶשְׂרֵ֖ה נָֽפֶשׁ׃ |
The scripts in this notebook require (beside text-fabric
) the following Python libraries to be installed in the environment:
difflib
You can install any missing library from within Jupyter Notebook using eitherpip
or pip3
.
For an elaborate treatment of parallel passages, see:
Willem Th. van Peursen and Eep Talstra. "Computer-Assisted Analysis of Parallel Texts in the Bible - The Case of 2 Kings xviii-xix and its Parallels in Isaiah and Chronicles" in Vetus Testamentum 57, pp. 45-72. 2007, Brill, Leiden.