[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

#plural? or #singular?

Mark Dodwell

5/23/2008 10:07:00 PM

Does anybody know an easy way to test if a word is singular or plural --
something a bit smarter than just checking if there is an s on the end!

Thanks,

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

31 Answers

Michael W. Ryder

5/23/2008 10:44:00 PM

0

Mark Dodwell wrote:
> Does anybody know an easy way to test if a word is singular or plural --
> something a bit smarter than just checking if there is an s on the end!
>
> Thanks,
>
> ~ Mark

You might be able to use some form of dictionary lookup and that will
help with words like mice, but it still will not help with words like
moose where the singular and plural are the same.

Axel Etzold

5/23/2008 11:14:00 PM

0


-------- Original-Nachricht --------
> Datum: Sat, 24 May 2008 07:45:01 +0900
> Von: "Michael W. Ryder" <_mwryder@worldnet.att.net>
> An: ruby-talk@ruby-lang.org
> Betreff: Re: #plural? or #singular?

> Mark Dodwell wrote:
> > Does anybody know an easy way to test if a word is singular or plural --
> > something a bit smarter than just checking if there is an s on the end!
> >
> > Thanks,
> >
> > ~ Mark
>
> You might be able to use some form of dictionary lookup and that will
> help with words like mice, but it still will not help with words like
> moose where the singular and plural are the same.

Dear Mark,

for the simpler task, where there are different forms for singular and
plural (eg., mouse-mice, house-houses), you could use this:

http://api.rubyonrails.org/classes/Infl...

For the more difficult cases, where singular and plural forms coincide
(and for the easier cases as well), a part-of-speech tagger can be helpful.

I don't know of any written in Ruby, but I can recommend the tree-tagger,
which you can script from Ruby to suit your needs.
It is available for several languages, so you can find irregular plurals
of words in different languages ....

It is here :

http://www.ims.uni-stuttgart.de/projekte/corplex/T...


Best regards,

Axel
--
Super-Acktion nur in der GMX Spieleflat: 10 Tage für 1 Euro.
Über 180 Spiele downloaden und spiele: http://flat.ga...

Trans

5/24/2008 12:43:00 AM

0



On May 23, 6:07=A0pm, Mark Dodwell <s...@mkdynamic.co.uk> wrote:
> Does anybody know an easy way to test if a word is singular or plural --
> something a bit smarter than just checking if there is an s on the end!

English gem may help. If you devise #plural? and #singular? I'd be
happy to add them to the API.

T.


Marc Heiler

5/24/2008 1:12:00 AM

0


http://www.deveiate.org/projects/Li...

might be also useful to you.
--
Posted via http://www.ruby-....

Dave Bass

5/24/2008 3:08:00 PM

0

There are lots of difficulties here.

Is "sheep" singular or plural?
Is "fish" singular or plural?
Is "the government" singular or plural?
Is "England" singular or plural? (England is a country / England are
bound to lose the match)
Is "English" singular or plural? (English is a language / The English
are eccentric)

So even an exhaustive list of words is not going to give you the right
answer all the time. You need to take the word in context, i.e. you need
to parse the sentence grammatically. Here There Be Dragons.



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

Robert Dober

5/24/2008 3:28:00 PM

0

On Sat, May 24, 2008 at 5:08 PM, Dave Bass <davebass@musician.org> wrote:
Even worse sometimes it is undefined I guess, or caption may play a role.

I can see data.

Maybe some native speakers will tell me that this is not a correct
sentence, I do not know, but than there is

I can see Data.

Languages (plural) are just a big mess (singular) ;)

Robert
--
http://ruby-smalltalk.blo...

---
Whereof one cannot speak, thereof one must be silent.
Ludwig Wittgenstein

Axel Etzold

5/24/2008 4:14:00 PM

0



-------- Original-Nachricht --------
> Datum: Sun, 25 May 2008 00:27:48 +0900
> Von: "Robert Dober" <robert.dober@gmail.com>
> An: ruby-talk@ruby-lang.org
> Betreff: Re: #plural? or #singular?

> On Sat, May 24, 2008 at 5:08 PM, Dave Bass <davebass@musician.org> wrote:
> Even worse sometimes it is undefined I guess, or caption may play a role.
>
> I can see data.
>
> Maybe some native speakers will tell me that this is not a correct
> sentence, I do not know, but than there is
>
> I can see Data.
>
> Languages (plural) are just a big mess (singular) ;)
>
> Robert
> --
> http://ruby-smalltalk.blo...
>
> ---
> Whereof one cannot speak, thereof one must be silent.
> Ludwig Wittgenstein

Dear Robert and Dave,

well, this is what tree-tagger (see tags output below, for the tagset
see my previous post) says:

I can see data. (noun plural)
I can see Data. (proper noun singular)
England is a country. (proper noun singular)
England are bound to lose the match. (proper noun singular) (nobody is perfect).
English is a language. (proper noun singular)
The English are eccentric. (noun plural)
Languages (noun plural) are just a big mess (noun singular).

Parts-of-speech tagging uses a Bayesian decision model, requiring
training on a set of human-tagged text.
There are large amounts of texts available for many languages, such
as newspaper articles.
The authors of tree-taggers claim about 96 % correct tagging somewhere
in the docs ( can't find it right now).
It's also fast - you can tag an entire novel in just a few seconds -
and it's available for several major languages, not just English.


Best regards,

Axel

-----------------------------------

I PP I
can MD can
see VV see
data NNS datum
SENT .
I PP I
can MD can
see VV see
Data NP Data
SENT .
England NP England
is VBZ be
a DT a
country NN country
SENT .
England NP England
are VBP be
bound VVN bind
to TO to
lose VV lose
the DT the
match NN match
SENT .
English NP English
is VBZ be
a DT a
language NN language
SENT .
The DT the
English NNS English
are VBP be
eccentric JJ eccentric
SENT .
Languages NNS language
are VBP be
just RB just
a DT a
big JJ big
mess NN mess
SENT .


--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/...

Ray Baxter

5/24/2008 4:35:00 PM

0


On May 24, 2008, at 9:14 AM, Axel Etzold wrote:

> well, this is what tree-tagger (see tags output below, for the tagset
> see my previous post) says:

> England are bound to lose the match. (proper noun singular) (nobody
> is perfect).

The collective noun in American English is singular, while in British
English the collective noun is plural. In American English, we would
say "England is bound to lose the match," so your results are correct,
if the language under consideration is American English. (Although I'm
not sure what to make of the plural verb.)

> Parts-of-speech tagging uses a Bayesian decision model, requiring
> training on a set of human-tagged text.

Did you train tree-tagger on a data set of American English?

Ray



Robert Dober

5/24/2008 4:41:00 PM

0

>
> I can see data. (noun plural)
> I can see Data. (proper noun singular)
> England is a country. (proper noun singular)
> England are bound to lose the match. (proper noun singular) (nobody is perfect).
> English is a language. (proper noun singular)
> The English are eccentric. (noun plural)
> Languages (noun plural) are just a big mess (noun singular).
Impressive, I have to admit :)

>
> Parts-of-speech tagging uses a Bayesian decision model, requiring
> training on a set of human-tagged text.
> There are large amounts of texts available for many languages, such
> as newspaper articles.
> The authors of tree-taggers claim about 96 % correct tagging somewhere
> in the docs ( can't find it right now).
> It's also fast - you can tag an entire novel in just a few seconds -
> and it's available for several major languages, not just English.
Even more so !!! Thanx for sharing
R.

Todd Benson

5/24/2008 6:14:00 PM

0

On Sat, May 24, 2008 at 11:14 AM, Axel Etzold <AEtzold@gmx.de> wrote:
>
>
> -------- Original-Nachricht --------
>> Datum: Sun, 25 May 2008 00:27:48 +0900
>> Von: "Robert Dober" <robert.dober@gmail.com>
>> An: ruby-talk@ruby-lang.org
>> Betreff: Re: #plural? or #singular?
>
>> On Sat, May 24, 2008 at 5:08 PM, Dave Bass <davebass@musician.org> wrote:
>> Even worse sometimes it is undefined I guess, or caption may play a role.
>>
>> I can see data.
>>
>> Maybe some native speakers will tell me that this is not a correct
>> sentence, I do not know, but than there is
>>
>> I can see Data.
>>
>> Languages (plural) are just a big mess (singular) ;)
>>
>> Robert
>> --
>> http://ruby-smalltalk.blo...
>>
>> ---
>> Whereof one cannot speak, thereof one must be silent.
>> Ludwig Wittgenstein
>
> Dear Robert and Dave,
>
> well, this is what tree-tagger (see tags output below, for the tagset
> see my previous post) says:
>
> I can see data. (noun plural)
> I can see Data. (proper noun singular)
> England is a country. (proper noun singular)
> England are bound to lose the match. (proper noun singular) (nobody is perfect).
> English is a language. (proper noun singular)
> The English are eccentric. (noun plural)
> Languages (noun plural) are just a big mess (noun singular).

You will always have problems with collective nouns (brood, flock,
pride, etc), especially if you train yourself on languages that aren't
spoken.

>
> Parts-of-speech tagging uses a Bayesian decision model, requiring
> training on a set of human-tagged text.
> There are large amounts of texts available for many languages, such
> as newspaper articles.
> The authors of tree-taggers claim about 96 % correct tagging somewhere
> in the docs ( can't find it right now).
> It's also fast - you can tag an entire novel in just a few seconds -
> and it's available for several major languages, not just English.

I think many people balk at your question because you didn't specify
the terms of the problem. What language? What vernacular? What
venue?

cheerio (plural),
Todd