#!/usr/bin/env python # coding: utf-8 # # Lexical parallels in parasha #11 Vayigash (Genesis 44:18-47:27) # ## Table of Content (ToC) # # * 1 - Introduction # * 2 - Load Text-Fabric app and data # * 3 - Performing the queries # * 3.1 - Locate the parallels # * 4 - Required libraries # * 5 - Further reading # * 6 - Notebook version details # # 1 - Introduction # ##### [Back to ToC](#TOC) # # In this notebook we search for lexical parallels between verses in this parasha with other verses in the Tenach. # # 2 - Load Text-Fabric app and data # ##### [Back to ToC](#TOC) # # The following code will load the Text-Fabric version of the [Biblia Hebraica Stuttgartensia (Amstelodamensis)](https://etcbc.github.io/bhsa/). # In[1]: get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') # In[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 # In[3]: # load the app and data BHSA = use ("etcbc/BHSA", mod="tonyjurg/BHSaddons/tf/", hoist=globals()) # # 3 - Performing the queries # ##### [Back to ToC](#TOC) # # The main engine of our queries is the use of Text-Fabric feature `crossref`, part of `Parallel Passages` module. See also [this notebook](https://nbviewer.org/github/etcbc/parallels/blob/master/programs/parallels.ipynb) explaing the concepts and how this feature was created. # ## 3.1 - Locate the parallels # In[4]: # find all verse nodes for this parasha using its sequence number parashaQuery = ''' verse parashanum=11 ''' parashaResults = BHSA.search(parashaQuery) # In[5]: # 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='
' htmlFooter=f'Data generated by `hapax.ipynb` at `github.com/tonyjurg/Parashot`
' # In[6]: 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"{comparisonText[j1:j2]}" 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"" f"{verseSection[0]} {verseSection[1]}:{verseSection[2]}" ) # Right-align the main verse text tableContent += f"Reference | Match | Text |
---|---|---|
{targetStepBible} | {confidence}% | {highlightedText} |
Author | #Tony Jurg | #
Version | #1.1 | #
Date | #18 November 2024 | #