CAN You help Re: Writing dictionary output to a file
dont bother
dontbotherworld at yahoo.com
Sat Mar 6 07:02:12 EST 2004
Hi Jong,
Yes I really want the location of the number matching
in the dictionary.
This is because I have to input these feature vectors
to another program which takes [index: value ] where
index: is the value specific to dictionary.
I dont care about the addition/extension of the words
in the dictionary but for now, I really want the index
of the word in the dictionary. This is also equivalent
to the line number of the word in the dictionary.
> >for v,i in enumerate(vector):
> >
> Confusing naming. enumerate(iterable) gives a list
> of
> (index, value) tuples.
> When you enumerate a map, the index values are of
> course sequential
> integers, starting with 0, but the values are
> essentially
> arbitrary keys from the mapping.
> So, here you have:
> v == irrelevant integer index value,
> and i == arbitrary key (=word) from vector
>
> > vector[i] /= a
> >
> I assume a is an integer, otherwise this would fail.
Yes a is an integer, the total number of words in the
message.
> You divide the count for the word i by a (total
> number
> of words in msg?).
>
> > #print v,i, vector[i] ; if u want to see the
> word
> >too that was commmon
> >
> This would print
> <irrelevant index number>, <word>, <wordcount
> divided by a>
>
> > print v,":",vector[i]
> >
> This would print
> <irrelevant index number>: <wordcount divided by a>
No. This does not print the corresponding location of
the word in the dictionary, but the location of the
word in the message. I want the location/line number
of the matching word in the dictionary.
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what youre looking for faster
http://search.yahoo.com
More information about the Python-list
mailing list