LATE.IO2 / backend /digs_engine /digest_segment.py
AIEONE
Initial commit syncing local server with Hugging Face Space
490ec84
# digest_segment.py
import os
def process_segment(filepath):
try:
with open(filepath, 'r', encoding='utf-8') as file:
data = file.read()
# Simulated 8-path DIGS processing result
result_text = f"[DIGS] File: {os.path.basename(filepath)}\n" \
f"[DIGS] Length: {len(data)} characters\n" \
f"[DIGS] Processed paths: Literal, Conceptual, Terminology, Structure, Data, Comparative, Application, CrossRef\n"
# Save .digested file
digested_path = filepath + ".digested"
with open(digested_path, 'w', encoding='utf-8') as out:
out.write(result_text)
print(f"Segment processed: {filepath}")
# Return structured result for CSV export
return {
"filename": os.path.basename(filepath),
"char_count": len(data),
"processed_paths": "Literal, Conceptual, Terminology, Structure, Data, Comparative, Application, CrossRef"
}
except Exception as e:
print(f"Error processing {filepath}: {e}")
return None