Created
April 6, 2016 15:01
-
-
Save cinoss/83742da6c7b7108f2007f400a95641d1 to your computer and use it in GitHub Desktop.
Remove Vietnamese Accents - Xoá dấu tiếng việt in Python
This file contains 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
s1 = u'ÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚÝàáâãèéêìíòóôõùúýĂăĐđĨĩŨũƠơƯưẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹ' | |
s0 = u'AAAAEEEIIOOOOUUYaaaaeeeiioooouuyAaDdIiUuOoUuAaAaAaAaAaAaAaAaAaAaAaAaEeEeEeEeEeEeEeEeIiIiOoOoOoOoOoOoOoOoOoOoOoOoUuUuUuUuUuUuUuYyYyYyYy' | |
def remove_accents(input_str): | |
s = '' | |
print input_str.encode('utf-8') | |
for c in input_str: | |
if c in s1: | |
s += s0[s1.index(c)] | |
else: | |
s += c | |
return s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mình có làm 1 phiên bản khác hoàn thiện hơn:
https://gist.github.com/phineas-pta/05cad38a29fea000ab6d9e13a6f7e623