# Lists the labels of a JSONL file touching a range: id, bounds, family, first N chars of description. Args: file FROM TO [N] [family-filter] import json, sys f, a, b = sys.argv[1:4] n = int(sys.argv[4]) if len(sys.argv) > 4 else 120 fam = sys.argv[5] if len(sys.argv) > 5 else None rows = [] for l in open(f): l = l.strip() if not l: continue d = json.loads(l) if d['start'] < b and d['end'] >= a and (not fam or d['family'] == fam): rows.append(d) rows.sort(key=lambda d: d['start']) from collections import Counter print(Counter(d['family'] for d in rows)) for d in rows: print(d['id'], d['start'], d['end'], d['family'], '|', d['description'][:n])