Spaces:
Sleeping
Sleeping
| 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}") | |