次の形式でネストされた辞書を作成しようとしています。
{person1:
{tweet1 that person1 wrote: times that tweet was retweeted},
{tweet2 that person1 wrote: times that tweet was retweeted},
person2:
{tweet1 that person2 wrote: times that tweet was retweeted},...
}
次のデータ構造から作成しようとしています。以下は、実際のものの切り捨てられたバージョンです。
rt_sources =[u'SaleskyKATU', u'johnfaye', u'@anisabartes']
retweets = [[],
[u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT',u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT', u'Stay safe #nyc #sandy http://t.co/TisObxxT'], []]
annotated_retweets = {u'Stay safe #nyc #sandy http://t.co/TisObxxT':26}
'''
Key is a tweet from set(retweets)
Value is how frequency of each key in retweets
'''
for_Nick = {person:dict(tweet_record,[annotated_tweets[tr] for tr in tweet_record])
for person,tweet_record in zip(rt_sources,retweets)}