Very basic question

2008-12-23 Thread Sengly
Hello all,

I would like to calculate a string expression to a float. For example,
I have ('12/5') and I want 2.4 as a result. I tried to use eval but it
only gives me 2 instead of 2.5

Help!!!

Regards,

Sengly
--
http://mail.python.org/mailman/listinfo/python-list


Re: Very basic question

2008-12-23 Thread Sengly
I can hack it by doing eval('1.0*12/5') but is there any better method?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Very basic question

2008-12-23 Thread Sengly
Thank you very much everyone.

Regards,

-- Sengly
--
http://mail.python.org/mailman/listinfo/python-list


Python library for clustering from distance vector

2008-05-17 Thread Sengly
Dear all,

I am looking for a python library which can cluster similar objects
into their respective groups given their similarity score of each two
of them. I have searched the group but I couldn't find any helpful
information yet.

Any suggestion is appreciated. Also, if you know any specific group
that I should post this message, please also suggest.

Thank you.

Sengly
--
http://mail.python.org/mailman/listinfo/python-list


simple question on list manipulation from a newbie

2008-06-07 Thread Sengly
Dear all,

I am working with wordnet and I am a python newbie. I'd like to know
how can I transfer a list below

In [69]: dog
Out[69]:
[{noun: dog, domestic_dog, Canis_familiaris},
 {noun: frump, dog},
 {noun: dog},
 {noun: cad, bounder, blackguard, dog, hound, heel},
 {noun: frank, frankfurter, hotdog, hot_dog, dog, wiener, wienerwurst,
weenie},
 {noun: pawl, detent, click, dog},
 {noun: andiron, firedog, dog, dog-iron}]

to a list like this with python:

[dog, domestic_dog, Canis_familiaris,
frump, dog,
dog,
cad, bounder, blackguard, dog, hound, heel,
frank, frankfurter, hotdog, hot_dog, dog, wiener, wienerwurst,
weenie},
pawl, detent, click, dog},
andiron, firedog, dog, dog-iron]

Thank you.

Sengly

--
http://mail.python.org/mailman/listinfo/python-list


Re: simple question on list manipulation from a newbie

2008-06-07 Thread Sengly
On Jun 8, 6:38 am, Sam Denton <[EMAIL PROTECTED]> wrote:
> Sengly wrote:
> > Dear all,
>
> > I am working with wordnet and I am a python newbie. I'd like to know
> > how can I transfer a list below
>
> > In [69]: dog
> > Out[69]:
> > [{noun: dog, domestic_dog, Canis_familiaris},
> >  {noun: frump, dog},
> >  {noun: dog},
> >  {noun: cad, bounder, blackguard, dog, hound, heel},
> >  {noun: frank, frankfurter, hotdog, hot_dog, dog, wiener, wienerwurst,
> > weenie},
> >  {noun: pawl, detent, click, dog},
> >  {noun: andiron, firedog, dog, dog-iron}]
>
> > to a list like this with python:
>
> > [dog, domestic_dog, Canis_familiaris,
> > frump, dog,
> > dog,
> > cad, bounder, blackguard, dog, hound, heel,
> > frank, frankfurter, hotdog, hot_dog, dog, wiener, wienerwurst,
> > weenie},
> > pawl, detent, click, dog},
> > andiron, firedog, dog, dog-iron]
>
> I can't help you with the formatting, but here's a solution using Python
> data structures:
>
>  >>> alist = [
>      {'noun': ('dog', 'domestic_dog', 'Canis_familiaris')},
>      {'noun': ('frump', 'dog')},
>      {'noun': ('dog',)},
>      {'noun': ('cad', 'bounder', 'blackguard', 'dog', 'hound', 'heel')},
>      {'noun': ('frank', 'frankfurter', 'hotdog', 'hot_dog', 'dog',
> 'wiener', 'wienerwurst', 'weenie')},
>      {'noun': ('pawl', 'detent', 'click', 'dog')},
>      {'noun': ('andiron', 'firedog', 'dog', 'dog-iron')},
>      ]
>
>  >>> merged = {}
>  >>> for d in alist:
>          for key, value in d.iteritems():
>              merged.setdefault(key, []).extend(value)
>
>  >>> merged
> {'noun': ['dog', 'domestic_dog', 'Canis_familiaris', 'frump', 'dog',
> 'dog', 'cad', 'bounder', 'blackguard', 'dog', 'hound', 'heel', 'frank',
> 'frankfurter', 'hotdog', 'hot_dog', 'dog', 'wiener', 'wienerwurst',
> 'weenie', 'pawl', 'detent', 'click', 'dog', 'andiron', 'firedog', 'dog',
> 'dog-iron']}

Thank you all for your help. I found a solution as the following:

alist = [
 {'noun': 'dog', 'domestic_dog', 'Canis_familiaris'},
 {'noun': 'frump', 'dog'},
 {'noun': 'dog',},
 {'noun': 'cad', 'bounder', 'blackguard', 'dog', 'hound', 'heel'},
 {'noun': 'frank', 'frankfurter', 'hotdog', 'hot_dog', 'dog',
'wiener', 'wienerwurst', 'weenie'},
 {'noun': 'pawl', 'detent', 'click', 'dog'},
 {'noun': 'andiron', 'firedog', 'dog', 'dog-iron'},
 ]

def getAll(alist):
list=[]
for i in range(0,len(alist)):
list.extend(alist[i][:])
return list

Kind regards,

Sengly
--
http://mail.python.org/mailman/listinfo/python-list


Finding a sense of word in a text

2008-06-11 Thread Sengly
Dear all,

This might be off group but I am looking for a python library that can
help me to find a sense of a word in a text and eventually a list of
synonyms of that term. I searched the web and found one but it is
written in perl (http://www.d.umn.edu/~tpederse/senserelate.html) :(

I appreciate any pointers.

Thank you before hand.

Kind regards,

Sengly
--
http://mail.python.org/mailman/listinfo/python-list


Re: Finding a sense of word in a text

2008-06-13 Thread Sengly
Thank you. I have tried but no luck :(

Regards,

Sengly

--
http://mail.python.org/mailman/listinfo/python-list


Re: Finding a sense of word in a text

2008-06-13 Thread Sengly
Thanks a lot everyone. I appreciate your suggestion.

But still, I could not find a simple way using wordnet since each term
might have several part of speech and each one of them can have many
senses. What I want is simply the list of synonyms of each term with
their popularity score in English text.

Once again, thank you.

Best regards,

Sengly
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python library for clustering from distance vector

2008-06-14 Thread Sengly
On May 19, 2:42 am, jay graves <[EMAIL PROTECTED]> wrote:
> On May 17, 11:49 pm, Sengly <[EMAIL PROTECTED]> wrote:
>
> > I am looking for a python library which can cluster similar objects
> > into their respective groups given their similarity score of each two
> > of them. I have searched the group but I couldn't find any helpful
> > information yet.
>
> How about google?  Searching for the terms python and cluster gave
> some results for me.
>
> http://www.google.com/search?q=python+cluster
>
> > Any suggestion is appreciated. Also, if you know any specific group
> > that I should post this message, please also suggest.
>
> The book, "Programming Collective Intelligence" by Toby Segaran is
> great and has examples of clustering algorithms written in Python.
>
> http://www.amazon.com/Programming-Collective-Intelligence-Building-Ap...
>
> ...
> Jay Graves

Thank you very much for your pointers.

Regards,

Sengly
--
http://mail.python.org/mailman/listinfo/python-list


Re: image matching algorithms

2008-05-03 Thread Sengly
On Mar 14, 10:59 am, "Daniel Fetchinson" <[EMAIL PROTECTED]>
wrote:
> > > Since you seem to know quite a bit about this topic, what is your
> > > opinion on the apparently 'generic' algorithm described here:
> > >http://grail.cs.washington.edu/projects/query/?
> > > So far it seems to me that it does what I'm asking for, it does even
> > > more because it can take a hand drawn sample image and query the
> > > database for similar photos.
>
> > > There is even a python implementation for it here:
> > >http://members.tripod.com/~edcjones/pycode.html
>
> > > On the histogram method I agree that it won't work partly because of
> > > what you say and partly because it is terribly slow since it's
> > > comparing every single pixel.
>
> > I'm hardly the expert and can't answer authoritatively, but here's my 2c.
>
> > I can't comment as to the actual accuracy of the algorithm, since it
> > will depend on your specific data set (set of photos). The algorithm is
> > sensitive to spatial and luminance information (because of the YIQ
> > colorspace), so there are simple ways in which it will fail.
>
> > The histogram method uses only color, but has a lot of numbers to
> > compare. You may find the histogram method insensitive to spatial
> > relations (a landscape with the mountain on the left and one with the
> > mountain on the right) compared to the wavelet approach.
>
> > This is a relatively old paper, and I've seen other more recent image
> > retrieval research using wavelets (some cases using only the
> > high-frequency wavelets for "texture" information instead of the
> > low-frequency ones used by this paper for "shape") and other information
> > retrieval-related research using lossy compressed data as the features.
> > If you have time, you may want to look at other research that cite this
> > particular paper.
>
> > And just a thought: Instead of merely cutting off at m largest-wavelets,
> > why not apply a quantization matrix to all the values?
>
> I'm not at all an expert, just started to look into image matching, so
> I'm not quite sure what you mean. What's a quantization matrix in this
> context?

Hello,

I am also looking for the solution to the same problem. Could you let
me know if you have found something useful so far?

I appreciate your response.

Thanks a lot.

Sengly
--
http://mail.python.org/mailman/listinfo/python-list