old_contents: #!/usr/bin/env python
  
  import sys
  
  # Open just for read
  dbpediadb = set(open('dbpedia_labels.txt').read().splitlines())
  
  for line in sys.stdin:
      # remove leading and trailing whitespace
      line = line.strip()
      # split the line into words
      ngram, num = line.split('\t')
  
      if ngram in dbpediadb:
          print '%s\t%s' % (ngram.replace(' ', '_'), num)
  
  
new_contents: #!/usr/bin/env python
  
  import sys
  import shelve
  
  # Open just for read
  dbpediadb = shelve.open('dbpedia_types.dbm')
  
  for line in sys.stdin:
      # remove leading and trailing whitespace
      line = line.strip()
      # split the line into words
      ngram, num = line.split('\t')
  
      uri_ngram = ngram.replace(' ', '_')
      if uri_ngram in dbpediadb:
          # put canonical url
          print '%s\t%s' % (dbpediadb[uri_ngram], num)
  
  dbpediadb.close()
  
subject: Update mapper_dbpedia_uri_counts.py