forked from mgruppi/nela-gt-2019
-
Notifications
You must be signed in to change notification settings - Fork 2
/
load-labels.py
39 lines (26 loc) · 938 Bytes
/
load-labels.py
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
34
35
36
37
38
39
import argparse
# Load NELA-GT-2019 ground truth label file
def main():
parser = argparse.ArgumentParser()
parser.add_argument("path", type=str, help="Path to label file")
args = parser.parse_args()
labels = dict()
with open(args.path) as fin:
# Read out the header line from label file
fin.readline()
# Iterate over lines, taking the value from first column after name
# i.e., aggregated label
for line in fin:
l = line.strip().split(",")
source = l[0]
if l[1] == "": # NODATA for this entry, skip it
continue
labels[source] = int(l[1]) # get value from last column (label)
print("- Read labels for %d sources" % len(labels))
print("- Labels")
print("source, label\n")
for s in sorted(labels):
print(s,labels[s])
print("ALL DONE.")
if __name__ == "__main__":
main()