20260731 - first commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
from docx import Document
|
||||
|
||||
|
||||
|
||||
import language_tool_python
|
||||
import os, sys
|
||||
|
||||
import pdb
|
||||
|
||||
fishero = "c:\\DATOS\\DOCS\\!NOM\\SPANISH\\1_MITROKHIN\\El archivo Mitrokhin - El KGB en Europa y Occidente - Christopher Andrew, Vasili Mitrokhin Z-Library-mono.docx"
|
||||
|
||||
checker_tool = language_tool_python.LanguageTool('es')
|
||||
|
||||
f = open(fishero, 'rb')
|
||||
document = Document(f)
|
||||
|
||||
offset = 0
|
||||
|
||||
nroPara = 1
|
||||
nroParas = len(document.paragraphs)
|
||||
for para in document.paragraphs:
|
||||
start = offset
|
||||
end = start + len(para.text)
|
||||
if para.style.name == "Heading 1":
|
||||
print(f"{para.text.replace(chr(9), " "):80s} => Rango = {start} to {end}")
|
||||
else:
|
||||
text = para.text
|
||||
matches = checker_tool.check(text)
|
||||
nroMatch = 1
|
||||
for match in matches:
|
||||
print(f"Rule[{nroMatch}]: {match.rule_id}")
|
||||
print(f"Message: {match.message}")
|
||||
print(f"Error: '{text[match.offset:match.offset+match.error_length]}'")
|
||||
print("Suggestions:", match.replacements)
|
||||
print("Context: ", match.context)
|
||||
print()
|
||||
nroMatch += 1
|
||||
#if nroMatch > 3:
|
||||
# break
|
||||
print(f"=[{nroPara:5d}/{nroParas:5d}]========================================")
|
||||
offset = end + 1
|
||||
nroPara += 1
|
||||
|
||||
#pdb.set_trace()
|
||||
f.close()
|
||||
|
||||
Reference in New Issue
Block a user