Spaces:
Running
Running
unknown
Claude Opus 5.5
Journal Finder: SCIE / SSCI / AHCI / ESCI lists from Wikidata (open, partial) until Clarivate's lists are added
ee1736c Download devtools/fetch_wos_wikidata.py from Rasheed/Test_AI_writing: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/spaces/Rasheed/Test_AI_writing/resolve/main/devtools/fetch_wos_wikidata.py
- Command line
-
hf download hf://spaces/Rasheed/Test_AI_writing/devtools/fetch_wos_wikidata.py
-
curl -L -o fetch_wos_wikidata.py https://huggingface.co/spaces/Rasheed/Test_AI_writing/resolve/main/devtools/fetch_wos_wikidata.py
1.79 kB
| """Web of Science collection lists (SCIE / SSCI / AHCI / ESCI) from Wikidata ("indexed in bibliographic review", | |
| P8875), for when Clarivate's Master Journal List downloads are not available. Wikidata is CC0 but incomplete | |
| (roughly 60-90 % of each collection), so a journal missing here may still be indexed. | |
| python devtools/fetch_wos_wikidata.py -> finder/data/wos/wikidata_<COLL>.csv | |
| """ | |
| import csv | |
| import sys | |
| from pathlib import Path | |
| import requests | |
| COLLECTIONS = {"SCIE": "Q104047209", "SSCI": "Q1090953", "AHCI": "Q713927", "ESCI": "Q22908122"} | |
| OUT = Path(__file__).resolve().parent.parent / "finder" / "data" / "wos" | |
| QUERY = """SELECT ?j ?title ?issn WHERE { | |
| ?j p:P8875 ?st . ?st ps:P8875 wd:%s . | |
| FILTER NOT EXISTS { ?st pq:P582 ?end } # no longer indexed | |
| ?j wdt:P236 ?issn . | |
| OPTIONAL { ?j wdt:P1476 ?t } OPTIONAL { ?j rdfs:label ?l FILTER(LANG(?l) = "en") } | |
| BIND(COALESCE(?t, ?l) AS ?title) }""" | |
| def fetch(qid: str) -> list[tuple[str, str]]: | |
| r = requests.get("https://query.wikidata.org/sparql", params={"query": QUERY % qid, "format": "json"}, | |
| headers={"User-Agent": "CS-AI-Writing-Suite-Finder/1.0"}, timeout=300) | |
| r.raise_for_status() | |
| return [(b.get("title", {}).get("value", ""), b["issn"]["value"]) for b in r.json()["results"]["bindings"]] | |
| def main() -> int: | |
| OUT.mkdir(parents=True, exist_ok=True) | |
| for coll, qid in COLLECTIONS.items(): | |
| rows = sorted(set(fetch(qid))) | |
| with open(OUT / f"wikidata_{coll}.csv", "w", newline="", encoding="utf-8") as f: | |
| w = csv.writer(f) | |
| w.writerow(["Journal title", "ISSN"]) | |
| w.writerows(rows) | |
| print(f"{coll}: {len({i for _, i in rows}):,} ISSNs") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |