Shami96 commited on
Commit
0d578da
·
verified ·
1 Parent(s): c61706a

Update extract_red_text.py

Browse files
Files changed (1) hide show
  1. extract_red_text.py +6 -6
extract_red_text.py CHANGED
@@ -323,13 +323,13 @@ def extract_red_text(path):
323
  return out
324
 
325
  if __name__=="__main__":
326
- fn = sys.argv[1] if len(sys.argv)>1 else "test.docx"
327
- word_data = extract_red_text(fn)
328
-
329
- # --- STORE TO JSON for later reuse ---
330
- with open('word_red_data.json', 'w', encoding='utf-8') as f:
 
331
  json.dump(word_data, f, indent=2, ensure_ascii=False)
332
- # ----------------------------------------
333
 
334
  # still print to console for immediate feedback
335
  print(json.dumps(word_data, indent=2, ensure_ascii=False))
 
323
  return out
324
 
325
  if __name__=="__main__":
326
+ import sys, json
327
+ # Usage: python extract_red_text.py input.docx output.json
328
+ input_docx = sys.argv[1]
329
+ output_json = sys.argv[2]
330
+ word_data = extract_red_text(input_docx)
331
+ with open(output_json, 'w', encoding='utf-8') as f:
332
  json.dump(word_data, f, indent=2, ensure_ascii=False)
 
333
 
334
  # still print to console for immediate feedback
335
  print(json.dumps(word_data, indent=2, ensure_ascii=False))