Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- d = {}
- with open('acronym.txt', 'r') as acronym:
- for line in acronym:
- d[line.split(None, 1)[0]] = (line.split(None, 1)[1]).strip()
- ntweetsfile= open('newTweets.txt', 'w')
- import fileinput
- for line in fileinput.input('tweets1k.txt', inplace=True):
- line = line.rstrip()
- if not line:
- continue
- for key in d:
- if str(key) in line:
- line = line.replace(str(key), d[key])
- ntweetsfile.write(str(line)+'n')
- else:
- ntweetsfile.write(str(line)+'n')
- ntweetsfile.close()
Add Comment
Please, Sign In to add comment