How do you spell Gaddafi? Regex to the rescue!
September 21, 2011 11:22 AM   Subscribe

Stackoverflow grapples with the many spellings of "Gaddafi." Thank God programmers are on the case, because everyone else is confused by the 112 possibilities (even with this chart)! Even Dr. Demento weighed in.
posted by grumblebee (51 comments total) 9 users marked this as a favorite
 
How many different spellings of 'Gaddafi' are there?
posted by run"monty at 11:27 AM on September 21, 2011 [2 favorites]


The weird thing is that all of them are pronounced "Friedman."
posted by eugenen at 11:29 AM on September 21, 2011 [2 favorites]


There's only one spelling of G-a-d-d-a-f-i, but there are ~112 spellings (in English) of the Libyan leader's name.
posted by grumblebee at 11:30 AM on September 21, 2011 [1 favorite]


There's only one spelling of G-a-d-d-a-f-i, but there are ~112 spellings (in English) of the Libyan leader's name.
"Or else it doesn't, you know. The name of the song is called 'Haddocks' Eyes.'"
"Oh, that's the name of the song, is it?" Alice said, trying to feel interested.
"No, you don't understand," the Knight said, looking a little vexed. "That's what the name
is called. The name really is 'The Aged, Aged Man.'"
"Then I ought to have said 'That's what the song is called'?" Alice corrected herself.
"No you oughtn't: that's another thing. The song is called 'Ways and Means' but that's only
what it's called, you know!"
"Well, what is the song then?" said Alice, who was by this time completely bewildered.
"I was coming to that," the Knight said. "The song really is 'A-sitting On a Gate': and the
tune's my own invention."

posted by Sticherbeast at 11:32 AM on September 21, 2011 [6 favorites]


The chart in the PRI link is a regex, and probably more complete than anything in the stackoverflow thread, to boot.
posted by alopez at 11:39 AM on September 21, 2011


The Straight Dope struggled with this issue in the 80s, the Library of Congress gets involved, it is discovered his Name Authority Record recognizes 32 variants.

Thanks, Uncle Cecil!
posted by fifteen schnitzengruben is my limit at 11:40 AM on September 21, 2011


A good FPP becomes great when its tags are given sufficient attention. Well played, grumblebee.
posted by The Winsome Parker Lewis at 11:43 AM on September 21, 2011 [5 favorites]




As The Atlantic is reporting, the release of a video of someone apparently flipping through the passport of Gaddafi's eldest son Mohammed shows the accurate Latinized spelling of the Libyan leader's surname to be "Gathafi."

*Waves his passport.*

"This is not the Gaddafi you're looking for."
posted by three blind mice at 11:45 AM on September 21, 2011


I just checked his authority record--it's up to 54 now. (I don't think the LC Authorities site does permalinks, but just search for him here.)
posted by Horace Rumpole at 11:46 AM on September 21, 2011 [1 favorite]


I just checked his authority record--it's up to 54 now. (I don't think the LC Authorities site does permalinks, but just search for him here.)

well played, sir, well played.
posted by Foci for Analysis at 11:48 AM on September 21, 2011


I thought this was settled when the passports were found at his compound.
posted by MikeMc at 11:49 AM on September 21, 2011 [1 favorite]


I'll have a dumb crack at this. Looking at the Arabic spelling of his name, it seems that the transliteration would be Qadaafee (using the usual way of showing long vowels), which is not shown in the chart. One problem may be that there's a difference between the dark glottal qaaf sound (which sounds like a 'g' to some ears) and the sharper sound in an English 'q'.

Someone who speaks Arabic fluently--why is would this not be a good spelling?
posted by hanoixan at 11:51 AM on September 21, 2011


The chart in the PRI link is a regex

Technically the string "Mummar Gadaffi" is also a regex.

Also, the PRI chart admits 34,560 variations of the spelling, perhaps admitting more 'correct' spellings then it should (for example, if you mix different transliteration schemes, that would be wrong, but admitted by the PRI char)
posted by delmoi at 11:51 AM on September 21, 2011


fifteen schnitzengruben is my limit: "The Straight Dope struggled with this issue in the 80s"

That's why that piece was linked in the original post.
posted by Chrysostom at 11:54 AM on September 21, 2011 [1 favorite]


If that isn't an SO Tour de Force, I don't know what is.

As I read it, I cranked up White and Nerdy, put my hand over my heart, and shed one single tear of awe for my kind.

Thank you.
posted by tempythethird at 11:54 AM on September 21, 2011


Someone who speaks Arabic fluently--why is would this not be a good spelling?

Because apparently the goal of transliteration is to get as far from unambiguous phonetic representation of sounds while still retaining a tenuous connection to reality. See also the letter "X" re: conversion of Chinese to a Latin alphabet.
posted by Holy Zarquon's Singing Fish at 12:01 PM on September 21, 2011


NPR and AP go with "Gadhafi," citing letters written by Gadhafi in 1986, sent in response to letters sent from a second grade class. The NPR link was tucked under the fold on a prior post, but I didn't find the MinnPost on the letters until today.
posted by filthy light thief at 12:03 PM on September 21, 2011


"Bless you, bless you, bless you, gesundheit, bless you..."
posted by mmrtnt at 12:04 PM on September 21, 2011


I've always spelled it "Yelnik McWawa," but I have a background in linguistics.
posted by TheWhiteSkull at 12:11 PM on September 21, 2011 [1 favorite]


Ah, but are you sure it's not "Yelnick McWawa"?
posted by Chrysostom at 12:13 PM on September 21, 2011


See also the letter "X" re: conversion of Chinese to a Latin alphabet.

Eh, I don't really see how that one can be helped. There literally is no equivalent to the Chinese Pinyin "X" consonant in English. (At least that I know of. If anybody knows different, I would love to know.) A bit more baffling is using "Zh" for the English "J" sound, though again the Pinyin "J" doesn't really have an English equivalent.
posted by kmz at 12:16 PM on September 21, 2011


It's "Jacuzzi", obviously.
posted by lantius at 12:19 PM on September 21, 2011


....the longtime Libyan leader spells his own name Muammar al Gathafi.

What I don't understand is why there's no systematic way of transliterating Arabic letters. OK, Chinese has the two systems, Pinyin and Wade-Giles, but only the two, and Pinyin is standard now. The various Indian alphabets don't seem to give such problems either. Why hasn't it been standardized?
posted by TheophileEscargot at 12:30 PM on September 21, 2011


Can someone explain what a deterministic finite automaton (DFA) is?
posted by swift at 12:30 PM on September 21, 2011


^M(u|o|ou)\'?a?(mm|m)ar ((Al|al|El|el)[\- ]?)(Q|G|K|Kh)a(d|dh|dd|dhdh|th|zz)a(f|ff)(i|y)$
posted by Pruitt-Igoe at 12:32 PM on September 21, 2011


At a guess, it's really hard to get all the countries who speak Arabic or all the English-speak countries to sit down and hash it out. Arabic also has a lot of regional variation, which may or may not be a factor. But Russian transliteration is all over the place as well. Heck, I've gone and looked up whether Gauss and Weierstrass should have ess-zetts (which, slightly ironically, I don't know how to type on an iPad.)
posted by hoyland at 12:33 PM on September 21, 2011


Aw crap, that's wrong. Here:
^M(u|o|ou)\'?a?(mm|m)ar ((Al|al|El|el)[\- ]?)?(Q|G|K|Kh)a(d|dh|dd|dhdh|th|zz)a(f|ff)(i|y)$
posted by Pruitt-Igoe at 12:34 PM on September 21, 2011


I would go with the second answer:

Easy... (Qadaffi|Khadafy|Qadafi|...

you don't want to update and retest your regex every time a new spelling surfaces.

plus you can use PLINQ to paralellize maching.

Can someone explain what a deterministic finite automaton

A DFA is a state machine used in compiler design. The idea would be create a state machine based on a DSL for defining correct spellings.
posted by Ad hominem at 12:35 PM on September 21, 2011 [1 favorite]


Here is some info on DFAs from the GOLD parser system.
posted by Ad hominem at 12:40 PM on September 21, 2011 [1 favorite]


....the longtime Libyan leader spells his own name Muammar al Gathafi.

But he pronounces it "Throat-Warbler Mangrove."
posted by EmpressCallipygos at 12:56 PM on September 21, 2011 [2 favorites]


Does anyone remember the old SNL bit on Weekend Update where Chevy Chase was talking about this very subject? There was a graphic of a bunch of variations on how to spell it, and I think the last one was something like, Qaddafi Duck.
posted by luckynerd at 1:08 PM on September 21, 2011


I remember a standup comic back in the day that did a bit about trying to recite his airline confirmation code over the phone, although the internets is not letting me find it.

"K, as in Kaddafi.
P, as in Psychology.
Q ... as in Qadaffi."
posted by Kabanos at 1:11 PM on September 21, 2011 [4 favorites]


I don't care how you spell it. At least it's easier than saying Achmendinjahd, Agmedidandyjahd, Ahmdemijinawad. Sorry, I meant Machmoodahmadeanajad. No, that's not right either. How about mah-MOOD ah-mah-genie... mah-MOOD ah-mah-dinner... my-money on-my-DINNER... MOMMIE-mommie-MOMMIE-mommie-MOMMIE... beep-BOP-da-wheep-BOP... mah-MOOD ah-mah-something-or-other).

Oh screw it. Let's just call him Gaddafi. They're the same guy anyway.
posted by twoleftfeet at 1:23 PM on September 21, 2011


I expect a future wikileak to show that the West backed his ouster primarily to make diplomatic correspondence less of a headache.
posted by Abiezer at 1:32 PM on September 21, 2011


The Gadaffi REGEXP tests
;; Note that the first group matches NULL because it is always sucked
;; up by the preceding .* in case of a successful match.
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar Qaddafi" t t ("Muammar Qaddafi" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Mo'ammar Gadhafi" t t ("Mo'ammar Gadhafi" "" "dh"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar Kaddafi" t t ("Muammar Kaddafi" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar Qadhafi" t t ("Muammar Qadhafi" "" "dh"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Moammar El Kadhafi" t t ("Moammar El Kadhafi" "" "dh"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar Gadafi" t t ("Muammar Gadafi" "" "d"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Mu'ammar al-Qadafi" t t ("Mu'ammar al-Qadafi" "" "d"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Moamer El Kazzafi" t t ("Moamer El Kazzafi" "" "zz"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Moamar al-Gaddafi" t t ("Moamar al-Gaddafi" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Mu'ammar Al Qathafi" t t ("Mu'ammar Al Qathafi" "" "th"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar Al Qathafi" t t ("Muammar Al Qathafi" "" "th"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Mo'ammar el-Gadhafi" t t ("Mo'ammar el-Gadhafi" "" "dh"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Moamar El Kadhafi" t t ("Moamar El Kadhafi" "" "dh"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar al-Qadhafi" t t ("Muammar al-Qadhafi" "" "dh"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Mu'ammar al-Qadhdhafi" t t ("Mu'ammar al-Qadhdhafi" "" "dh"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Mu'ammar Qadafi" t t ("Mu'ammar Qadafi" "" "d"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Moamar Gaddafi" t t ("Moamar Gaddafi" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Mu'ammar Qadhdhafi" t t ("Mu'ammar Qadhdhafi" "" "dh"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar Khaddafi" t t ("Muammar Khaddafi" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar al-Khaddafi" t t ("Muammar al-Khaddafi" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Mu'amar al-Kadafi" t t ("Mu'amar al-Kadafi" "" "d"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar Ghaddafy" t t ("Muammar Ghaddafy" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar Ghadafi" t t ("Muammar Ghadafi" "" "d"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar Ghaddafi" t t ("Muammar Ghaddafi" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muamar Kaddafi" t t ("Muamar Kaddafi" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar Quathafi" t t ("Muammar Quathafi" "" "th"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muammar Gheddafi" t t ("Muammar Gheddafi" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Muamar Al-Kaddafi" t t ("Muamar Al-Kaddafi" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Moammar Khadafy " t t ("Moammar Khadafy" "" "d"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Moammar Qudhafi" t t ("Moammar Qudhafi" "" "dh"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Mu'ammar al-Qaddafi" t t ("Mu'ammar al-Qaddafi" "" "dd"))
("M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]"
"Mulazim Awwal Mu'ammar Muhammad Abu Minyar al-Qadhafi" t t
("Mu'ammar Muhammad Abu Minyar al-Qadhafi" "" "dh"))
;;

posted by benzenedream at 1:37 PM on September 21, 2011


grumblebee, you're missing about 82 tags. Very sloppy.
posted by Kabanos at 1:47 PM on September 21, 2011


Why don't we just spell it مُعَمَّر القَذَّافِي ?
I remember some wise guy in the 80's saying he doesn't even know how to spell his own name, like it's his fault.
posted by MtDewd at 1:50 PM on September 21, 2011


My iPhone autocorrects to "Catfish."
posted by mullacc at 2:23 PM on September 21, 2011


"I don't care how you spell it. At least it's easier than saying"

I prefer IM-A-DINNER-JACKET.
posted by MikeMc at 2:49 PM on September 21, 2011 [1 favorite]


That chart thing is rather nifty.
posted by deborah at 3:27 PM on September 21, 2011


Dictatorist 1.0, add names as you see fit. Run on the command line with a name


static void Main(string[] args)
{

List dictators = new List () {
"Gadaffi",
"Gadafi",
"Gadafy",
"Gaddafi"};

if (args.Length == 0)
{
Console.WriteLine("Gimme a name");
return;
}
Console.WriteLine(dictators.AsParallel().Any(dictator => string.Equal(dictator, args[0], StringComparison.CurrentCultureIgnoreCase)) ? "Dictator" : "Not a dictoator");
}

posted by Ad hominem at 3:39 PM on September 21, 2011


Whoa whoa, lost some angle brackets there!

should be List<string> dictators = new List<string>()

and

AsParallel().Any<string>(

Already too much code in this thread, ill just toss this bad boy up on GitHub so everyone can contribute!
posted by Ad hominem at 3:43 PM on September 21, 2011


I'll have a dumb crack at this. Looking at the Arabic spelling of his name, it seems that the transliteration would be Qadaafee (using the usual way of showing long vowels), which is not shown in the chart. One problem may be that there's a difference between the dark glottal qaaf sound (which sounds like a 'g' to some ears) and the sharper sound in an English 'q'.

It really depends on the end goal of transcription. If you're trying to represent a language properly, but written in Roman script rather than its native script, faithfulness is key. But here we're just trying to represent a name as part of an English text, but which isn't otherwise readable. So while we preserve French or German spellings for the sake of ease because they're already more or less readable, there's no reason why we shouldn't write an Arabic name (or Chinese, or Hindi) in a way that represents it as spoken by English speakers. Trying to show phonological distinctions in Arabic that aren't present in English only makes things harder. The qaaf sound is a voiceless uvular plosive, which simply no standard dialect of English has. If it sounds more like a "k" or a "g" to our ears, then we should write it as such. For many years English wrote Koran which was clear as to pronunciation in English, but now we often see Qur'an which is ambiguous.
posted by Jehan at 4:01 PM on September 21, 2011


I love how most people are like "What is the One True Way to spell his name?" and programmers are like "Let's just account for every variation possible..."
posted by Xany at 5:12 PM on September 21, 2011


luckynerd: "Does anyone remember the old SNL bit on Weekend Update where Chevy Chase was talking about this very subject? There was a graphic of a bunch of variations on how to spell it, and I think the last one was something like, Qaddafi Duck"

That was actually Brian Doyle Murray doing Weekend Update, in 1981. I can't find any video of the bit, but the transcript is here. (Note the other alternatives in the screenshot on the left.) I've thought of the Libyan leader as Kadaffy Duck ever since.
posted by John Smallberries at 5:54 PM on September 21, 2011


My iPhone autocorrects to "Catfish."

So that's the twist ending.
posted by Judith Butlerian Jihad at 1:11 AM on September 22, 2011


Godawful
posted by Segundus at 2:20 AM on September 22, 2011


Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. (source)
posted by cyberscythe at 5:18 AM on September 22, 2011


Arabic has pharyngealized consonants which are written with separate letters, plus some other letters that represent sounds that don't have equivalents in most languages that use variants of the Latin alphabet.

So:

ح kind of like an H, but different from the other H that's spelled ه

ص kind of like an S, but different from س

ض kind of like a D, but different from د

ط kind of like a T, but different from ت

ظ sounds a lot like an English L, but usually transcribed Z. It's different from ز which is also transcribed Z, and different from ل which sounds more like a French or Spanish L.

ع kind an "ah" sound, only it's a consonant. (The most common approach to transcribing this one is just to pretend it's not there.)

غ kind of like a G, usually transcribed GH.

ق kind of like a K, but different from ك . Usually ق is transcribed Q and ك is K, but the pronunciation of ق varies a lot.

ء a diacritic not a letter, indicates a catch like in the English words "uh-oh" and "uh-uh."

Matching Arabic sounds up with Latin letters is tricky. There are some fairly standardized transcriptions of Arabic used in academic literature (Wikipedia uses DIN), However, these use a lot of diacritics, and newspapers don't like diacritics.

The first letter of قذافى 's name is ق kind like a K in standard Arabic, but pronounced like a G in Libya. The second letter is ذ . It sounds like the TH in "then" and "they" (but not "thin"). It's usually transcribed DH, but it western Libya it's pronounced D. (Qaddafi's from the Sirt area where they do pronounce it as in "then", which explains his family's preference for TH spellings.) The second letter of his first name is ع usually left out, but sometimes indicated with an apostrophe. The D or DH in Qaddhafi and the second M in Muammar, Moammar, Moamer, etc. are geminates, pronounced like Italian, Finnish and Hungarian double consonants. They're usually transcribed with double letters, but this distinction isn't usually marked in Arab spelling. Some transcriptions ignore it.

Qaddhafi, or Qaddafi, are close to academic transcriptions, based on standard Arabic pronunciation, with the diacritics stripped out. Gaddafi and Gaddhafi represent Western and Eastern Libyan pronunciations.

Short vowels usually aren't represented in Arabic spelling at all, and pronunciation varies a lot with accent, so transcriptions of them end up being close to random. And Libyan pronunciation is highly contracted, so sometimes they disappear entirely, and you get spellings like Misrata for Misurata and (Mersa) Brega for Marsa al-Buraiqa.
posted by nangar at 5:21 AM on September 22, 2011 [3 favorites]


Anything other than Al-Qadhafi makes my skin crawl.
posted by dougrayrankin at 3:37 PM on September 22, 2011


« Older Sweetness follows   |   Aurora borealis under a full moon Newer »


This thread has been archived and is closed to new comments