Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
575 B
41
Indexable
Never
def cleanText(string):

  try:
    fin=""
    string=string.replace('\n'," ")
    #print(string)
    string=string.split()
    for  i in range(len(string)):
      if (string[i]=="") or (string[i][0] in "@/") or ("http" in string[i]) or (string[i][0] =="#" and string[i][-1] not in "?!.,"):
        continue
      else:
        if((string[i][0] =="#" and string[i][-1] in "?!.,")):
          fin+=" "+string[i][1:]
        else:
          fin+=" "+string[i]
    return fin.strip()


  except Exception as e:
    print("ERROR"," ".join(string))
    print(e)