okf-wiki 1.1.1
First public release, published as one snapshot. What changed between versions is in CHANGELOG.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
commit
0fd86a23a3
227 changed files with 96077 additions and 0 deletions
26
gates/stubs/fasit_reader.py
Normal file
26
gates/stubs/fasit_reader.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"""Known-positive reader for the file-type gate: answers every query from the frozen pairs file (the fasit itself).
|
||||
|
||||
It reads no source file. A GREEN gate with it shows that the pairs, the manifest and the gate's scoring agree;
|
||||
it says nothing about any real reader.
|
||||
|
||||
Usage: python3 gates/stubs/fasit_reader.py {file} {queries} <pairs.json>
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main() -> int:
|
||||
queries = json.loads(Path(sys.argv[2]).read_text(encoding="utf-8"))
|
||||
key = {p["id"]: p for p in json.loads(Path(sys.argv[3]).read_text(encoding="utf-8"))["pairs"]}
|
||||
answers = [{"id": q["id"], "found": [{"locator": key[q["id"]]["locator"], "hidden": key[q["id"]]["hidden"]}]}
|
||||
for q in queries["queries"] if q["id"] in key]
|
||||
print(json.dumps({"answers": answers}))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue