title: python-TypeError: string indices must be integers. How to fix?
body: <p>I'm querying Google+ data with TF-IDF and save the data as a <code>JSON</code>file. While working with this file I get an error.</p>
  
  <p>Code</p>
  
  <pre><code>import json
  import nltk
  
  DATA = 'C:/Users/Dung Ring/Desktop/kpdl/107033731246200681024.json'
  data = json.loads(open(DATA).read())
  
  QUERY_TERMS = ['SOPA']
  
  activities = [activity['object']['content'].lower().split() \
            for activity in data \
              if activity['object']['content'] != " "]
  
  # TextCollection provides tf, idf, and tf_idf abstractions so 
  # that we don't have to maintain/compute them ourselves
  
  tc = nltk.TextCollection(activities)
  
  relevant_activities = []
  
  for idx in range(len(activities)):
      score = 0
      for term in [t.lower() for t in QUERY_TERMS]:
          score += tc.tf_idf(term, activities[idx])
      if score &gt; 0:
           relevant_activities.append({'score': score, 'title': data[idx]['title'],
                            'url': data[idx]['url']})
  
  # Sort by score and display results
  
  relevant_activities = sorted(relevant_activities, key=lambda p: p['score'],    reverse=True)
  for activity in relevant_activities:
        print activity['title']
        print '\tLink: %s' % (activity['url'], )
        print '\tScore: %s' % (activity['score'], )
        print
  </code></pre>
  
  <p>Error message</p>
  
  <pre><code>Traceback (most recent call last):
    File "ex9.py", line 11, in &lt;module&gt;
      if activity['object']['content']!= ""]
  TypeError: string indices must be integers
  </code></pre>
  
  <p>I use Python 2.7.</p>