oracle 编程中人名的大写
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2466706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Capitalization of Person names in programming
提问by Albert
Is anyone aware of some code/rules on how to capitalize the names of people correctly?
有没有人知道一些关于如何正确大写人名的代码/规则?
- John Smith
- Johan van Rensburg
- Derrick von Gogh
- Ruby de La Fuente
- Peter Maclaurin
- Garry McDonald
- 约翰·史密斯
- 约翰·范·伦斯堡
- 德里克·冯·高
- 红宝石德拉富恩特
- 彼得麦克劳林
- 加里麦克唐纳
(these may not be correct, just some sample names and how the capitalization could be/work)
(这些可能不正确,只是一些示例名称以及大写如何/工作)
This seems like a losing battle...
这似乎是一场失败的战斗......
If anyone has some code or rules on when and how to capitalize names, let me know :)
如果有人对何时以及如何大写名称有一些代码或规则,请告诉我:)
Cheers, Albert
干杯,阿尔伯特
回答by Jonathan Leffler
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.
在我看来,处理它的唯一明智的方法是让用户告诉你他们的名字应该如何大写。任何自动计划都会惹恼某人。
回答by Mark Harrison
Just tell them you're OLD SCHOOL. That makes it simple and 100% correct:
告诉他们你是OLD SCHOOL。这使它变得简单且 100% 正确:
- JOHN SMITH
- JOHAN VAN RENSBURG
- DERRICK VON GOGH
- RUBY DE LA FUENTE
- PETER MACLAURIN
- GARRY MCDONALD
The same logic also helps with many i18n problems.
同样的逻辑也有助于解决许多 i18n 问题。
回答by Peter Alexander
回答by Jaxidian
回答by ig0774
There's also this implementation in Pythonwhich 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.
在 Python 中也有这个实现,它基于这个算法。基本思想是将名称转换为标题大小写,然后根据一个巨大的异常查找表检查名称。
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).
但 Jonathan Leffler 所说的确实是正确的:除非你有一些要求转换预先存在的未格式化数据,否则自动大写会做错事(特别是因为大写规则因语言鸿沟、文化鸿沟、移民导致的姓名变化而异或者人们只是喜欢以某种特定的方式将他们的名字大写)。
回答by AMissico
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/.
我一直在查找需要特殊处理的名称。当找到不区分大小写的匹配时,我使用了查找值。这并没有解决使用与“接受”大写不匹配的案例的人。它允许我/用户根据需要添加名称。我找不到我的代码,但我确实从http://www.census.gov/获得了姓氏。