-
-
Save J2TEAM/9992744f15187ba51d46aecab21fd469 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 và xử lí dc các trường hợp không thành công ở trên:
https://gist.github.com/phineas-pta/05cad38a29fea000ab6d9e13a6f7e623