rockym93 dot net

archive · tags · feed

Ordinal Numbers

19 February 201105:25PMlinguisticscode

Yesterday I had to walk to City Beach to pick up my bike. I was going to catch the bus over there, but Transperth decided that no, every half an hour is quite enough, and I just happened to pick a combination of two buses with the maximum possible time between them. Walking was actually faster. I was going to ride straight home, but Dad convinced me I should stay for a while and look at his computer (I didn't) and meet his sister's Swedish (or something) exchange student, and hang out with Mike who showed me dealextreme.com where I bought a 50-pack of dice for $2.15 or something ridanculous. In any case, I was there until about 10 at night, I didn't get to ride my bike home and had to do it the next morning.

Anyway.

While I was walking, I started wondering about the logic behind ordinal numbers. Ordinal numbers are the ones which denote order, as in first, second, third, etc. (as opposed to cardinal numbers, which are one, two, three, and so on.) and more specifically, the suffixes used to identify them. The rule basically goes, "st, nd, rd, and then th indefinitely, unless it's a -teen, in which case they're all ths". Which basically follows another irregularity in English numbering which is the use of -teen at all where every other tens digit follows the [variation on tens digit]ty-[ones digit]. It would make a lot more sense, and probably be easier to teach people, if we just used tenty for that.

Having established this rule, when I got home the first thing I did was teach my computer this pleasantly logical rule, like so:

#!/usr/bin/env python  
def ordinaliser(number):  
    if len(str(number) > 1 and int(str(number)[-2]) == 1 and int(str(number)[-1]) in [1,2,3]:  
        return str(number) + "th"  
    elif int(str(number)[-1]) == 1:  
        return str(number) + "st"  
    elif int(str(number)[-1]) == 2:  
        return str(number) + "nd"  
    elif int(str(number)[-1]) == 3:  
        return str(number) + "rd"  
    else:  
        return str(number) + "th"

Which is probably more than it could (or should) be given my limited programming skills, but loads smaller than I was expecting for something which is basically a rule of grammar. Interestingly, if you were French, that code would only look like this:

def ord_francais(nombre):  
    if nombre == 1:  
        return str(nombre) + "er"  
    else:  
        return str(nombre) + "eme"

Because French is logical like that. On a side note, it's also incredibly difficult to teach, especially to someone who a) has never done French before and b) knows nothing about grammar. I have to say, most of my knowledge of grammar comes from French rather than English, probably because things like tenses are much more rigidly defined. Then again, I am getting paid for it...

Anyway, back on topic. I was expecting the interaction between language and numbers to be a lot less logical and easily defined than that - admittedly, mostly due to there being very, very few rules in the english language which work as consistently and (relatively) simply, which is one of the major barriers (I gather) to language processing. If every rule in english could be coded in that many lines, we'd be talking to our computers Star Trek style in no time. Clearly, the maths types need to get more involved in language. It'd make things much easier for all of us.

< Talking to strangers I should be reading the Iliad right now. >