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=10
'''
parashaResults = BHSA.search(parashaQuery)
0.01s 146 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 41:18 | 86% | וְהִנֵּ֣ה מִן־הַיְאֹ֗ר עֹלֹת֙ שֶׁ֣בַע פָּרֹ֔ות בְּרִיאֹ֥ות בָּשָׂ֖ר וִיפֹ֣ת תֹּ֑אַר וַתִּרְעֶ֖ינָה בָּאָֽחוּ׃ |
Reference | Match | Text |
---|---|---|
Genesis 41:20 | 75% | וַתֹּאכַ֨לְנָה֙ הַפָּרֹ֔ות הָרַקֹּ֖ות וְהָרָעֹ֑ות אֵ֣ת שֶׁ֧בַע הַפָּרֹ֛ות הָרִאשֹׁנֹ֖ות הַבְּרִיאֹֽת׃ |
Reference | Match | Text |
---|---|---|
Genesis 41:22 | 84% | וָאֵ֖רֶא בַּחֲלֹמִ֑י וְהִנֵּ֣ה׀ שֶׁ֣בַע שִׁבֳּלִ֗ים עֹלֹ֛ת בְּקָנֶ֥ה אֶחָ֖ד מְלֵאֹ֥ת וְטֹבֹֽות׃ |
Reference | Match | Text |
---|---|---|
Genesis 41:23 | 92% | וְהִנֵּה֙ שֶׁ֣בַע שִׁבֳּלִ֔ים צְנֻמֹ֥ות דַּקֹּ֖ות שְׁדֻפֹ֣ות קָדִ֑ים צֹמְחֹ֖ות אַחֲרֵיהֶֽם׃ |
Reference | Match | Text |
---|---|---|
Genesis 41:24 | 79% | וַתִּבְלַ֨עְןָ֙ הָשִׁבֳּלִ֣ים הַדַּקֹּ֔ת אֵ֛ת שֶׁ֥בַע הַֽשִׁבֳּלִ֖ים הַטֹּבֹ֑ות וָֽאֹמַר֙ אֶל־הַֽחַרְטֻמִּ֔ים וְאֵ֥ין מַגִּ֖יד לִֽי׃ |
Reference | Match | Text |
---|---|---|
Genesis 41:2 | 86% | וְהִנֵּ֣ה מִן־הַיְאֹ֗ר עֹלֹת֙ שֶׁ֣בַע פָּרֹ֔ות יְפֹ֥ות מַרְאֶ֖ה וּבְרִיאֹ֣ת בָּשָׂ֑ר וַתִּרְעֶ֖ינָה בָּאָֽחוּ׃ |
Reference | Match | Text |
---|---|---|
Genesis 41:4 | 75% | וַתֹּאכַ֣לְנָה הַפָּרֹ֗ות רָעֹ֤ות הַמַּרְאֶה֙ וְדַקֹּ֣ת הַבָּשָׂ֔ר אֵ֚ת שֶׁ֣בַע הַפָּרֹ֔ות יְפֹ֥ת הַמַּרְאֶ֖ה וְהַבְּרִיאֹ֑ת וַיִּיקַ֖ץ פַּרְעֹֽה׃ |
Reference | Match | Text |
---|---|---|
Genesis 41:5 | 84% | וַיִּישָׁ֕ן וַֽיַּחֲלֹ֖ם שֵׁנִ֑ית וְהִנֵּ֣ה׀ שֶׁ֣בַע שִׁבֳּלִ֗ים עֹלֹ֛ות בְּקָנֶ֥ה אֶחָ֖ד בְּרִיאֹ֥ות וְטֹבֹֽות׃ |
Reference | Match | Text |
---|---|---|
Genesis 41:6 | 92% | וְהִנֵּה֙ שֶׁ֣בַע שִׁבֳּלִ֔ים דַּקֹּ֖ות וּשְׁדוּפֹ֣ת קָדִ֑ים צֹמְחֹ֖ות אַחֲרֵיהֶֽן׃ |
Reference | Match | Text |
---|---|---|
Genesis 41:7 | 79% | וַתִּבְלַ֨עְנָה֙ הַשִּׁבֳּלִ֣ים הַדַּקֹּ֔ות אֵ֚ת שֶׁ֣בַע הַֽשִּׁבֳּלִ֔ים הַבְּרִיאֹ֖ות וְהַמְּלֵאֹ֑ות וַיִּיקַ֥ץ פַּרְעֹ֖ה וְהִנֵּ֥ה חֲלֹֽום׃ |
Reference | Match | Text |
---|---|---|
Genesis 42:32 | 78% | שְׁנֵים־עָשָׂ֥ר אֲנַ֛חְנוּ אַחִ֖ים בְּנֵ֣י אָבִ֑ינוּ הָאֶחָ֣ד אֵינֶ֔נּוּ וְהַקָּטֹ֥ן הַיֹּ֛ום אֶת־אָבִ֖ינוּ בְּאֶ֥רֶץ כְּנָֽעַן׃ |
Reference | Match | Text |
---|---|---|
Genesis 42:13 | 78% | וַיֹּאמְר֗וּ שְׁנֵ֣ים עָשָׂר֩ עֲבָדֶ֨יךָ אַחִ֧ים׀ אֲנַ֛חְנוּ בְּנֵ֥י אִישׁ־אֶחָ֖ד בְּאֶ֣רֶץ כְּנָ֑עַן וְהִנֵּ֨ה הַקָּטֹ֤ן אֶת־אָבִ֨ינוּ֙ הַיֹּ֔ום וְהָאֶחָ֖ד אֵינֶֽנּוּ׃ |
Reference | Match | Text |
---|---|---|
Genesis 43:5 | 76% | וְאִם־אֵינְךָ֥ מְשַׁלֵּ֖חַ לֹ֣א נֵרֵ֑ד כִּֽי־הָאִ֞ישׁ אָמַ֤ר אֵלֵ֨ינוּ֙ לֹֽא־תִרְא֣וּ פָנַ֔י בִּלְתִּ֖י אֲחִיכֶ֥ם אִתְּכֶֽם׃ |
Reference | Match | Text |
---|---|---|
Genesis 43:3 | 76% | וַיֹּ֧אמֶר אֵלָ֛יו יְהוּדָ֖ה לֵאמֹ֑ר הָעֵ֣ד הֵעִד֩ בָּ֨נוּ הָאִ֤ישׁ לֵאמֹר֙ לֹֽא־תִרְא֣וּ פָנַ֔י בִּלְתִּ֖י אֲחִיכֶ֥ם אִתְּכֶֽם׃ |
Genesis 44:26 | 75% | וַנֹּ֕אמֶר לֹ֥א נוּכַ֖ל לָרֶ֑דֶת אִם־יֵשׁ֩ אָחִ֨ינוּ הַקָּטֹ֤ן אִתָּ֨נוּ֙ וְיָרַ֔דְנוּ כִּי־לֹ֣א נוּכַ֗ל לִרְאֹות֙ פְּנֵ֣י הָאִ֔ישׁ וְאָחִ֥ינוּ הַקָּטֹ֖ן אֵינֶ֥נּוּ אִתָּֽנוּ׃ |
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.