Created
September 20, 2013 03:38
-
-
Save junaidpv/6633007 to your computer and use it in GitHub Desktop.
Replace old chills with new atomic chills.
To read more about chills see: http://www.unicode.org/versions/Unicode5.1.0/#Malayalam_Chillu_Characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!python | |
| """ | |
| Replace old chills with new atomic chills. | |
| To read more about chills see: http://www.unicode.org/versions/Unicode5.1.0/#Malayalam_Chillu_Characters | |
| """ | |
| import unicodedata | |
| import codecs | |
| import sys | |
| import os.path | |
| # Chill pairs | |
| chills = { | |
| u'\u0D23\u0D4D\u200D': u'\u0D7A', # new chillu NN | |
| u'\u0D28\u0D4D\u200D': u'\u0D7B', # new chillu N | |
| u'\u0d30\u0d4d\u200d': u'\u0d7c', # new chillu R | |
| u'\u0D32\u0D4D\u200D': u'\u0D7D', # new chillu L | |
| u'\u0D33\u0D4D\u200D': u'\u0D7E', # new chillu LL | |
| u'\u0d15\u0D4D\u200D': u'\u0D7F', # new chillu K | |
| } | |
| #oldNT = u'\u0d28\u0d4d\u0D31' | |
| #newNT = u'\u0D7B\u0D4D\u0D31' | |
| # function to replace old chills with new ones | |
| def replace_chills(string): | |
| for old_chill, new_chill in chills.iteritems(): | |
| string=string.replace(old_chill, new_chill) | |
| return string | |
| if __name__ =='__main__': | |
| input_filename = sys.argv[1] | |
| output_filename = sys.argv[2] | |
| input_file = codecs.open(input_filename, mode='r', encoding='utf-8') | |
| output_file = codecs.open(output_filename, mode='w+', encoding='utf-8') | |
| # Read entire text and convert. | |
| output_file.write(replace_chills(input_file.read())) | |
| output_file.flush() | |
| output_file.close() | |
| input_file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment