[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: The "ruby way" to break apart a name?

mathew

12/21/2005 10:15:00 PM

Jeff Cohen wrote:
> Assume for simplicity that the the first name is the text up to the
> first space, and the last name is the text after the last space.
[...]
> But something about split_name still feels a bit "wrong",

Well, I think the bigger issue is that your assumptions are wrong. :-)

In some countries, the surname is written first, then the 'first' name.
Japan is an example. Some Japanese write their names in reverse when
writing them transliterated to English, and some don't. (...which makes
me wonder which is the case for Matz...)

Also, the number of words in the full name can vary between 1 and a
fairly large integer. (I knew a guy with 6.) The number of name words
required to actually route mail to a unique person can vary between 1
and (at least) 3, and compound names are not always hyphenated. Then
there are things like "Jr", and salutations that go after the name
rather than in front.

There are quite a few postings in comp.risks about this kind of thing.
In general it's very hard to do it right, and if (for example) you want
to produce a "Dear <salutation goes here>" header for a letter, it's
best to store the salutation as a separate field, rather than try to
guess what it might be from the name.

Of course, if you're working with a badly structured database someone
else has given you, you may not have the choice...


mathew
--
<URL:http://www.pobox.com/...
My parents went to the lost kingdom of Hyrule
and all I got was this lousy triforce.
12 Answers

James Gray

12/21/2005 10:55:00 PM

0

On Dec 21, 2005, at 4:17 PM, mathew wrote:

> Also, the number of words in the full name can vary between 1 and a
> fairly large integer.

Amen. Names are much trickier than you think...

James Edward Gray II (married to Dana Ann Leslie Gray)



greg.kujawa

12/22/2005 2:28:00 PM

0

James Edward Gray II wrote:

> Amen. Names are much trickier than you think...
>
>James Edward Gray II (married to Dana Ann Leslie Gray)

I second that sentiment. I recall a college buddy of mine. His full
name was Bradley Lee Bradley. Trying hard to think of a good regex
representation of that :-)

Christian Neukirchen

12/22/2005 2:46:00 PM

0

James Edward Gray II <james@grayproductions.net> writes:

> On Dec 21, 2005, at 4:17 PM, mathew wrote:
>
>> Also, the number of words in the full name can vary between 1 and a
>> fairly large integer.
>
> Amen. Names are much trickier than you think...
>
> James Edward Gray II (married to Dana Ann Leslie Gray)

Full Ack, James II.

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneuk...


dblack

12/22/2005 3:01:00 PM

0

Jacob Fugal

12/22/2005 6:01:00 PM

0

On 12/22/05, Christian Neukirchen <chneukirchen@gmail.com> wrote:
> James Edward Gray II <james@grayproductions.net> writes:
>
> > On Dec 21, 2005, at 4:17 PM, mathew wrote:
> >
> >> Also, the number of words in the full name can vary between 1 and a
> >> fairly large integer.
> >
> > Amen. Names are much trickier than you think...
> >
> > James Edward Gray II (married to Dana Ann Leslie Gray)
>
> Full Ack, James II.

I thought that was a spoonerism at first and wondered what you had
against James' comments. Then I looked again and read "Full ACK", and
it made more sense. :)

Jacob Fugal


Jeff

1/2/2006 12:46:00 AM

0

unknown wrote:
> On Thu, 22 Dec 2005, James Edward Gray II wrote:
>
>> On Dec 21, 2005, at 4:17 PM, mathew wrote:
>>
>>> Also, the number of words in the full name can vary between 1 and a fairly
>>> large integer.
>>
>> Amen. Names are much trickier than you think...
>>

HEY YOU GUYS! :-) I was originally asking for the best way to return
the first and last parts of an array.

Breaking apart a name was just an example because I had to make up and
example in order to ask the question. Hence I said "Assume for
simplicity..." OF COURSE dealing with names is not as trivial as my
example.

The initial replies helped me understand arrays in Ruby better.

Thanks
Jeff

--
Posted via http://www.ruby-....


Wilson Bilkovich

1/2/2006 7:29:00 AM

0

This reminds me of U.S. street addresses. I (on and off) do work that
interfaces with a huge IBM mainframe application. That system has
many, many separate fields for street addresses:
Number, Direction, Street/Route, Quad, Suffix, Apartment, Line2, etc.
I laughed at the way the original engineers had overbuilt. Ha ha ha.
...
...
Then I had to write code that took a single address string and split
it into its component parts, and I stopped laughing.
e.g. 123 N. NESTOR LANE RD. SE #10B

Life is complicated, it turns out.

On 1/1/06, Gerardo Santana Gómez Garrido <gerardo.santana@gmail.com> wrote:
> We had a similar problem at work.
>
> In the Spanish speaking world we use two last names: one from the
> father's family (apellido paterno) and another from the mother's
> family (apellido materno). For the "first name" there's no limit in
> the number of names.
>
> Fortunately for us, the names were stored in the database as:
>
> <apellido paterno> <apellido materno> <nombres>
>
> But there was a difficulty. In Spanish we have last names composed of
> more than one word like "de la Vega", "y Cruz", "de las Casas"
>
> Examples:
>
> Cruz y Cruz María del Rosario
> de la Vega Domínguez Jorge
> Ponce de León Ernesto Zedillo
>
> We couldn't avoid regular expressions:
> http://santanatechnotes.blo...2005/12/matching-iso-8859-1-strings-with...
>
> ---------- Forwarded message ----------
> From: mathew <meta@pobox.com>
> Date: 21-dic-2005 16:17
> Subject: Re: The "ruby way" to break apart a name?
> To: ruby-talk ML <ruby-talk@ruby-lang.org>
>
>
> Jeff Cohen wrote:
> > Assume for simplicity that the the first name is the text up to the
> > first space, and the last name is the text after the last space.
> [...]
> > But something about split_name still feels a bit "wrong",
>
> Well, I think the bigger issue is that your assumptions are wrong. :-)
>
> In some countries, the surname is written first, then the 'first' name.
> Japan is an example. Some Japanese write their names in reverse when
> writing them transliterated to English, and some don't. (...which makes
> me wonder which is the case for Matz...)
>
> Also, the number of words in the full name can vary between 1 and a
> fairly large integer. (I knew a guy with 6.) The number of name words
> required to actually route mail to a unique person can vary between 1
> and (at least) 3, and compound names are not always hyphenated. Then
> there are things like "Jr", and salutations that go after the name
> rather than in front.
>
> There are quite a few postings in comp.risks about this kind of thing.
> In general it's very hard to do it right, and if (for example) you want
> to produce a "Dear <salutation goes here>" header for a letter, it's
> best to store the salutation as a separate field, rather than try to
> guess what it might be from the name.
>
> Of course, if you're working with a badly structured database someone
> else has given you, you may not have the choice...
>
>
> mathew
> --
> <URL:http://www.pobox.com/...
> My parents went to the lost kingdom of Hyrule
> and all I got was this lousy triforce.
>
>
>
> --
> Gerardo Santana
> "Between individuals, as between nations, respect for the rights of
> others is peace" - Don Benito Juárez
> http://santanatechnotes.blo...
>
>


Kevin Brown

1/2/2006 3:53:00 PM

0

On Monday 02 January 2006 01:28, Wilson Bilkovich wrote:
> This reminds me of U.S. street addresses. I (on and off) do work that
> interfaces with a huge IBM mainframe application. That system has
> many, many separate fields for street addresses:
> Number, Direction, Street/Route, Quad, Suffix, Apartment, Line2, etc.
> I laughed at the way the original engineers had overbuilt. Ha ha ha.
> ...
> ...
> Then I had to write code that took a single address string and split
> it into its component parts, and I stopped laughing.
> e.g. 123 N. NESTOR LANE RD. SE #10B
>
> Life is complicated, it turns out.

That's nothing. Addresses here are based on landmarks:

De donde fue Texaco Viejo 1/2 C al E, 2 c al S
City Name, Department name (sometimes), Nicaragua

Break that one up.

(literal translation is: From where the old texaco USED TO BE (it's a petronic
now), 1/2 a block to the east and 2 blocks to the south) That is just how
addresses are here.

> On 1/1/06, Gerardo Santana Gómez Garrido <gerardo.santana@gmail.com> wrote:
> > We had a similar problem at work.
> >
> > In the Spanish speaking world we use two last names: one from the
> > father's family (apellido paterno) and another from the mother's
> > family (apellido materno). For the "first name" there's no limit in
> > the number of names.
> >
> > Fortunately for us, the names were stored in the database as:
> >
> > <apellido paterno> <apellido materno> <nombres>
> >
> > But there was a difficulty. In Spanish we have last names composed of
> > more than one word like "de la Vega", "y Cruz", "de las Casas"
> >
> > Examples:
> >
> > Cruz y Cruz María del Rosario
> > de la Vega Domínguez Jorge
> > Ponce de León Ernesto Zedillo
> >
> > We couldn't avoid regular expressions:
> > http://santanatechnotes.blo...2005/12/matching-iso-8859-...
> >with-ruby.html
> >
> > ---------- Forwarded message ----------
> > From: mathew <meta@pobox.com>
> > Date: 21-dic-2005 16:17
> > Subject: Re: The "ruby way" to break apart a name?
> > To: ruby-talk ML <ruby-talk@ruby-lang.org>
> >
> > Jeff Cohen wrote:
> > > Assume for simplicity that the the first name is the text up to the
> > > first space, and the last name is the text after the last space.
> >
> > [...]
> >
> > > But something about split_name still feels a bit "wrong",
> >
> > Well, I think the bigger issue is that your assumptions are wrong. :-)
> >
> > In some countries, the surname is written first, then the 'first' name.
> > Japan is an example. Some Japanese write their names in reverse when
> > writing them transliterated to English, and some don't. (...which makes
> > me wonder which is the case for Matz...)
> >
> > Also, the number of words in the full name can vary between 1 and a
> > fairly large integer. (I knew a guy with 6.) The number of name words
> > required to actually route mail to a unique person can vary between 1
> > and (at least) 3, and compound names are not always hyphenated. Then
> > there are things like "Jr", and salutations that go after the name
> > rather than in front.
> >
> > There are quite a few postings in comp.risks about this kind of thing.
> > In general it's very hard to do it right, and if (for example) you want
> > to produce a "Dear <salutation goes here>" header for a letter, it's
> > best to store the salutation as a separate field, rather than try to
> > guess what it might be from the name.
> >
> > Of course, if you're working with a badly structured database someone
> > else has given you, you may not have the choice...
> >
> >
> > mathew
> > --
> > <URL:http://www.pobox.com/...
> > My parents went to the lost kingdom of Hyrule
> > and all I got was this lousy triforce.
> >
> >
> >
> > --
> > Gerardo Santana
> > "Between individuals, as between nations, respect for the rights of
> > others is peace" - Don Benito Juárez
> > http://santanatechnotes.blo...


Gerardo Santana Gómez Garrido

1/2/2006 4:46:00 PM

0

2006/1/2, Steve Litt <slitt@earthlink.net>:
> On Sunday 01 January 2006 10:25 pm, Gerardo Santana Gómez Garrido wrote:
> > We had a similar problem at work.
> >
> > In the Spanish speaking world we use two last names: one from the
> > father's family (apellido paterno) and another from the mother's
> > family (apellido materno). For the "first name" there's no limit in
> > the number of names.
> >
> > Fortunately for us, the names were stored in the database as:
> >
> > <apellido paterno> <apellido materno> <nombres>
>
> I've always wondered about this, both in Spanish names and American hyphenated
> names. When the mother and father have a baby, does it go like this:
>
> baby.apellido_materno = mother.apellido_paterno
> baby.apellido_paterno = father.apellido_paterno

This is the one.
Father's last name prevails in each case. Very machista eh? :)

apellido_materno would be the "mother's name" in the English speaking
world, I believe (since mother's last name is her father's last name)

--
Gerardo Santana
"Between individuals, as between nations, respect for the rights of
others is peace" - Don Benito Juárez
http://santanatechnotes.blo...


Daniel Calvelo

1/2/2006 5:26:00 PM

0

And the only problems arise when one or both of paterno or materno is
itself composite and non hyphenated. Right, Gerardo?

In France, not only you *can* receive either your father's or mother's
family name, but you can change your family when you marry, divorce
remarry and so on.