I have this situation, I have a sentence with wrong dot (.) to process, the sentence:
sentence = 'Hi. Long time no see .how are you ?can you follow .@abcde?'
I am trying to normalize this sentence, if you see it, there is some wrong format sentence (.how, ?can, and .@abcde). I am thinking of using regex to handle this because the sentence keep changing. This is my code so far: import re
character = ['.','?','@']
sentence = 'Hi. Long time no see .how are you ?can you follow .@abcde?'
sentence = str(sentence)
for i in character:
charac = str(i)
charac_after = re.findall(r'\\'+charac+r'\S*', sentence)
if charac_after:
print("Exist")
sentence = sentence.replace(charac, charac+' ')
print(sentence)
The result some how skip the dot (.) and at (@) it just process the question mark (?). This is the result: Exist
Hi. Long time no see .how are you ? can you follow .@abcde?
its supposed to be "Hi. Long time no see . how are you ? can you follow . @ abcde?". I don't know if my double backslash in "r'\'+charac+r'\S*'" are wrong or something, did I miss something?
How can I process all the character? please help.