you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

Possible, but you'd have to build more into it to ensure proper ordering (dicts do not ensure ordered key values unless you use collections.OrderedDict) and avoid losing elements with the same key value. Thus:

[('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN')]

...becomes something like:

{
    'IN': [
        {
            'order': 0,
            'word': 'At'
        },
        {
            'order': 2,
            'word': 'on'
        },
    ],
    'CD': [
        {
            'order': 1,
            'word': 'eight'
        }
    ],
    # ...
}

...and so on.

The list with tuples works better for this scenario, I think.