Spaces:
Sleeping
Sleeping
File size: 2,222 Bytes
e8510d3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | import sys
import re
sys.path.append('/run/media/julian/ML2/Python/bos-network/daily-psalms-api')
import bible
import json
import logging
import os
# Set up logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()
# Load text from Matthew
bible_data = bible.process_bible_files(40, 40)
book_id = 40
book_info = bible_data[book_id]
book_title = book_info.get("title", "Unknown")
chapters = book_info.get("text", [])
# Flatten the text
flattened_text = ""
for chapter_idx, chapter in enumerate(chapters, 1):
for verse_idx, verse in enumerate(chapter, 1):
if verse:
flattened_text += verse + " "
# Clean the text
processed_text = flattened_text.lower()
processed_text = re.sub(r'\[.*?\]|\(.*?\)', '', processed_text)
processed_text = re.sub(r'\s+', '', processed_text)
processed_text = bible.strip_diacritics(processed_text)
print(f"Processed text length: {len(processed_text)}")
step = 5642
rounds = [1, -1]
# Test both rounds
for round_num in rounds:
direction = 1 if round_num > 0 else -1
abs_round = abs(round_num)
actual_step = step * abs_round
start_idx = 0 if direction > 0 else len(processed_text) - 1
print(f"\n--- Testing round {round_num} ---")
print(f"Direction: {direction}, Abs round: {abs_round}, Actual step: {actual_step}")
print(f"Start index: {start_idx}")
for i in range(min(abs_round, 10)): # Just try the first few positions
# Skip if starting position is out of bounds
if start_idx + i >= len(processed_text) or start_idx - i < 0:
print(f"Starting position {i} is out of bounds, skipping")
continue
# Get starting position for this round
pos = start_idx + i if direction > 0 else start_idx - i
print(f"\nStarting position {i}, pos = {pos}")
# Extract letters at intervals
result_text = ""
positions = []
while 0 <= pos < len(processed_text) and len(positions) < 15:
result_text += processed_text[pos]
positions.append(pos)
pos += actual_step * direction
print(f"Result: {result_text}")
print(f"Positions: {positions}")
|