#!/usr/bin/env python
# coding: utf-8
# # Missing verses (N1904LFT)
# ## Table of content
# * 1 - Introduction
# * 2 - Load Text-Fabric app and data
# * 3 - Identifying the holes ('missing' verses)
# # 1 - Introduction
# ##### [Back to TOC](#TOC)
#
# When using verse numbers inside a script, it is not save to assume verse number within a chapter are sequential without gaps. The folling script will produce a list of 'missing' verses.
# # 2 - Load Text-Fabric app and data
# ##### [Back to TOC](#TOC)
# 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 N1904 app and data
N1904 = use ("tonyjurg/Nestle1904LFT", version="0.6", hoist=globals())
# # 3 - Identifying the holes ('missing' verses)
# ##### [Back to TOC](#TOC)
# In[33]:
# Initialize variables for tracking the previous verse and node
previousVerse = 1
previousNode = 0 # Start with a dummy value for the previous node
# Iterate over all verse nodes in the dataset
for verseNode in F.otype.s('verse'):
# Retrieve the verse number for the current node
ThisVerse = F.verse.v(verseNode)
# Check if the current verse is different from the previous one
if ThisVerse != previousVerse:
# Check for a gap in verse numbering that is not at the start
if ThisVerse != previousVerse + 1 and ThisVerse != 1:
# Calculate the size of the gap and print details
print(f'Hole of {ThisVerse - previousVerse - 1} verse(s) between {T.sectionFromNode(previousNode)} and {T.sectionFromNode(verseNode)}')
# Update the previous verse and node to the current ones
previousVerse = ThisVerse
previousNode = verseNode
# In[ ]: