Spaces:
Running
Running
Update extract_red_text.py
Browse files- 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 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
|
|
|
| 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))
|