PDA

View Full Version : a or an


Chompy
01-05-2007, 08:21 PM
Well, when you see title I think that you think it's something about grammar,
well, script wise it is; is there a way to see if a string should have 'a' or 'an' infront? Instead of having a private function like..


temp.foo = { "a", "e", "u", "i", "o", "y"};
temp.bar = "test";

return ( temp.bar.substring( 0, 1) in temp.foo ? "an" : "a") SPC temp.bar;

// would produce 'a test'


Is there an easier way? ( well, thats easy, just looking if there is a built-in or something, or it could of been suggested..)

xXziroXx
01-05-2007, 08:25 PM
if (this.string.starts("an")) { ... }

Chompy
01-05-2007, 08:28 PM
if (this.string.starts("an")) { ... }

Not that, I mean, if you have a clean text string, like:


temp.text = "item";


Now.. Is there a way to see if the string should have 'an' before it, or is the only way a public function?

xXziroXx
01-05-2007, 08:38 PM
Not that, I mean, if you have a clean text string, like:


temp.text = "item";


Now.. Is there a way to see if the string should have 'an' before it, or is the only way a public function?

Ohh you mean like that.. no idea.

Tolnaftate2004
01-05-2007, 08:43 PM
There is no tell-tale way to determine this. Your script will not function perfectly. You will get results such as "a honor".

Chompy
01-05-2007, 08:45 PM
There is no tell-tale way to determine this. Your script will not function perfectly. You will get results such as "a honor".

hmm, didn't think of that :O Would of been nice tho.. could maybe been scripted as a function.. hmm..

Angel_Light
01-07-2007, 07:58 AM
well you could create a very long 23 gigibyte english word base and do it from there :P Thats how large M-W webbase of common english words is.

Twinny
01-07-2007, 08:14 AM
well you could create a very long 23 gigibyte english word base and do it from there :P Thats how large M-W webbase of common english words is.

Gigabyte. I think it would be more check first letter for aeiou and then maybe an array of certain words which use an.