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 build_tables.py from madviking/technology-taxonomy: direct link, hf CLI and curl.
- Browser
- Download file 2.69 kB
-
https://huggingface.co/datasets/madviking/technology-taxonomy/resolve/main/build_tables.py
- Command line
-
hf download hf://datasets/madviking/technology-taxonomy/build_tables.py
-
curl -L -o build_tables.py https://huggingface.co/datasets/madviking/technology-taxonomy/resolve/main/build_tables.py
2.69 kB
| """Derive the Hugging Face reference tables from the checksum-verified release. | |
| Run: python3 build_tables.py | |
| Only the four JSONL files are written. Original release bytes are never edited. | |
| """ | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| def build(root): | |
| raw = (root / "taxonomy.json").read_bytes() | |
| expected = (root / "taxonomy.json.sha256").read_text().split()[0] | |
| if hashlib.sha256(raw).hexdigest() != expected: | |
| raise ValueError("taxonomy.json checksum mismatch") | |
| release = json.loads(raw) | |
| categories = {r["id"]: r for r in release["categories"]} | |
| domains = {r["id"]: r for r in release["domains"]} | |
| parents = {} | |
| for edge in release["relationships"]: | |
| if edge["type"] == "parent_of": | |
| child = edge["target_id"] | |
| if child in parents and parents[child] != edge["source_id"]: | |
| raise ValueError("Multiple parents require a revised table projection") | |
| parents[child] = edge["source_id"] | |
| technologies = [] | |
| string_fields = ( | |
| "canonical_id", "name", "slug", "description", "explanation", | |
| "classification_kind", "lifecycle", "popularity", "official_website", | |
| "official_documentation_url", "updated_at", "reviewed_at", | |
| ) | |
| for source in release["technologies"]: | |
| row = {key: source.get(key) for key in string_fields} | |
| row.update( | |
| release_version=release["taxonomy_version"], | |
| aliases=source.get("aliases", []), | |
| requires_context=source["requires_context"], | |
| category_ids=source.get("category_ids", []), | |
| domain_ids=source.get("domain_ids", []), | |
| sources=source.get("sources", []), | |
| parent_canonical_id=parents.get(source["canonical_id"]), | |
| ) | |
| row["category_names"] = [categories[k]["name"] for k in row["category_ids"]] | |
| row["domain_names"] = [domains[k]["name"] for k in row["domain_ids"]] | |
| technologies.append(row) | |
| tables = {"technologies": technologies} | |
| for name in ("categories", "domains", "relationships"): | |
| # Pad optional fields with null so every row has the same columns. | |
| keys = sorted({key for row in release[name] for key in row}) | |
| tables[name] = [{key: row.get(key) for key in keys} for row in release[name]] | |
| for name, rows in tables.items(): | |
| text = "".join(json.dumps(row, ensure_ascii=False, sort_keys=True, separators=(",", ":")) + "\n" for row in rows) | |
| (root / (name + ".jsonl")).write_text(text, encoding="utf-8") | |
| return tables | |
| if __name__ == "__main__": | |
| result = build(Path(__file__).resolve().parent) | |
| print({name: len(rows) for name, rows in result.items()}) | |