SPB Git

Repository Public Research preview

taxonomy.py 3.6 KB 67 lines python

1"""Coarse discipline taxonomy and era buckets used for stratification and style conditioning."""2from __future__ import annotations34import re56DISCIPLINES = ["biomedicine", "life_sciences", "physics", "mathematics", "computer_science", "statistics", "economics", "finance", "social_sciences", "engineering", "chemistry", "earth_sciences", "humanities", "general_reference", "other"]78ERAS = [("pre1900", None, 1899), ("1900-1949", 1900, 1949), ("1950-1979", 1950, 1979), ("1980-1999", 1980, 1999), ("2000-2009", 2000, 2009), ("2010-2017", 2010, 2017)]91011def era_of(year: int | None) -> str:12    if year is None:13        return "unknown"14    for name, lo, hi in ERAS:15        if (lo is None or year >= lo) and year <= hi:16            return name17    return "post2017"181920_ARXIV_MAP = [21    (r"^q-fin", "finance"), (r"^econ", "economics"), (r"^stat", "statistics"), (r"^math", "mathematics"), (r"^cs", "computer_science"),22    (r"^(astro-ph|cond-mat|gr-qc|hep|math-ph|nlin|nucl|physics|quant-ph)", "physics"), (r"^q-bio", "life_sciences"), (r"^eess", "engineering"),23]242526def discipline_from_arxiv(categories: list[str]) -> str:27    for c in categories:28        for pat, d in _ARXIV_MAP:29            if re.match(pat, c):30                return d31    return "other"323334# Journal-title and subject-category hints for PMC. Word boundaries matter: "physiology" is not physics,35# "biochemistry" is life sciences, "computational biology" is life sciences. Order = priority.36_PMC_HINTS = [37    (r"\bfinanc", "finance"),38    (r"\beconom", "economics"),39    (r"\b(?:bio)?statist|\bbiostat|\bbiometri", "statistics"),40    (r"\bphysics\b|\bphysical review\b|\boptics?\b|\bphotonic|\bacoustic|\bastronom|\bastrophys", "physics"),41    (r"\bmathemati|\balgebra|\bgeometr", "mathematics"),42    (r"\bcomputer\b|\bcomputing\b|\bsoftware\b|\binformatics?\b|\bbioinformatic|\bdata mining\b|\bmachine learning\b|\bartificial intelligence\b|\balgorithm", "computer_science"),43    (r"(?<!bio)(?<!neuro)(?<!electro)(?<!physico)(?<!biological )(?<!medicinal )\bchemistry\b|\bchemical\b|\banalytical chem|\borganic chem|\bpolymer", "chemistry"),44    (r"\bengineer|\bmaterials\b|\bnanotechnolog|\bnanoscale|\bsensors?\b|\brobotic", "engineering"),45    (r"\bgeolog|\bgeophys|\bgeoscien|\bearth\b|\bclimat|\bmeteorolog|\boceanogr|\bhydrolog|\benvironmental (?:science|research|monitoring)", "earth_sciences"),46    (r"\bpsycholog|\bsociolog|\banthropolog|\beducation|\bpolitical|\blinguistic|\bdemograph|\bsocial science|\bhuman geogr", "social_sciences"),47    (r"\bhistory\b|\bphilosoph|\bliterature\b|\barchaeolog|\barcheolog|\bhumanities", "humanities"),48    (r"\becolog|\bevolution|\bbotan|\bzoolog|\bplant\b|\bmicrobio|\bgenetic|\bgenom|\bmolecular|\bcell\b|\bbiolog|\bbiochem|\bbiophys|\bentomolog|\bmarine\b|\bagricultur|\bveterinar|\bneuroscience", "life_sciences"),49]50_MULTIDISCIPLINARY = re.compile(r"\bplos one\b|\bscientific reports\b|\bpeerj\b|\bf1000|\bheliyon\b|\bbmj open\b|\bnature communications\b|\broyal society open science\b|\bsage open\b|\bspringerplus\b", re.I)515253def discipline_from_pmc(journal: str | None, subjects: list[str]) -> str:54    """Coarse discipline from journal title first, then subject categories (used for multidisciplinary venues)."""55    j = (journal or "").lower()56    if j and not _MULTIDISCIPLINARY.search(j):57        for pat, d in _PMC_HINTS:58            if re.search(pat, j):59                return d60    s = " ".join(subjects).lower()61    for pat, d in _PMC_HINTS:62        if re.search(pat, s):63            return d64    if j and _MULTIDISCIPLINARY.search(j) and not s:65        return "biomedicine"66    return "biomedicine"67
Files main
Menu

Theme