Possible Duplicate:
Python dictionary, keep keys/values in same order as declared
Good day to all.
I'm working on a sentiment analysis application in python (to which I am new) and I am experiencing a problem.
I'm using the bag of words feature extractor but I'm experiencing one major problem when the bag of words function is called.
Let's assume that we have the following text: "He will be the winner."
When I call my function which has the following code: dict([(word, True) for word in words])
I get the following result:
{'will': True, 'be': True, 'the': True, 'winner': True, 'He': True}
Which is OK except for the fact that the word ordering is off. If I use a loop like that one:
for i in range(0, len(words)):
The order of the output is OK but I don't know how I can create a dictionary out of that. So can anyone suggest a way to get my bag of words without messing up the ordering of the words?
Thank you for your time and help.
Teo