{"data":{"slug":"github-aipoch-medical-research-skills-scientific-skills-evidence-insight-literature-filtering-42f181799dab","title":"Filter Literature by Year, Journal, and Screening Rules","summary":"Filter a bibliography by publication year range, journal whitelist\/blacklist, and inclusion\/exclusion rules to produce inclusion\/exclusion lists and a screening log for systematic reviews or preliminary screening.","url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-scientific-skills-evidence-insight-literature-filtering-42f181799dab","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-aipoch-medical-research-skills-scientific-skills-evidence-insight-literature-filtering-42f181799dab","markdown_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-scientific-skills-evidence-insight-literature-filtering-42f181799dab.md","download_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-scientific-skills-evidence-insight-literature-filtering-42f181799dab\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Before running the script, ensure the input CSV file contains columns: id, title, year, journal, and abstract. A journal alias mapping file is optional but recommended for consistent normalization.","instructions":"---\nname: literature-filtering\ndescription: Filter literature by publication year, journal, and predefined screening rules to produce inclusion\/exclusion lists; use when conducting preliminary screening or systematic review screening to narrow the literature scope.\nlicense: MIT\nauthor: AIPOCH\n---\n> **Source**: [https:\/\/github.com\/aipoch\/medical-research-skills](https:\/\/github.com\/aipoch\/medical-research-skills)\n\n## When to Use\n\n- You need to quickly narrow a large bibliography by **publication year range** (e.g., 2015\u20132024).\n- You must restrict results to a **target journal set** (e.g., a whitelist\/blacklist of journals).\n- You are running **preliminary screening** before full-text review and need traceable inclusion\/exclusion decisions.\n- You are conducting **systematic review screening** and must record consistent reasons for exclusion.\n- You need standardized outputs (lists + logs) for collaboration, auditing, or downstream analysis.\n\n## Key Features\n\n- Rule-based filtering by **year**, **journal**, and **literature type\/criteria**.\n- **Journal name normalization** to match abbreviations and full names consistently.\n- Structured recording of **exclusion reasons** for transparency and reproducibility.\n- Support for **borderline\/controversial item review** to improve consistency.\n- Standardized outputs: **inclusion list**, **exclusion list**, and **screening statistics\/summary**.\n\n## Dependencies\n\n- None (documentation-driven workflow).\n- Optional template file:\n  - `assets\/screening_log_template.csv`\n\n## Example Usage\n\nThe following example is a complete, runnable Python script that:\n1) normalizes journal names, 2) filters by year and journal whitelist, 3) applies simple inclusion\/exclusion rules, and 4) outputs inclusion\/exclusion CSV files plus a screening log.\n\n```python\n#!\/usr\/bin\/env python3\nimport csv\nimport re\nfrom dataclasses import dataclass\nfrom typing import Dict, List, Tuple\n\n# ----------------------------\n# Configuration (edit as needed)\n# ----------------------------\nYEAR_MIN = 2018\nYEAR_MAX = 2024\n\n# Journal whitelist after normalization\nJOURNAL_WHITELIST = {\n    \"journal of finance\",\n    \"journal of financial economics\",\n    \"review of financial studies\",\n}\n\n# Abbreviation\/full-name mapping (extend as needed)\nJOURNAL_ALIASES = {\n    \"j. finan.\": \"journal of finance\",\n    \"j finan\": \"journal of finance\",\n    \"jfe\": \"journal of financial economics\",\n    \"rev. financ. stud.\": \"review of financial studies\",\n    \"rfs\": \"review of financial studies\",\n}\n\n# Simple keyword-based screening rules (example)\nINCLUDE_KEYWORDS = {\"asset pricing\", \"corporate finance\", \"risk premium\"}\nEXCLUDE_KEYWORDS = {\"editorial\", \"book review\", \"erratum\"}\n\n# ----------------------------\n# Data model\n# ----------------------------\n@dataclass\nclass Record:\n    id: str\n    title: str\n    year: int\n    journal: str\n    abstract: str\n\n# ----------------------------\n# Helpers\n# ----------------------------\ndef normalize_journal(name: str, aliases: Dict[str, str]) -> str:\n    \"\"\"\n    Normalize journal names:\n    - lowercase\n    - strip punctuation\n    - collapse whitespace\n    - map abbreviations to canonical full names\n    \"\"\"\n    if not name:\n        return \"\"\n    raw = name.strip().lower()\n    raw = re.sub(r\"[^\\w\\s\\.]\", \" \", raw)  # keep dots for alias keys like \"j. finan.\"\n    raw = re.sub(r\"\\s+\", \" \", raw).strip()\n\n    # Try alias mapping on the dot-preserved version\n    if raw in aliases:\n        return aliases[raw]\n\n    # Also try a dot-stripped variant\n    nodot = raw.replace(\".\", \"\")\n    if nodot in aliases:\n        return aliases[nodot]\n\n    # Canonicalize by removing dots and extra spaces\n    canonical = re.sub(r\"[\\.]\", \"\", raw)\n    canonical = re.sub(r\"\\s+\", \" \", canonical).strip()\n    return canonical\n\ndef contains_any(text: str, keywords: set) -> bool:\n    t = (text or \"\").lower()\n    return any(k in t for k in keywords)\n\ndef screen_record(r: Record) -> Tuple[bool, str]:\n    \"\"\"\n    Returns (included, reason).\n    Reasons are designed to be human-auditable.\n    \"\"\"\n    if r.year < YEAR_MIN or r.year > YEAR_MAX:\n        return False, f\"Excluded: year out of range ({r.year})\"\n\n    norm_journal = normalize_journal(r.journal, JOURNAL_ALIASES)\n    if norm_journal not in JOURNAL_WHITELIST:\n        return False, f\"Excluded: journal not in whitelist ({norm_journal})\"\n\n    text = f\"{r.title}\\n{r.abstract}\"\n    if contains_any(text, EXCLUDE_KEYWORDS):\n        return False, \"Excluded: matches exclusion keywords\"\n\n    if not contains_any(text, INCLUDE_KEYWORDS):\n        return False, \"Excluded: does not match inclusion keywords\"\n\n    return True, \"Included: meets all criteria\"\n\n# ----------------------------\n# I\/O\n# ----------------------------\ndef read_input_csv(path: str) -> List[Record]:\n    \"\"\"\n    Expected columns: id,title,year,journal,abstract\n    \"\"\"\n    out = []\n    with open(path, \"r\", newline=\"\", encoding=\"utf-8\") as f:\n        reader = csv.DictReader(f)\n        for row in reader:\n            out.append(\n                Record(\n                    id=row.get(\"id\", \"\").strip(),\n                    title=row.get(\"title\", \"\").strip(),\n                    year=int(row.get(\"year\", \"0\")),\n                    journal=row.get(\"journal\", \"\").strip(),\n                    abstract=row.get(\"abstract\", \"\").strip(),\n                )\n            )\n    return out\n\ndef write_csv(path: str, rows: List[Dict[str, str]], fieldnames: List[str]) -> None:\n    with open(path, \"w\", newline=\"\", encoding=\"utf-8\") as f:\n        w = csv.DictWriter(f, fieldnames=fieldnames)\n        w.writeheader()\n        w.writerows(rows)\n\ndef main():\n    input_path = \"input_literature.csv\"\n    records = read_input_csv(input_path)\n\n    included, excluded, log = [], [], []\n    for r in records:\n        norm_journal = normalize_journal(r.journal, JOURNAL_ALIASES)\n        ok, reason = screen_record(r)\n\n        log.append({\n            \"id\": r.id,\n            \"title\": r.title,\n            \"year\": str(r.year),\n            \"journal_raw\": r.journal,\n            \"journal_normalized\": norm_journal,\n            \"decision\": \"include\" if ok else \"exclude\",\n            \"reason\": reason,\n        })\n\n        base = {\n            \"id\": r.id,\n            \"title\": r.title,\n            \"year\": str(r.year),\n            \"journal\": norm_journal,\n        }\n        (included if ok else excluded).append(base)\n\n    write_csv(\"included.csv\", included, [\"id\", \"title\", \"year\", \"journal\"])\n    write_csv(\"excluded.csv\", excluded, [\"id\", \"title\", \"year\", \"journal\"])\n    write_csv(\n        \"screening_log.csv\",\n        log,\n        [\"id\", \"title\", \"year\", \"journal_raw\", \"journal_normalized\", \"decision\", \"reason\"],\n    )\n\n    # Simple screening statistics\n    stats = {\n        \"total\": len(records),\n        \"included\": len(included),\n        \"excluded\": len(excluded),\n    }\n    print(\"Screening complete:\", stats)\n    print(\"Outputs: included.csv, excluded.csv, screening_log.csv\")\n\nif __name__ == \"__main__\":\n    main()\n```\n\nMinimal input file example (`input_literature.csv`):\n\n```csv\nid,title,year,journal,abstract\n1,Asset Pricing with Risk Premiums,2020,J. Finan.,We study asset pricing and the risk premium...\n2,An Editorial Note,2021,Journal of Finance,This editorial summarizes...\n3,Corporate Finance Evidence,2017,JFE,Empirical corporate finance results...\n```\n\n## Implementation Details\n\n### 1. Rule Setting\n\n- **Year rules**: define an inclusive range `[YEAR_MIN, YEAR_MAX]`.\n- **Journal rules**:\n  - Use a **whitelist** (or blacklist) of canonical journal names.\n  - Apply **normalization** before matching to avoid false mismatches.\n- **Screening criteria**:\n  - Define explicit inclusion\/exclusion criteria (e.g., topic, study type, population, method).\n  - Ensure each exclusion has a **single primary reason** (or a controlled multi-reason scheme).\n\n### 2. Journal Name Normalization\n\nRecommended normalization steps (in order):\n\n1. Convert to lowercase.\n2. Remove\/standardize punctuation and collapse whitespace.\n3. Apply **abbreviation\/full-name mapping** (e.g., `J. Finan.` \u2192 `Journal of Finance`).\n4. Output a canonical form used for matching and reporting.\n\nKey parameters:\n- `JOURNAL_ALIASES`: dictionary for abbreviation\/full-name mapping.\n- Normalization policy choices:\n  - Case sensitivity (typically disabled by lowercasing).\n  - Punctuation handling (strip most punctuation; optionally preserve dots for alias keys).\n  - Whitespace collapsing.\n\n### 3. Execution of Screening\n\n- Apply filters in a stable order to keep decisions consistent and auditable:\n  1. Year range\n  2. Journal match (after normalization)\n  3. Inclusion\/exclusion criteria\n- Record a **decision** and **reason** for every record in a screening log.\n\n### 4. Review and Consistency\n\n- Flag borderline items (e.g., unclear abstracts, ambiguous journal names) for manual review.\n- Keep a shared, versioned rule set (year range, journal list, alias map, criteria) to ensure consistent application across reviewers.\n\n### 5. Output Organization\n\nProduce at minimum:\n- `included.csv`: records that pass all rules.\n- `excluded.csv`: records that fail at least one rule.\n- `screening_log.csv`: full trace with normalized journal and exclusion reason.\n- Optional: screening statistics and a reason summary (counts by reason).\n\nReference formats and checkpoints can be aligned with `references\/guide.md` if available.","use_cases":["Narrow a large bibliography by publication year range (e.g., 2015\u20132024).","Restrict results to a target journal set (e.g., a whitelist\/blacklist of journals).","Conduct preliminary screening before full-text review with traceable inclusion\/exclusion decisions.","Perform systematic review screening with consistent exclusion reasons."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/aipoch\/medical-research-skills\/blob\/686e09dfdb45d9fa1a08664f06bb93769b3c9d91\/scientific-skills\/Evidence%20Insight\/literature-filtering\/SKILL.md","source_commit":"686e09dfdb45d9fa1a08664f06bb93769b3c9d91","license":"MIT","version":null,"listing_approved_at":"2026-11-26","created_at":"2026-11-24T13:05:26.000000Z","updated_at":"2026-11-26T09:24:51.000000Z","seo_title":"Filter literature by year journal and screening rules","seo_description":"Automate literature screening for systematic reviews by filtering by publication year, journal, and inclusion\/exclusion rules.","seo_keywords":["literature screening tool","systematic review filtering","journal publication filter","bibliography year range filter","exclusion reason tracking"]}}