HanspellChecker.py
def correct_and_save(self, filename):
        """
        correct sentences line by line in the file, and save it in a new file(.txt).
        """
        try:
            with open(filename, "r", encoding="utf-8") as f:
                text_list = f.read().split('\n')

        except FileNotFoundError as e:
            print(e)
            return -1
        
        corrected = self.correct(text_list)

        new_filename = os.path.splitext(os.path.basename(filename))[0] + "_corrected.txt"
        with open(new_filename, "w", encoding="utf-8") as f:
            f.write("\n".join(corrected))

        correct sentences line by line in the file, and save it in a new file(.txt).
        
correct sentences line by line in the file, and save it in a new file(.txt).
correct sentences line by line in the file and save it in a new file ( . txt ) .
def correct_and_save(self, filename):
        try:
            with open(filename, "r", encoding="utf-8") as f:
                text_list = f.read().split('\n')
        except FileNotFoundError as e:
            print(e)
            return -1
        corrected = self.correct(text_list)
        new_filename = os.path.splitext(os.path.basename(filename))[0] + "_corrected.txt"
        with open(new_filename, "w", encoding="utf-8") as f:
            f.write("\n".join(corrected))
def correct_and_save ( self , filename ) : try : with open ( filename , "r" , encoding = "utf-8" ) as f : text_list = f . read ( ) . split ( '\n' ) except FileNotFoundError as e : print ( e ) return - 1 corrected = self . correct ( text_list ) new_filename = os . path . splitext ( os . path . basename ( filename ) ) [ 0 ] + "_corrected.txt" with open ( new_filename , "w" , encoding = "utf-8" ) as f : f . write ( "\n" . join ( corrected ) )
correct sentences line by line in the file, and save it in a new file(.txt).
correct sentences line by line in the file and save it in a new file ( . txt ) .
"""
        correct sentences line by line in the file, and save it in a new file(.txt).
        """
self
filename