Skip to content

Instantly share code, notes, and snippets.

@tonyjurg
tonyjurg / Transcoding between beta- and uni-code
Last active April 29, 2025 09:38
Transcoding between beta- and uni-code presenatations of Greek text
Transcoding between beta- and uni-code you can easily be done in the following manner:
```python
import beta_code
beta_code.greek_to_beta_code(u'χαῖρε ὦ κόσμε')
'xai=re w)= ko/sme'
beta_code.beta_code_to_greek('xai=re w)= ko/sme')
'χαῖρε ὦ κόσμε'
@tonyjurg
tonyjurg / loading BHSaddons features
Last active April 27, 2025 20:37
Use Text_Fabric features from BHSaddons to manage parshots.
# Loading the Text-Fabric code
from tf.fabric import Fabric
from tf.app import use
# load the app and data and the BHSaddons features
BHSA = use ("etcbc/BHSA", mod="tonyjurg/BHSaddons/tf/", hoist=globals())
# find all verse nodes for this parasha using its sequence number
parashaQuery = '''
verse parashanum=1
@tonyjurg
tonyjurg / TF_feature_value_overview
Created April 14, 2025 16:44
Snippet of Python code to create a simple overview of Text-Fabric feature data
FeatureList=Fall()
LinesToPrint=5
for Feature in FeatureList:
if Feature!='otype':
print ('Feature:',Feature,'\n\n\t value\t frequency')
FeatureFrequenceLists=Fs(Feature).freqList()
PrintedLine=0
for item, freq in FeatureFrequenceLists:
PrintedLine+=1
print ('\t',item,'\t',freq)
@tonyjurg
tonyjurg / recursive-traversing.py
Last active January 27, 2025 16:58
Recursive traversing in Text-Fabric
# This code traverses the hierarchical structure of a Text-Fabric corpus,
# starting from books and drilling down through chapters, verses, and words.
# At each level, it allows for processing or extracting specific data
# related to the respective nodes (book, chapter, verse, or word).
# Loop through all the book nodes in the corpus
for bookNode in F.otype.s('book'):
# Do something on the book nodes data
# Loop through all the chapter nodes in the book
@tonyjurg
tonyjurg / louwNidaTopLevelMapping.py
Created November 14, 2024 12:31
Creating a dictionary to map Louw-Nida top-level domains to descriptions
# The Greek words in the New Testament are classified semantically according to a two-tier system developed by Louw and Nida.
# This Python script maps the top-level codes (the part of the Louw-Nida code preceding the dot) to their human-readable descriptions.
# The structure of the dictionary is:
# louwNidaMapping = {
# numeric (key): "description"
# ...
# }
# The information for this dictionary is obtained from parsing the Louw-Nida Lexicon information available at laparola.net.
# The original publication is by Johannes P. Louw and Eugene Albert Nida, titled:
# Greek-English Lexicon of the New Testament: Based on Semantic Domains (New York: United Bible Societies, 1996).
@tonyjurg
tonyjurg / shebanqRest.py
Last active November 26, 2024 12:37
Python functions for interfacing with the SHEBANQ REST API
# SHEBANQ REST API - https://github.com/ETCBC/shebanq/wiki/REST-Api
# https://github.com/ETCBC/shebanq/wiki/REST-Api#deep-linking-to-shebanq
# Define the transliteration substitution function
def substituteTranslit(translit):
substitutions = {
'>': 'A', # aleph
'<': 'O', # ayin
'/': 'n', # nun
'[': 'v', # vav