IT
asked on
how to split attached words and slang look up in a text file in python?
I have a text file which has multiple attached words like RainyDay, PlayingInTheCold etc. These words can be split into normal forms using regex to make them into meaningful words.
error is:
Can someone please help me?
Thanks
import re, string, html
with open("1.txt", "r") as fin, open("2.txt", "w") as fout:
for text in fin:
words = text.split()
cleaned = " ".join(re.findall('[A-Z][^A-Z]*', words))
fout.write(cleaned)
error: Also, there are many slang words like helo, luv which should be converted to hello, love. I am trying like thiswith open("1.txt", "r") as fin, open("2.txt", "w") as fout:
for text in fin:
words = text.split()
words = slang_loopup(words)
text = ' '.join(words)
fout.write(cleaned)
I tried _slang_loopup() also but same NameErrorerror is:
Can someone please help me?
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually, I think it should work but not working.
Open in new window