Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
The community reviewed whether to reopen this question 9 months ago and left it closed:
Original close reason(s) were not resolved
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
在我看来,处理这个问题的唯一明智的方法是让用户告诉你他们的名字应该如何大写。任何自动计划都会惹恼某人。
The only sensible way to handle it, in my opinion, is to let the users tell you how their name should be capitalized. Any automatic scheme is going to annoy someone.
只要告诉他们你是老派。这使得它变得简单且 100% 正确:
相同的逻辑也有助于解决许多 i18n 问题。
Just tell them you're OLD SCHOOL. That makes it simple and 100% correct:
The same logic also helps with many i18n problems.
还有 Python 中的此实现 基于此算法。基本思想是将名称转换为标题大小写,然后根据巨大的异常查找表检查名称。
但乔纳森·莱弗勒 (Jonathan Leffler) 所说的确实是正确的:除非您有转换预先存在的未格式化数据的要求,否则自动大写将会出现错误(特别是因为大写规则因语言鸿沟、文化鸿沟、因移民而导致的姓名更改而异)或者人们只是喜欢以某种特定的方式大写他们的名字)。
There's also this implementation in Python which is based on this algorithm. The basic idea is convert the name to title case then check the name against a giant look-up table of exceptions.
But really what Jonathan Leffler said is spot on: unless you have some requirement to convert pre-existing unformatted data, automated capitalization is going to do something wrong (especially as capitalization rules vary across language divides, cultural divides, name changes that result from emigration or people just preferring to capitalize their name in some particular fashion).
我不断查找需要特殊处理的名字。当找到不区分大小写的匹配项时,我使用查找值。这并没有解决使用与“接受的”大写不匹配的大小写的人的问题。它允许我/用户根据需要添加名称。我找不到我的代码,但我确实从 http://www.census.gov/。
I kept a lookup of names that needed special handling. When a case-insensitive match was found, I used the lookup value. This did not resolve people who used case that did not match the "accepted" capitalization. It allowed me/user to add names as needed. I can't find my code, but I did get the surnames from http://www.census.gov/.