import json import argparse def count_non_universe_targets(data_path, universe_path): # Load universe file entities into a set for fast lookup universe_entities = set() with open(universe_path, 'r') as universe_file: for line in universe_file: entity = json.loads(line.strip()) universe_entities.add(entity) # Count entries in data file with targets not in universe non_universe_count = 0 total_count = 0 with open(data_path, 'r') as data_file: for line in data_file: data_entry = json.loads(line.strip()) total_count += 1 if data_entry['target'] not in universe_entities: non_universe_count += 1 print(f'Total entries: {total_count}') print(f'Entries with targets not in universe: {non_universe_count}') if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--data', required=True, help='Path to input data jsonl file') parser.add_argument('--universe', required=True, help='Path to universe jsonl file') args = parser.parse_args() count_non_universe_targets(args.data, args.universe)