> >>> d = defaultdict(lambda: defaultdict(int))
>
> Arnaud
Ah... so that's what lambdas are for. Many thanks!
Brandon
--
http://mail.python.org/mailman/listinfo/python-list
Brandon writes:
> Thanks bear -
>
> Some outside advice has me looking at nested dictionaries. But I am
> still bogged down because I've not created one before and all examples
> I can find are simple ones where they are created manually, not with
> loops. Maybe a further example:
>
> data:
>
> Smells like homework without a particular application.
@Scott:
Even if that were the case :) I'd still like to figure out how to
create nested dictionaries!
Brandon
--
http://mail.python.org/mailman/listinfo/python-list
Thanks bear -
Some outside advice has me looking at nested dictionaries. But I am
still bogged down because I've not created one before and all examples
I can find are simple ones where they are created manually, not with
loops. Maybe a further example:
data:
POS1POS2 POS3
['word1','tag
Brandon wrote:
I have a series of lists in format ['word', 'tagA', 'tagB']. I have
converted this to a few dicts, such as one in which keys are tuples of
('word', 'tagB'), and the values are the number of times that key was
found.
Smells like homework without a particular application.
--
bearophile:
> you can do with a dict
> that has the tuple ('word', 'tagB') as key, and as value has a
> collections.defaultdict(int) that maps 'tagB' to its count.
Where's 'tagA'?
Probably I haven't understood your problem well enough. I need a
better example of your data and what you need...
Sor
Brandon:
> I need an dictionary idiom whereby I can find all instances of
> a given 'word' with any 'tagB', and then subdivide into all instances
> of a given 'tagB'. In both cases I would want the value as a count of
> all instances found.
If I have understood you well enough, I think you can do
Hi all,
I have a series of lists in format ['word', 'tagA', 'tagB']. I have
converted this to a few dicts, such as one in which keys are tuples of
('word', 'tagB'), and the values are the number of times that key was
found. I need an dictionary idiom whereby I can find all instances of
a given '