Last active
August 29, 2015 14:10
-
-
Save dchaplinsky/d91e5f3dea13440d274d to your computer and use it in GitHub Desktop.
Simple implementaiton of python's title that works well with ukrainian surnames and names (including compound ones and names with apostrophes)
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
# -*- coding: utf-8 -*- | |
from string import capwords | |
def title(s): | |
chunks = s.split() | |
chunks = map(lambda x: capwords(x, u"-"), chunks) | |
return u" ".join(chunks) | |
if __name__ == '__main__': | |
s = u"мар'яна семенюк-самсоненко" | |
print(title(s)) # Мар'яна Семенюк-Самсоненко | |
print(capwords(s)) # Мар'яна Семенюк-самсоненко | |
print(s.title()) # Мар'Яна Семенюк-Самсоненко |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment