Created
April 15, 2019 15:56
-
-
Save GabsGear/e92c0666d16fd61e1a7b032090311afe 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
import os, io | |
def read_item_names(): | |
"""Read the u.item file from MovieLens 100-k dataset and returns a | |
mapping to convert raw ids into movie names. | |
""" | |
file_name = (os.path.expanduser('~') + | |
'/.surprise_data/ml-100k/ml-100k/u.item') | |
rid_to_name = {} | |
with io.open(file_name, 'r', encoding='ISO-8859-1') as f: | |
for line in f: | |
line = line.split('|') | |
rid_to_name[line[0]] = line[1] | |
return rid_to_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment