import language_tool_python import os, sys tool = language_tool_python.LanguageTool('es') #mierda de perro text = """ Ayer fuimos al playa y comimos mucho pescados. """ if len(sys.argv)>=2: nombre_fichero = sys.argv[1] if os.path.isfile(nombre_fichero): print(f"Leyendo fichero '{nombre_fichero}'") text = "" with open(nombre_fichero, 'r', encoding='ISO-8859-1') as infile: for line in infile: text += line matches = tool.check(text) for match in matches: print(f"Rule: {match.rule_id}") print(f"Message: {match.message}") print(f"Error: '{text[match.offset:match.offset+match.error_length]}'") print("Suggestions:", match.replacements) print()