Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28760

Re: Is there a unique method in python to unique a list?

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!news-out.octanews.net!indigo.octanews.net!auth.brown.octanews.com.POSTED!not-for-mail
From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.python
Subject Re: Is there a unique method in python to unique a list?
References <c44aff41-71ed-4323-9184-9c87bd0e1119@googlegroups.com> <60A480B7378343149401A424A682AF34@gmail.com> <CAE5RzXmmGF-w0qHG1F6J5yBMMUptzmGmTqpjh21gf8Yg0A1U_w@mail.gmail.com> <C6FCB83691994615873009528A6C0CD7@gmail.com> <CAE5RzXnjE+UqZj5Ofk2i0F=9U7ZGaAi2D+odwZbUHz0_bYQbzg@mail.gmail.com> <mailman.405.1347172371.27098.python-list@python.org> <mailman.407.1347173102.27098.python-list@python.org> <7xwr03oafu.fsf@ruckus.brouhaha.com>
Date Sun, 09 Sep 2012 02:06:49 -0700
Message-ID <7x7gs34lau.fsf@ruckus.brouhaha.com> (permalink)
Organization Nightsong/Fort GNOX
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:dvybCc59G+9M256kWbehm8TDI8M=
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Lines 17
NNTP-Posting-Date 09 Sep 2012 04:06:49 CDT
X-Complaints-To abuse@octanews.net
Xref csiph.com comp.lang.python:28760

Show key headers only | View raw


Paul Rubin <no.email@nospam.invalid> writes:
> I think you mean (untested):
>
>      synsets = wn.all_synsets(pos)
>      sense_number = 0
>      lemma_set = set()
>      for synset in synsets:
>          lemma_set.add(synset.lemma_names)
>      for lemma in lemma_set:
>          sense_number += len(wn.synsets(lemma,pos))
>      return sense_number / len(lemma_set)

Or even:

  lemma_set = set(synset for synset in wn.all_synsets(pos))
  sense_number = sum(len(wn.synsets(lemma, pos)) for lemma in lemma_set)
  return sense_number / len(lemma_set)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Is there a unique method in python to unique a list? Token Type <typetoken@gmail.com> - 2012-09-08 22:43 -0700
  Re: Is there a unique method in python to unique a list? Chris Angelico <rosuav@gmail.com> - 2012-09-09 15:48 +1000
  Re: Is there a unique method in python to unique a list? Chris Angelico <rosuav@gmail.com> - 2012-09-09 16:32 +1000
    Re: Is there a unique method in python to unique a list? Token Type <typetoken@gmail.com> - 2012-09-08 23:44 -0700
      Re: Is there a unique method in python to unique a list? Paul Rubin <no.email@nospam.invalid> - 2012-09-09 01:41 -0700
        Re: Is there a unique method in python to unique a list? Paul Rubin <no.email@nospam.invalid> - 2012-09-09 02:06 -0700
        Re: Is there a unique method in python to unique a list? Token Type <typetoken@gmail.com> - 2012-09-09 06:44 -0700
          Re: Is there a unique method in python to unique a list? Chris Angelico <rosuav@gmail.com> - 2012-09-10 00:13 +1000
  Re: Is there a unique method in python to unique a list? Serhiy Storchaka <storchaka@gmail.com> - 2012-09-09 11:36 +0300

csiph-web