无损检测期末复习笔记:十天章节笔记、考点精编、三套模拟卷(带Obsidian双链)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import json
|
||||
|
||||
json_path = r'D:\mineru_home\doclib\parsed\d9\d991db7dc971c6655661492bb28129f2089d03222b439064e30b7156ff1ba848\flash\1-10_1794301361022.json'
|
||||
|
||||
with open(json_path, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
def extract_text(content_list, depth=0):
|
||||
"""Recursively extract text from content structure"""
|
||||
result = []
|
||||
for item in content_list:
|
||||
if isinstance(item, dict):
|
||||
if item.get('type') == 'text' and 'content' in item:
|
||||
text = item['content']
|
||||
if isinstance(text, str):
|
||||
result.append(text)
|
||||
elif 'content' in item:
|
||||
result.extend(extract_text(item['content'], depth+1))
|
||||
return result
|
||||
|
||||
# Check page 2
|
||||
page2 = data['pages'][1]
|
||||
print(f"=== Page 2 ===")
|
||||
for i, block in enumerate(page2['blocks']):
|
||||
btype = block.get('type', '?')
|
||||
texts = extract_text(block.get('content', []))
|
||||
full_text = ' '.join(texts)
|
||||
if len(full_text) > 300:
|
||||
full_text = full_text[:300] + '...'
|
||||
print(f"[{btype}] {full_text}")
|
||||
print()
|
||||
|
||||
# Also check page 3
|
||||
page3 = data['pages'][2]
|
||||
print(f"=== Page 3 ===")
|
||||
for i, block in enumerate(page3['blocks']):
|
||||
btype = block.get('type', '?')
|
||||
texts = extract_text(block.get('content', []))
|
||||
full_text = ' '.join(texts)
|
||||
if len(full_text) > 300:
|
||||
full_text = full_text[:300] + '...'
|
||||
print(f"[{btype}] {full_text}")
|
||||
print()
|
||||
Reference in New Issue
Block a user