Okay Heres the problem: in Index

Miki Tebeka miki.tebeka at zoran.com
Wed Mar 10 07:28:16 CET 2004


> 1. The numbers 0, 1, 2, 3, that are in the output of
> the vector.py are the corresponding position of the
> words in the email_message, that I ran against the
> dictionary_index. I want the index of the
> corresponding word in the dictionary. For example: If
> "syntax" was occuring in the dictionary at 500. I want
> the 500 syntax <value> instead of 6 syntax <value>
> that I am getting right now.
When you load the dictionary just remember the line of each "syntax" and 
print it later.

--- *not tested* ---
syntax = {}
lines = {}
for lnum, line in enumerate(open("dictionary.txt")):
     val, syn = line.strip().split(":")
     syntax[syn] = long(val)
     lines[syn] = lnum

> 1 index value index value index value index value
> index value
I don't see the problem here.


More information about the Python-list mailing list