Python Forum
Specifying Keys in txt file Dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Specifying Keys in txt file Dictionary
#1
So I am trying to build a dictionary that maps the key value to a specific value in a txt file. Its a txt file about movie reviews and I am trying to separate it into random reviews by each author. The format of the text file is |reviewId userId itemId rating title content|. So how would I specify that I want 100 random reviews from each author (userID) and place each all the random reviews into separate text files for test/train data.
Reply
#2
use a dictionary:
    'Gone With the Wind': {
        'stars': {
            'Vivien Leigh': 'Scarlett O'Hara',
            'William Clark Gable': 'Rhett Butler',
            ...
        },
        'other stuff': {
        }
    }
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020