App/Model.py
def clrtext(self, text):
        # TODO: remove after implement the Topic() class
        """
        clean text from HTML, remove all inconvinient characters such as:
        extra spaces, extra end-of-line, and non utf-8 characters

        Args:
            text (str): text to clean

        Raises:
            exp: raise a generic exception if something goes wrong

        Returns:
            ans(str): clean text
        """
        try:
            # asigning text as ans
            ans = str(text)

            # attempt striping
            ans = ans.strip()

            # fix encoding
            ans = unicodedata.normalize('NFD', ans)
            ans = ans.encode('ascii', 'ignore')
            ans = ans.decode("utf-8")
            ans = str(ans)

            # removing extra spaces
            ans = re.sub(r" \s+", " ", ans)
            # removing newlines
            ans = re.sub(r"\n", ". ", ans)
            ans = re.sub(r"\r", ". ", ans)

            # remove pesky single quote
            ans = re.sub(r"'", "", ans)
            ans = re.sub(r"’", "", ans)

            # HTML weird leftovers
            ans = re.sub(r"None{1,3}", " ", ans)

            # Remove some punctuations
            ans = re.sub(r";", "", ans)
            ans = re.sub(r",", "", ans)

            # final cast and rechecking
            ans = str(ans)
            # ans = re.sub(r"\W", " ", ans)
            ans = re.sub(r" \s+", " ", ans)

            # return answer
            return ans

        # exception handling
        except Exception as exp:
            Err.reraise(exp, "Gallery: clrtext")

        clean text from HTML, remove all inconvinient characters such as:
        extra spaces, extra end-of-line, and non utf-8 characters

        Args:
            text (str): text to clean

        Raises:
            exp: raise a generic exception if something goes wrong

        Returns:
            ans(str): clean text
        
clean text from HTML, remove all inconvinient characters such as:
extra spaces, extra end-of-line, and non utf-8 characters
clean text from HTML remove all inconvinient characters such as : extra spaces extra end - of - line and non utf - 8 characters
def clrtext(self, text):
        try:
            ans = str(text)
            ans = ans.strip()
            ans = unicodedata.normalize('NFD', ans)
            ans = ans.encode('ascii', 'ignore')
            ans = ans.decode("utf-8")
            ans = str(ans)
            ans = re.sub(r" \s+", " ", ans)
            ans = re.sub(r"\n", ". ", ans)
            ans = re.sub(r"\r", ". ", ans)
            ans = re.sub(r"'", "", ans)
            ans = re.sub(r"’", "", ans)
            ans = re.sub(r"None{1,3}", " ", ans)
            ans = re.sub(r";", "", ans)
            ans = re.sub(r",", "", ans)
            ans = str(ans)
            ans = re.sub(r" \s+", " ", ans)
            return ans
        except Exception as exp:
            Err.reraise(exp, "Gallery: clrtext")
def clrtext ( self , text ) : try : ans = str ( text ) ans = ans . strip ( ) ans = unicodedata . normalize ( 'NFD' , ans ) ans = ans . encode ( 'ascii' , 'ignore' ) ans = ans . decode ( "utf-8" ) ans = str ( ans ) ans = re . sub ( r" \s+" , " " , ans ) ans = re . sub ( r"\n" , ". " , ans ) ans = re . sub ( r"\r" , ". " , ans ) ans = re . sub ( r"'" , "" , ans ) ans = re . sub ( r"’",  " ,  a s) ans = re . sub ( r"None{1,3}" , " " , ans ) ans = re . sub ( r";" , "" , ans ) ans = re . sub ( r"," , "" , ans ) ans = str ( ans ) ans = re . sub ( r" \s+" , " " , ans ) return ans except Exception as exp : Err . reraise ( exp , "Gallery: clrtext" )
clean text from HTML, remove all inconvinient characters such as:
extra spaces, extra end-of-line, and non utf-8 characters
clean text from HTML remove all inconvinient characters such as : extra spaces extra end - of - line and non utf - 8 characters
# TODO: remove after implement the Topic() class """
        clean text from HTML, remove all inconvinient characters such as:
        extra spaces, extra end-of-line, and non utf-8 characters

        Args:
            text (str): text to clean

        Raises:
            exp: raise a generic exception if something goes wrong

        Returns:
            ans(str): clean text
        """ # asigning text as ans # attempt striping # fix encoding # removing extra spaces # removing newlines # remove pesky single quote # HTML weird leftovers # Remove some punctuations # final cast and rechecking # ans = re.sub(r"\W", " ", ans) # return answer # exception handling
None
ans(str)
raise a generic exception if something goes wrong
raise a generic exception if something goes wrong
exp
self
text
text to clean
text to clean