- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Frists!
Admin
Anothers goods ones froms Elli Mornings.
Reminds me of one of my favourite brain teasers: what common English plural noun becomes a common English singular noun by the addition of an s?
Admin
And today the "View all 1 comments" link at the bottom of the article has never been more appropriate...
But now I've spoiled it.
Admin
The weakne of thi algorithm i tremendou!
Admin
Also as a French native speaker I can't imagine how beautiful the thousand lines of code a clueless dev would output with that same thing in mind, but with a French-named DB instead (tbf using any other language than English for developing might be considered a wtf in the first place but that's for another debate).
Admin
princes
Admin
Why yes natural language is hard. With this hack the search provide better results than what they would have been without it. Sure you might get hilarious results, but you get those only after the search has failed for the original query. It doesn't need to work for all languages to be useful.
Admin
people, peoples
Admin
I'ms imaginings thes searchs resultss fors 1984s
Admin
I doubt that you'll get lots of hilarious results as long as there's no hjilarious content in the database.
It might look strange when the database is queried against "untils" or "hilariou" but since there was already no match for "until" or "hilarious", there will be none for the latter as well. Or maybe it will find a typo by conincidence, but then it's just fine.
This rather looks like some manager wanted to find singular and plural nouns with a quick check but the project was already over time, so the only thing the developers could do was inventing this dirty hack.
Admin
You realize these are fall-backs? The other option would have been not to show any results. Sure if most of the queries are not in English then using those fall-backs will likely confuse more than help. Since we don't know the frequency of languages this was used with, we can't say whether it's a WTF at all. And for other scripts like Chinese these won't do a thing so they are harmless.
Admin
"This rather looks like some manager wanted to find singular and plural nouns with a quick check but the project was already over time, so the only thing the developers could do was inventing this dirty hack."
That's almost certainly what happened. And since the "full" implementation would require a "database" of anomalies(1), doing it right in a hurry is a non-starter. Of course, doing it wrong is easy...
(1) Words that add -es instead of -s. Words that add -x (bureau(x) and similar). Words that change -y into -ies. Words that add -s to -y without changing the -y. Words that add some other suffix, like child(ren). Words that undergo internal change but don't add anything, like man/men and woman/women. Words that just plain don't change, like "sheep". Words that don't have plurals. Words that are only plural, even if they don't look it (frequently adjectives used as pronouns, e.g. "the blind", "the aged", and so on). Oh, and words that have two different plurals, like penny in British English - pennies if you mean the coin, pence if you mean an amount of money.
Admin
Actually, things are a bit worse when realize that grammer of one human language are added to both frameworks and programming languages.
Example 1: SQL The execution order of the query is different than the writing order. SELECT is actually one of the last statements that are executed. And when you write queries long enough, it even starts to feel natural to write queries in execution order instead of English language order.
Example 2: A lot of ORM's You create an 'object' and suddenly the name of the table is 'objects'. But how the plural form gets created or if it exist at all, is rather language specific.
You could of course use a dictionary to determine the single and plural form of each word, assuming that the language has a plural form that work similar to English plurals.
Bonus example 3: Functions that capitalize first letter of each word in names How many tutorials have I not seen that claims that their method of capitalizing the first letter of each word is a good method properly spell names. This is a function that creators claim is useful, but one that I have never been able to use. Frankly because this does not work in German, and in Dutch it even gets worse. Example:
First name: Pieter Middle name: Laurentius Last name: van der Meer
The last name is tricky as it contains of two parts the prefix "van der" and main part "Meer". And alphabetically, the last name starts with "M". First and last name combined: Mister Pieter van der Meer Only last name: Mister Van Der Meer
Admin
I'm not sure even a list of rules would really cut it, especially if we are supposed to support multiple languages (After all, bureaux is French, children is following Saxon conventions, and what the hell do you do with "paninis"? with or without Grocer's apostrophe?). And if it's straight user input, or off a website, you're probably screwed anyway.
You'd need some sort of dictionary API, with some sort of context awareness to tell apart heteronyms that pluralise differently ... bass (drum), (sea) bass, bass (the sound) ... and equally some way to deal with cross-language heteronyms (if that's the right way to say it).
It's a mess of complexities you'd never get a 100%, without more explanation this solution may well be messy, but good enough for whatever the purpose was at the time.
Admin
Paninis: without GG apostrophe of course, otherwise is always wrong.
Admin
Anyone else read the title in Toki Wartooth's voice?
Admin
I sees nothings wrong with its. My bandsmate Skwisgaar agrees with me's!
Admin
Holy sheet, that abomination of a (programming) language.
Admin
Stops copys me.
Admin
Point was, panini is already plural, but sticking the "s" on has become common usage, as has Panini's for that matter, so I'm not sure how universally accepted any rule or dictionary would be with this stuff. In fact, the use of an apostrophe when pluralising is standard usage in the very English-like Dutch language, as there are many shared words you could have a lot of fun automating that distinction.
Admin
TRWTF here is WHO TF would ever agree to code it that way rather than using a LIKE and letting the users wade thru the occasionally extra results. Boss: "But they might try with a plural and not get a hit" You: "So teach them to try without the plural. In fact teach them to try with only 5-12 or so characters. They'll still get hits but won't have to key so much or chance fumble-fingering 1 of the 37 characters in the full title"
Admin
I don't go to Mc Donald's, neither to Mc Donald'
Admin
mouses gooses octopuses vertexs
Admin
All of this plural stuff makes dates look like a piece of cake. Yes, I know it isn't, but language is difficult, and there are so many of them, and then there is English.
Admin
Nope, sorry: the correct spelling in this case is “Van der Meer” — only the first preposition is capitalised if there are no first names or initials.
Admin
what common English plural noun becomes a common English singular verb by the addition of an s?
assess
Admin
asses -> assess bras -> brass
Admin
Assuming the language is English, in most cases that the fallback finds a result, it will be a valid one. If the titles are proper English, most of the "hilarious" searches won't find anything. Personally, I think a bigger issue is that a user might become accustomed to successfully getting the alternative result whether they searched for a singular or plural, and then not think about looking for other forms when the title ends in an a word with an irregular plural, or which follows one of the many regular plurals rules other than "add an s".
Only slightly off-topic, back in the 70's, a friend had some success selling a program which would search a collection of books. It created an inverted full-text index by taking the first few letters of each word along with a hash. Due to the memory limitations of the day, the hash was short - I think it was 16 bits. This resulted in a large number of false positives. However, the product was marketed as having a level of "artificial intelligence". In fact, after getting the "matches", it would then repeat the search for the words found within some range of the match; this would be repeated a few times. The program then returned the paragraphs in which these "matches" were found.
As you can imagine, most of the results didn't have the word or phrase that was being searched for. But if your target audience was people searching for deep philosophical meaning in particular texts, and who believed in the power of the computer, they'd look at the results, and after a while go "Aha!" and wonder at the remarkable insight they'd received.
Admin
Please, noble Jedis! Not in the faces!
Admin
There's similar code in my codebase that even tries to be "smart" by looking at the last few letters of the word to be pluralised. But a typo with a logic error resulted in Gollum appearing: 1 resultses. 2 results. That bug existed for months before someone's OCD eventually got the better of them and got it fixed.
To be fair, things like adding "s" to most words or "es" to already ending in "s" (etc) was just the default behaviour; one could pass in the plural form. It still wouldn't handle non-English cases like 1, 2 many or gendered nouns but it could be made to create a grammatically correct sentence involving more words: "1 item is ready/2 items are ready"
Admin
There are several plural nouns that when you add an S, you get a singular noun. This puzzle was posted on rec.puzzles not too long ago.
Admin
"Brass" isn't a verb.
Admin
From Wiktionary: "To coat with brass."
Admin
"Look at all those motherfucking meese!"
Admin
Hah. What obsolete (hint - Shakespearean) word becomes plural when adding an "l" ?
Admin
Just looked the rec.puzzles thread - some nice examples I'd not seen before - particularly like "deadlines" and "worldlines"
Admin
"Oh, and words that have two different plurals, like penny in British English - pennies if you mean the coin, pence if you mean an amount of money."
This happens both ways, if you want to make "cattle" singular you need to know things like what the age and sex of the animal are as there is no generic singular.
Admin
In a former life I used a database that tried to capitalise Mc/Mac surnames. Welcome to Mr MacE.
Admin
Welcome also to Mr. Mackie who is not Mr. MacKie. (Look at the K's.)
Admin
"Goodbye Mr. MacKenzie" is an even shittier bandname than "Goodbye Mr. Mackenzie" already is, lol. Ah well, good thing the keyboardist got hired by a band called "Garbage".
Admin
I grew up in farm country, so I know the dictionary writers get it wrong with regards to cattle. Among those who raise cattle, the singular of "cattle" is "cow" unless you know the age and sex of the critter, and it is not an adult female - and the plural of "cow" is often "cows". If a mixed herd needs to be moved, they will tell you to drive the cows , not the cattle.
Admin
You are totally right about SQL being bass-ackwards. These days I almost always write my FROMs, JOINs, and inner queries first. Hell, most of the time, I don't have a clear picture of what fields I want to SELECT until I am halfway done.