|
|
|
|
|
""" |
|
|
Edit and Clean Audrey's Original Material |
|
|
Preserves her voice while improving clarity |
|
|
""" |
|
|
|
|
|
import re |
|
|
from pathlib import Path |
|
|
from typing import List, Dict |
|
|
import json |
|
|
|
|
|
class AudreyMaterialEditor: |
|
|
"""Edit Audrey's material while preserving her voice""" |
|
|
|
|
|
def __init__(self): |
|
|
self.audrey_material_dir = Path("manuscripts/Shadow_of_Lillya/audrey_original") |
|
|
self.edited_dir = Path("manuscripts/Shadow_of_Lillya/audrey_edited") |
|
|
self.edited_dir.mkdir(parents=True, exist_ok=True) |
|
|
|
|
|
def load_original_material(self) -> str: |
|
|
"""Load Audrey's compiled original material""" |
|
|
original_file = self.audrey_material_dir / "audrey_original_compiled.md" |
|
|
if not original_file.exists(): |
|
|
raise FileNotFoundError(f"Original material not found. Run extract_audrey_material.py first.") |
|
|
|
|
|
with open(original_file, 'r', encoding='utf-8') as f: |
|
|
return f.read() |
|
|
|
|
|
def clean_text(self, text: str, preserve_voice: bool = True) -> str: |
|
|
"""Clean text while preserving voice""" |
|
|
|
|
|
text = re.sub(r'\n\s*\n\s*\n+', '\n\n', text) |
|
|
|
|
|
|
|
|
|
|
|
text = re.sub(r'\s+([,.!?;:])', r'\1', text) |
|
|
text = re.sub(r'([,.!?;:])\s*([A-Z])', r'\1 \2', text) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return text.strip() |
|
|
|
|
|
def identify_editing_needs(self, text: str) -> Dict: |
|
|
"""Identify areas that might need editing for clarity""" |
|
|
issues = { |
|
|
'long_paragraphs': [], |
|
|
'repeated_phrases': [], |
|
|
'unclear_references': [], |
|
|
'incomplete_sentences': [] |
|
|
} |
|
|
|
|
|
paragraphs = text.split('\n\n') |
|
|
for i, para in enumerate(paragraphs): |
|
|
|
|
|
if len(para) > 1000: |
|
|
issues['long_paragraphs'].append({ |
|
|
'paragraph': i, |
|
|
'length': len(para), |
|
|
'preview': para[:100] + '...' |
|
|
}) |
|
|
|
|
|
|
|
|
sentences = re.split(r'[.!?]+', para) |
|
|
for sent in sentences: |
|
|
if sent.strip() and not re.search(r'[.!?]$', sent.strip()): |
|
|
if len(sent.strip()) > 20: |
|
|
issues['incomplete_sentences'].append({ |
|
|
'paragraph': i, |
|
|
'sentence': sent.strip()[:100] |
|
|
}) |
|
|
|
|
|
return issues |
|
|
|
|
|
def create_edited_version(self, original_text: str, edits: List[Dict] = None) -> str: |
|
|
"""Create edited version with clear attribution""" |
|
|
|
|
|
content_start = original_text.find('---', original_text.find('---') + 3) + 3 |
|
|
content = original_text[content_start:].strip() |
|
|
|
|
|
|
|
|
cleaned = self.clean_text(content) |
|
|
|
|
|
|
|
|
edited_version = f"""# The Shadow of Lillya |
|
|
## Original Material by Audrey Berger Welz |
|
|
### Edited for Clarity |
|
|
|
|
|
**Source:** Extracted from Audrey's original draft manuscripts |
|
|
**Editing:** Minor edits for clarity only - voice and style preserved |
|
|
**Date:** {Path(__file__).stat().st_mtime} |
|
|
|
|
|
--- |
|
|
|
|
|
## Editorial Note |
|
|
|
|
|
This version contains only Audrey Berger Welz's original writing, with minimal edits for clarity: |
|
|
- Fixed obvious typos and formatting issues |
|
|
- Normalized spacing and punctuation |
|
|
- Preserved all of Audrey's unique voice, style, and word choices |
|
|
- No content changes or additions |
|
|
|
|
|
Any material beyond this point that is not clearly marked is Audrey's original work. |
|
|
|
|
|
--- |
|
|
|
|
|
{cleaned} |
|
|
""" |
|
|
return edited_version |
|
|
|
|
|
def save_edited_version(self, edited_text: str): |
|
|
"""Save the edited version""" |
|
|
output_file = self.edited_dir / "audrey_edited_clean.md" |
|
|
with open(output_file, 'w', encoding='utf-8') as f: |
|
|
f.write(edited_text) |
|
|
|
|
|
return output_file |
|
|
|
|
|
def main(): |
|
|
print("βοΈ Editing Audrey's Material for Clarity...\n") |
|
|
|
|
|
editor = AudreyMaterialEditor() |
|
|
|
|
|
|
|
|
print("π Loading original material...") |
|
|
original = editor.load_original_material() |
|
|
print(" β Loaded\n") |
|
|
|
|
|
|
|
|
print("π Identifying editing needs...") |
|
|
issues = editor.identify_editing_needs(original) |
|
|
print(f" Found {len(issues['long_paragraphs'])} long paragraphs") |
|
|
print(f" Found {len(issues['incomplete_sentences'])} potentially incomplete sentences\n") |
|
|
|
|
|
|
|
|
print("π Creating edited version...") |
|
|
edited = editor.create_edited_version(original) |
|
|
|
|
|
|
|
|
print("πΎ Saving edited version...") |
|
|
output_file = editor.save_edited_version(edited) |
|
|
|
|
|
print(f"\nβ
Complete!") |
|
|
print(f" π Edited manuscript: {output_file}") |
|
|
print(f"\nβ οΈ Note: This version contains ONLY Audrey's original material, edited minimally for clarity.") |
|
|
|
|
|
if __name__ == '__main__': |
|
|
main() |
|
|
|
|
|
|