feat: Release v0.10 - Modular Architecture & External Config
- Refactor codebase into src/ (preprocessing, translation, assembly) - Add pipeline/ scripts for individual stages - Externalize configuration to config/config.yaml - Fix Cover Image preservation - Update documentation and manuals
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import re
|
||||
from src.format_extractor import FormatExtractor
|
||||
|
||||
extractor = FormatExtractor()
|
||||
|
||||
cases = [
|
||||
("<p>“But what is the goal?” <em>Amodei</em>...</p>", "Quoted text with em"),
|
||||
("<p>Q. What is artificial intelligence?</p>", "Simple Q&A"),
|
||||
("<p>Text <i>italic</i> followed by dots...</p>", "Italic with trailing dots"),
|
||||
]
|
||||
|
||||
for html, desc in cases:
|
||||
print(f"--- Testing: {desc} ---")
|
||||
|
||||
# Simulate how extract() identifies inner_html
|
||||
from bs4 import BeautifulSoup, Tag
|
||||
soup = BeautifulSoup(html, 'html.parser')
|
||||
root = list(soup.children)[0] if list(soup.children) else soup
|
||||
clean_text = root.get_text().strip()
|
||||
clean_text = re.sub(r'\s+', ' ', clean_text).strip()
|
||||
inner_html = root.decode_contents() if isinstance(root, Tag) else str(root)
|
||||
|
||||
# Call v3 directly
|
||||
text_with_ph, local_map = extractor._smart_extract_v3(inner_html)
|
||||
|
||||
stripped_text = re.sub(r'φ/?[0-9]+φ', '', text_with_ph)
|
||||
stripped_text = re.sub(r'\s+', ' ', stripped_text).strip()
|
||||
|
||||
print(f"Clean: '{clean_text}'")
|
||||
print(f"Stripped: '{stripped_text}'")
|
||||
print(f"Text ph: '{text_with_ph}'")
|
||||
print(f"Map: {local_map}")
|
||||
|
||||
if clean_text == stripped_text:
|
||||
print("✅ SUCCESS")
|
||||
else:
|
||||
print("❌ FAILED")
|
||||
print()
|
||||
Reference in New Issue
Block a user