Last active
August 29, 2015 14:07
-
-
Save amkatrutsa/2ecf7b7267dd752bf3dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # First version: len(person_id) = 15352 | |
| person_id = {} | |
| with open(in_dir + 'ID-title_dict.pickle', 'rb') as f: | |
| id2title = cPickle.load(f) | |
| with open(in_dir + 'person_id.txt') as f: | |
| for p_id in f: | |
| try: | |
| t = id2title[int(p_id)] | |
| person_id[int(p_id)] = 0 | |
| except KeyError: | |
| continue | |
| print "Number of person's id", len(person_id) | |
| # Second version: len(person_id) = 30497 | |
| person_id = [] | |
| with open(in_dir + 'ID-title_dict.pickle', 'rb') as f: | |
| id2title = cPickle.load(f) | |
| with open(in_dir + 'person_id.txt') as f: | |
| for p_id in f: | |
| try: | |
| t = id2title[int(p_id)] | |
| person_id.append(int(p_id)) | |
| except KeyError: | |
| continue | |
| print "Number of person's id", len(person_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment