HanspellChecker.py
def correct(self, text):
        """
        This function checks the spelling and grammer of korean text,
        and corrects it.
        """
        if isinstance(text, list):
            result = []
            for idx, item in enumerate(text):
                corrected = self.correct(item)
                result.append(corrected)
                print("[-] {}/{} complete".format(idx+1, len(text)))
            return result

        # Max length of text is 500
        if len(text) > 500:
            return text

        # Remove emoji
        text = self.remove_emoji(text)

        params = {"q": text, "color_blindness": 0}
        # Get response
        success = False
        try_cnt = 0
        while success == False:
            try:
                r = self._agent.get(self.base_url, params=params)
                try_cnt += 1
                res_code = r.status_code
                if res_code != 200:  # response 200 means 'The request has succeeded'
                    if try_cnt >= 3:
                        return text
                    raise HTTPError
            except HTTPError:
                print(
                    "[!] An error occurred while sending the request. error code: {}".format(
                        res_code
                    )
                )
                print("[-] Waiting 5 seconds before resending the request...")
                time.sleep(5)
            else:
                success = True

        r = r.text  # change bytestring to string
        data = json.loads(r)
        html = data["message"]["result"]["html"]

        # Remove html tag in the response
        result = self.remove_tag(html)

        return result

        This function checks the spelling and grammer of korean text,
        and corrects it.
        
This function checks the spelling and grammer of korean text,
and corrects it.
This function checks the spelling and grammer of korean text and corrects it .
def correct(self, text):
        if isinstance(text, list):
            result = []
            for idx, item in enumerate(text):
                corrected = self.correct(item)
                result.append(corrected)
                print("[-] {}/{} complete".format(idx+1, len(text)))
            return result
        if len(text) > 500:
            return text
        text = self.remove_emoji(text)
        params = {"q": text, "color_blindness": 0}
        success = False
        try_cnt = 0
        while success == False:
            try:
                r = self._agent.get(self.base_url, params=params)
                try_cnt += 1
                res_code = r.status_code
                if res_code != 200:  
                    if try_cnt >= 3:
                        return text
                    raise HTTPError
            except HTTPError:
                print(
                    "[!] An error occurred while sending the request. error code: {}".format(
                        res_code
                    )
                )
                print("[-] Waiting 5 seconds before resending the request...")
                time.sleep(5)
            else:
                success = True
        r = r.text  
        data = json.loads(r)
        html = data["message"]["result"]["html"]
        result = self.remove_tag(html)
        return result
def correct ( self , text ) : if isinstance ( text , list ) : result = [ ] for idx , item in enumerate ( text ) : corrected = self . correct ( item ) result . append ( corrected ) print ( "[-] {}/{} complete" . format ( idx + 1 , len ( text ) ) ) return result if len ( text ) > 500 : return text text = self . remove_emoji ( text ) params = { "q" : text , "color_blindness" : 0 } success = False try_cnt = 0 while success == False : try : r = self . _agent . get ( self . base_url , params = params ) try_cnt += 1 res_code = r . status_code if res_code != 200 : if try_cnt >= 3 : return text raise HTTPError except HTTPError : print ( "[!] An error occurred while sending the request. error code: {}" . format ( res_code ) ) print ( "[-] Waiting 5 seconds before resending the request..." ) time . sleep ( 5 ) else : success = True r = r . text data = json . loads ( r ) html = data [ "message" ] [ "result" ] [ "html" ] result = self . remove_tag ( html ) return result
This function checks the spelling and grammer of korean text,
and corrects it.
This function checks the spelling and grammer of korean text and corrects it .
"""
        This function checks the spelling and grammer of korean text,
        and corrects it.
        """ # Max length of text is 500 # Remove emoji # Get response # response 200 means 'The request has succeeded' # change bytestring to string # Remove html tag in the response
self
text