Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-09 Thread Token Type
Thanks indeed for your tips. Now I understand the difference between tuples and dictionaries deeper. -- http://mail.python.org/mailman/listinfo/python-list

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-08 Thread Token Type
yes, thanks all your tips. I did try sorted with itemgetter. However, the sorted results are same as follows whether I set reverse=True or reverse= False. Isn't it strange? Thanks. import nltk from nltk.corpus import wordnet as wn pairs = {'car':'automobile', 'gem':'jewel',

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-08 Thread Token Type
Dear all, the problem has been solved as follows. Thanks anyway: import nltk from nltk.corpus import wordnet as wn pairs = {'car':'automobile', 'gem':'jewel', 'journey':'voyage'} list_simi=[] for key in pairs: word1 = wn.synset(str(key) + '.n.01') word2 =

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-08 Thread Ian Kelly
On Mon, Oct 8, 2012 at 9:13 PM, Token Type typeto...@gmail.com wrote: yes, thanks all your tips. I did try sorted with itemgetter. However, the sorted results are same as follows whether I set reverse=True or reverse= False. Isn't it strange? Thanks. First of all, sorted does not sort the

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-08 Thread alex23
On Oct 9, 1:13 pm, Token Type typeto...@gmail.com wrote: yes, thanks all your tips. I did try sorted with itemgetter. However, the sorted results are same as follows whether I set reverse=True or reverse= False. Isn't it strange? Thanks. That's because you're sorting each entry individually,

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-08 Thread Token Type
Thanks indeed for all your suggestions. When I try my above codes, what puzzles me is that when the data in the dictionary increase, some data become missing in the sorted result. Quite odd. In the pairs, we have {'journey':'voyage'} but in the sorted result no ('journey-voyage',0.25), which

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-08 Thread alex23
On Oct 9, 2:16 pm, Token Type typeto...@gmail.com wrote: When I try my above codes, what puzzles me is that when the data in the dictionary increase, some data become missing in the sorted result. Quite odd. In the pairs, we have {'journey':'voyage'} but in the sorted result no (

wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-07 Thread Token Type
In order to solve the following question, http://nltk.googlecode.com/svn/trunk/doc/book/ch02.html: ★ Use one of the predefined similarity measures to score the similarity of each of the following pairs of words. Rank the pairs in order of decreasing similarity. How close is your ranking to the

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-07 Thread Mark Lawrence
On 07/10/2012 17:15, Token Type wrote: In order to solve the following question, http://nltk.googlecode.com/svn/trunk/doc/book/ch02.html: ★ Use one of the predefined similarity measures to score the similarity of each of the following pairs of words. Rank the pairs in order of decreasing

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-07 Thread Terry Reedy
On 10/7/2012 12:15 PM, Token Type wrote: In this case, I need to use loop to iterate each element in the above pairs. How can I refer to each element in the above pairs, i.e. pairs = [(car, automobile), (gem, jewel), (journey, voyage) ]. What's the index for 'car' and for 'automobile'? Thanks