Datasets:
Download code/evaluation-code/ent400-a06a1576/np/numeric_choice.py from VEHwang/cocogni4d: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/ent400-a06a1576/np/numeric_choice.py
- Command line
-
hf download hf://datasets/VEHwang/cocogni4d/code/evaluation-code/ent400-a06a1576/np/numeric_choice.py
-
curl -L -o numeric_choice.py https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/ent400-a06a1576/np/numeric_choice.py
1.71 kB
| """python3 -m np.numeric_choice GROUPS... --out choices.jsonl [--seed 0].""" | |
| import argparse | |
| import collections | |
| import json | |
| import random | |
| from embodied_pipeline.prover.numeric_choice import NUMERIC, build_many, nodes | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument('groups', nargs='+') | |
| parser.add_argument('--out', required=True) | |
| parser.add_argument('--seed', type=int, default=0) | |
| args = parser.parse_args() | |
| rng = random.Random(args.seed) | |
| counts, skips = collections.Counter(), collections.Counter() | |
| inputs = [] | |
| for path in args.groups: | |
| with open(path) as source: | |
| for line in source: | |
| row = json.loads(line) | |
| if row.get('decision', {}).get('result') == 'PASS' and any( | |
| n.get('method') in NUMERIC for n in nodes(row['public']['slots'])): | |
| inputs.append((path, row)) | |
| with open(args.out, 'w') as output: | |
| for (path, row), choice in zip(inputs, build_many([r for _, r in inputs], rng)): | |
| version = row['public']['version_id'] | |
| if 'skip' in choice: | |
| skips[version+' | '+choice['skip']] += 1 | |
| else: | |
| counts[version] += 1 | |
| output.write(json.dumps(dict(schema='numeric-choice/1', candidate_id=row['candidate_id'], | |
| version_id=version, scope=row.get('scope', {}), | |
| source_file=path, scoring={'kind': 'exact'}, **choice))+'\n') | |
| print(json.dumps(dict(converted=dict(sorted(counts.items())), skip=dict(sorted(skips.items()))), indent=2)) | |
| if __name__ == '__main__': | |
| main() | |