Download scripts/chains/count_ents.py from SocrAIte-Mosaic/patientphex-task1: direct link, hf CLI and curl.
- Browser
- Download file 473 Bytes
-
https://huggingface.co/SocrAIte-Mosaic/patientphex-task1/resolve/main/scripts/chains/count_ents.py
- Command line
-
hf download hf://SocrAIte-Mosaic/patientphex-task1/scripts/chains/count_ents.py
-
curl -L -o count_ents.py https://huggingface.co/SocrAIte-Mosaic/patientphex-task1/resolve/main/scripts/chains/count_ents.py
473 Bytes
| import json | |
| import sys | |
| from pathlib import Path | |
| p = Path(sys.argv[1]) | |
| rows = [json.loads(x) for x in p.read_text(encoding='utf-8').splitlines() if x.strip()] | |
| ents = sum(len(r.get('entities', [])) for r in rows) | |
| docs = len(rows) | |
| print('%s docs=%d entities=%d' % (p.name, docs, ents)) | |
| if len(sys.argv) > 2: | |
| target = float(sys.argv[2]) | |
| lo, hi = int(target * 0.5), int(target * 1.5) | |
| print('band=[%d,%d] %s' % (lo, hi, 'OK' if lo <= ents <= hi else 'OUT_OF_BAND')) | |