Manmeet2002/Accessibility_Project
0
1# parse_data.py2import json3 4# This is the big file we just added5WLASL_JSON_FILE = 'WLASL_info.json' 6OUTPUT_MAP_FILE = 'sign_video_map.json'7 8print(f"Loading data from {WLASL_JSON_FILE}...")9 10try:11 with open(WLASL_JSON_FILE, 'r') as f:12 data = json.load(f)13except FileNotFoundError:14 print(f"ERROR: Could not find {WLASL_JSON_FILE}.")15 print("Please make sure you moved and renamed the file correctly.")16 exit()17 18video_map = {}19 20# The WLASL JSON is a list of entries21for entry in data:22 word = entry['gloss']23 24 # An entry can have many video instances25 if not entry['instances']:26 continue27 28 # Let's just grab the FIRST video instance for simplicity29 first_instance = entry['instances'][0]30 31 # Get the video ID (which matches the .mp4 file name)32 video_id = first_instance.get('video_id')33 34 if word and video_id:35 # Save the word in lowercase for easy lookup36 if word.lower() not in video_map:37 video_map[word.lower()] = video_id38 39# Now, save our new, simple map40with open(OUTPUT_MAP_FILE, 'w') as f:41 json.dump(video_map, f, indent=2)42 43print(f"Success! Created {OUTPUT_MAP_FILE} with {len(video_map)} sign-to-video links.")