Datasets:
Modalities:
Text
Formats:
json
Languages:
English
Size:
1K - 10K
Tags:
technology-taxonomy
reference-data
entity-linking
information-retrieval
job-ads
resume-parsing
License:
Download example.py from madviking/technology-taxonomy: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/datasets/madviking/technology-taxonomy/resolve/main/example.py
- Command line
-
hf download hf://datasets/madviking/technology-taxonomy/example.py
-
curl -L -o example.py https://huggingface.co/datasets/madviking/technology-taxonomy/resolve/main/example.py
1.33 kB
| """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)) | |