File size: 1,169 Bytes
37cea5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)