Datasets:
Modalities:
Text
Formats:
json
Languages:
English
Size:
1K - 10K
Tags:
technology-taxonomy
reference-data
entity-linking
information-retrieval
job-ads
resume-parsing
License:
File size: 1,325 Bytes
1072c7c | 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 | """Checksum-verified exact name/alias lookup; standard library only.
Usage: python3 example.py taxonomy.json PostgreSQL
"""
import hashlib
import json
import sys
from pathlib import Path
def lookup(path, query):
raw = path.read_bytes()
expected = Path(str(path) + ".sha256").read_text().split()[0]
if hashlib.sha256(raw).hexdigest() != expected:
raise ValueError("Dataset checksum mismatch")
release = json.loads(raw)
categories = {row["id"]: row["name"] for row in release["categories"]}
matches = []
for row in release["technologies"]:
candidates = [row["name"], *row.get("aliases", [])]
if any(query.casefold() == name.casefold() for name in candidates):
matches.append({
"canonical_id": row["canonical_id"],
"name": row["name"],
"requires_context": row["requires_context"],
"categories": [categories[k] for k in row.get("category_ids", [])],
})
return {"release_version": release["taxonomy_version"], "query": query, "candidates": matches}
if __name__ == "__main__":
if len(sys.argv) != 3:
raise SystemExit("Usage: python3 example.py taxonomy.json 'technology name'")
print(json.dumps(lookup(Path(sys.argv[1]), sys.argv[2]), ensure_ascii=False, indent=2))
|